Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
46 views

I am porting the GetCurrentMicro function in the Arduino Core STM8 to my SDCC code and I noticed the Cosmic C Compiler _asm function allows me to return a result as well as an input in a C var. Is ...
Jonas's user avatar
  • 1,239
1 vote
1 answer
181 views

Can you somehow grab a value from a register and put it into a C variable in C with the asm keyword for arm64 macOS assembly? I have seen code from other stack overflows that have already answered ...
Jordon's user avatar
  • 103
1 vote
0 answers
89 views

So, this piece of C++ code: /* * Compile on 64-bit Linux or Solaris (I guess it will probably also work on * FreeBSD), like this: * g++ -o bin2dec bin2dec.cpp -std=c++11 #Don't put -O3 * here, as ...
FlatAssembler's user avatar
6 votes
2 answers
126 views

I have recently been learning how to program bare metal to write a kernal for the rpi4b. The last thing I needed to add was a way to have the main script only run on one core. The method I decided to ...
MsFormula's user avatar
  • 175
2 votes
1 answer
113 views

I'm following bare metal programming guide: https://github.com/cpq/bare-metal-programming-guide Clangd produces error "Non-ASM statement in naked function is not supported" in Helix editor ...
agrinevich's user avatar
1 vote
0 answers
89 views

I've made a small mod app for the game Elden Ring. With this mod, whenever the player loses health, I reduce their level by 1. Everything works so far. What I want to do now is make it happen when ...
Fran's user avatar
  • 19
2 votes
1 answer
249 views

This comes from a post about invoking a trivial buffer overflow (to jump to a function present in the source but not called explicitly in any place of the program (2333909/how-can-i-invoke-buffer-...
nostromo's user avatar
  • 423
8 votes
1 answer
210 views

I have a project that has to use GCC 14 which does not have #embed support. I attempted to simulate it as follows. namespace { namespace { extern "C" { extern std::...
Jeremy Richards's user avatar
1 vote
1 answer
175 views

The following code attempts to create a simple stackful coroutine. It allocates a stack frame in the heap space by setting the rsp register and then calling a function. Afterwards, it exits the ...
algae's user avatar
  • 151
-1 votes
1 answer
94 views

NOTE: This is decompiled ghidra code, the imageBase start at 0x00400000, so we are working with Program.exe+001a0d39 relative to image base. 005a0d39 01 87 94 ADD dword ptr [EDI + ...
Interity's user avatar
4 votes
2 answers
186 views

I am fairly new to assembly. After compiling, when I run the code below, I get a segmentation fault. I am trying inline assembly with recursion. I am compiling this code with cxxdroid. int ...
Steven Vanhaeren's user avatar
2 votes
2 answers
213 views

Assembly is always faster than high-level languages. For example, I tested an empty loop in Delphi repeating 1 billion times, and same loop but written in assembly. The Delphi loop took 6 billion (x64 ...
JOrE's user avatar
  • 156
4 votes
3 answers
295 views

In an algorithm I am using, most of the time is spent in the evaluation of square roots using the sqrt function in cmath. In my application I only need the integer part of the square root of integers, ...
doetoe's user avatar
  • 831
1 vote
1 answer
170 views

I am just wondering why this code: void test(void) { asm volatile( "ud2\n\t" ".long " "%c0" "\n\t" ".word %c1\n\t&...
user14825657's user avatar
3 votes
0 answers
163 views

I want to define a assembly to read register from arm64. Code is like the following: asm volatile( "str <reg> [%0]\n" : : "r"(value) : "...
songzh's user avatar
  • 65
0 votes
0 answers
92 views

I try to write this simple C function for AVX2 horizontal sum in assembly. static inline float hsum256_ps(__m256 v) { __m128 lo = _mm256_castps256_ps128(v); __m128 hi = _mm256_extractf128_ps(v,...
Googlebot's user avatar
  • 15.8k
1 vote
1 answer
93 views

I am trying to accelerate the computation of the dot product of 2 float arrays on an ARM Cortex A7. I benchmark the pure C code, the code using intrinsics and the assembly code. But my assembly code ...
Fabrice Auzanneau's user avatar
3 votes
1 answer
101 views

Does GCC, when compiling for x86 or x86_64, make sure that the Direction Flag has some specific value before it starts executing an Extended Asm block? I couldn't find any information on that in the ...
bindiff's user avatar
  • 284
0 votes
0 answers
91 views

I wrote some inline assembly functions a few years ago which worked fine. And now with the most recent version of Android Studio (dec 2024) it spits error messages: error: invalid operand for inline ...
Jake 'Alquimista' LEE's user avatar
0 votes
1 answer
294 views

I'm writing up a benchmark to compare the movbe operation against mov; bswap to find out which is faster. I used to write "extern C function ..." up until now, but for specific reasons I can'...
clockw0rk's user avatar
  • 577
1 vote
0 answers
44 views

I got stuck when porting our codebase from GCC => LLVM/CLANG. After much attempts, I have narrowed the problem to a trivial reproducer. Surprisingly, I can't even seem to make things work with GCC :...
Ajay Garg's user avatar
1 vote
2 answers
114 views

I just want to take the value in a1 and assign it to a variable, so why does it make me put an instruction before using an out, or in this case a lateout? I've written the following assembly, but I ...
CocytusDEDI's user avatar
1 vote
2 answers
82 views

I wrote a code in ASM to calculate the reverse number. For example: input: 123, the result should be 321. The ebx register should have the result, but it aways shows 0. Also, I have an exception "...
Alex544's user avatar
  • 35
2 votes
1 answer
210 views

So I'm trying to use the RISC-V SBI debug console extension of OpenSBI on Qemu using inline Rust assembly, but it isn't working. I've come to learn that the issue may be because of memory placement, ...
CocytusDEDI's user avatar
0 votes
1 answer
142 views

I have the following code #include <stdio.h> volatile int global_counter = 0; void increment_counter() { for (int i = 0; i < 100000; ++i) { //global_counter++; asm (&...
Victor's user avatar
  • 1,465
1 vote
1 answer
221 views

There are no questions on ARM V7 inline assembly that answer mine so I made a post. I want to move the value of C variables into r0-r2 and the other way round - from the registers into C variables. ...
user avatar
1 vote
0 answers
68 views

I have searched for the specific question how to write banked registers in inline assembly but could not find an answer so my question seems novel. I want to write the lr_usr register in supervisor ...
user avatar
4 votes
1 answer
186 views

I use BOCHS to emulate Intel-80386 and try to write an operating system, but when I use an element of PCB after destroying PCB, it won't cause a page fault. It confused me for a few days. Maybe ...
Ares's user avatar
  • 43
6 votes
0 answers
88 views

I maintain C code that has inline assembly used by GCC, Clang and sufficiently compatible compilers¹. Inline assembly statements require constraints to tell the compiler what registers and memory are ...
Gilles 'SO- stop being evil''s user avatar
2 votes
1 answer
124 views

What does this mean in Valgrind's VALGRIND_DO_CLIENT_REQUEST_EXPR? __asm__ volatile ( __SPECIAL_INSTRUCTION_PREAMBLE /* %RDX = client_request ( %RAX ) */ "xchgq %rbx, %rbx" : ...
rhanqtl's user avatar
  • 113
