I have 2 simple, but maybe tricky questions. Let´s say I have assembler instruction:
MOV EAX,[ebx+6*7] – what I am curious is, does this instruction really actually translates into opcode as it stands,so computation of code in brackets is encoded into opcode, or is this just pseudo intruction for compiler, not CPU, so that compiler before computes the value in brackets using add mul and so, store outcome in some reg and than uses MOV EAX,reg with computed value? Just to be clear, I know the output will be the same. I am interested in execution.
Second is about LEA instruction. I know what it does, but I am more interested wheather its real instruction, so compiles does not further change it, just make it into opcode as it stands, or just pseudo code for compiler to, again, first compute adress and than store it.
The assembler (not compiler, although it’s very similar) will work out the
6*7bit as 42 and then the instruction is:This is what the processor can execute, by adding the contents of the
ebxregister and the constant 42, then using that address to load upeax. There is no instruction that encodes 6 and 7 as different entities, to be multiplied later.LEAis as real an instruction as any other. Again, the assembler can handle constant-folding (working out fixed values) to get the assembler statement into a usable form for the processor.You only have to think about the instruction:
This won’t be encoded as some (magical) sequence of bytes
eb 01 01 01 01 01 01 01, it will be encoded exactly the same as any of the following: