Question about x86 assembler

I have two simple, but maybe complex questions. Let's say I have an assembler instruction: MOV EAX, [ebx + 6 * 7] - I'm curious if this instruction really translates to the operation code, because the calculation of the code in brackets is encoded in the operation code or is it just a pseudo instruction for the compiler, not CPU, so the compiler uses add mul, etc. before calculating the value in brackets, etc. Save the result in some reg, and then use MOV EAX, reg with the calculated value? To be clear, I know that the output will be the same. I'm interested in performing.

Secondly, this is the LEA instruction. I know what he does, but I'm more interested in his real instruction, so compilations don't change it anymore, just turn it into an operation code as it is, or just a pseudo code for the compiler to calculate the address again and save it,

+3
source share
2 answers

The assembler (and not the compiler, although it is very similar) will produce a bit 6*7as 42, and then the instruction:

MOV EAX,[ebx+42]

This is what the processor can accomplish by adding the contents of the register ebxand constant 42, then using this address to load eax. There is no instruction that encodes 6 and 7 as different entities, which will then be multiplied.

LEA , . , ( ), .

:

mov ax,1+1+1+1+1+1+1

() eb 01 01 01 01 01 01 01, , :

mov ax,7
mov ax,49-42
mov ax,42/6
+5

1)
2)

. .

, , X86 , . , , , .

+3

Source: https://habr.com/ru/post/1745600/


All Articles