3 votes
2 answers
126 views

I am trying to familiarise myself with gnu inline assembly. I wrote a single line inline asm to reinterpret int as float. While this prints the correct result, I am wondering whether this is correct. #...
Sai Charan Marrivada's user avatar
1 vote
1 answer
214 views

I am trying to create a class containing custom prologue/epilogues that shall be used by methods of other "consumer" classes. It should look like the following example. (Keep in mind that ...
user3387106's user avatar
2 votes
0 answers
159 views

I try to implement a simple coroutine using c. The platform is: M3 Pro MacBook Pro 16 apple native gcc macOS 14.3.1 Here is my code: // main.c #include <stdio.h> #include <stdlib.h> #...
JasonZhang's user avatar
2 votes
1 answer
107 views

I have this C code: #include <inttypes.h> #include <stdio.h> uint8_t count1(uint32_t x) { int out; __asm { mov edx, [x] mov al, 0 next: cmp edx, 0 je ...
Juraj's user avatar
  • 103
3 votes
1 answer
426 views

In LLDB, the step command steps over a whole asm{} block as a single "statement". Is there a way to make it treat each instruction separately so you don't have to use si to step ...
Juraj's user avatar
  • 103
1 vote
1 answer
199 views

I am using Embarcadero C++ Builder 12 and I am having a giant problem with my power function in Assembly, its called vpow(base, exp). It works perfectly with integers, but I need it to work with ...
Victor Melo's user avatar
2 votes
1 answer
195 views

I would like to write some gcc inline assembly for armv7em on Cortex-M7 to perform conversion between floating point numbers and fixed point numbers. ARM provides the vcvt instruction with #fbits to ...
user27039317's user avatar
1 vote
0 answers
67 views

Context I'm trying to write a piece of code in inline assembly, which processes all elements of a "small" array (say ~10 elements) as a fully-unrolled loop. I want to avoid falling into the ...
swineone's user avatar
  • 3,000
1 vote
0 answers
155 views

I've been working on a kernel that my system needs. I've implement some functions that acts as a wrapper for I/O. But somehow, the get_char() only returns 0. Code: uint8_t inb(uint16_t port) { ...
Minh Khôi Nguyễn's user avatar
1 vote
1 answer
122 views

I am implementing context switching for my first os and I came into a little problem I cannot solve which is restoring the cpu status after saving it from a struct. As all the registers have to be ...
Gabu's user avatar
  • 19
1 vote
1 answer
119 views

Recetly, this function rip_rel_ptr has been added to Linux kernel. https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/asm.h#L118. I can compile the kernel, but when I copy this ...
amrzar's user avatar
  • 367
2 votes
1 answer
121 views

In AT&T syntax you can do something like asm("mov %%eax, %0\n\t":"=r" (a[0])); but not in intel syntax. I want to translate this AT&T syntax to intel syntax, it gets the ...
mark pilsur's user avatar
8 votes
1 answer
273 views

Looking at some x86_64 GCC inline assembly, I have come across the following construct: int x; __asm__( "<opcode> %0" : "=m" (*&x) ); ^^^ ...
DevSolar's user avatar
  • 71k
2 votes
1 answer
196 views

I'm aware that when using gcc inline assembly, if you don't specify otherwise, it assumes that you consume all your inputs before you write any ouput operand. If you actually want to write to an ...
ChristmasTree's user avatar
-1 votes
3 answers
130 views

Im new with an assembler.Couldn't find the solution in the ethernet so asking here. This code outputs wrong numbers and i can't get why. #include <iostream> long DotProduct(short int* vec1, ...
Sheesh's user avatar
  • 1
1 vote
1 answer
368 views

I want to use x87's FSIN through gcc's / clang's inline assembly. How would a sin()-function using an __asm__-block internally for that look like with a 64 bit double parameter ? Using __builtin_sin() ...
Edison von Myosotis's user avatar
0 votes
1 answer
199 views

I want to calculate length of the word, but I have error. I don't understand why. int new_strlen(char* word) { int len = 0; __asm__ ("mov ecx, 100\n\t" &...
A_Elbereth_GIlthoniel's user avatar
1 vote
0 answers
69 views

I'm trying to find a difference of sets (I use vectors but idea is the same: arr1 \ arr2) using inline assembly in VS. But I can't get rid of the following error: "An exception was thrown: read ...
Ruslan Vaitukevich's user avatar
0 votes
1 answer
65 views

The following code, using gcc for ARMv4, is perfectly fine: asm("strb.w r2, [r0, #24 + 8 * 1]"); Now, if I try the following: asm("strb.w r2, [r0, %[offset] + %[delta] * %[scale]]"...
Hansel's user avatar
  • 257
2 votes
0 answers
248 views

I'm having slight issues with trying to use register-variables in clang-cl, on windows. I'm trying to declare a variable that simply reuses a (non-volatile) register that has been setup by a prior ...
Juliean's user avatar
  • 1,276

1
2 3 4 5
45