0
votes

How do you convert a code like "a = Array[i]" into x86 assembly?

On ARM, you could do something like LDR R3, [R2, R1], but I couldn't manage to find a similar thing for x86.

There's "mov eax, [array + 0 * 4]", but you need to put integers instead of registers for it to work. So is there an equilivant in x86 as well?

Thank you

mov eax, [array + rdi+4] works, if array is in the low 32 bits of virtual address space. And [rcx + rdx*4] always works, exactly like scaled indexing on ARM. So whatever you actually tried, you haven't shown a minimal reproducible example of it. Also, if you want to see how C compiles, ask a compiler, e.g. for a function that takes an int* and a size_t, or that takes just an integer and return an element of a global array. How to remove "noise" from GCC/clang assembly output?Peter Cordes