What is the shortest way to fetch a value from memory in X86 Assembler?
OK, the shortest way is to pop registers, like pop eax
, it's one byte instruction.
But that can be used only in special cases, where the stack pointer ESP will point to a buffer,
and probably you won't use the stack for other purpose until the code that uses it is done.
The standard way is to use the mov
instruction.
There is no workaround in assembler haw to do that. All assembler instructions are strictly dedicated.
mov AL, 0x12
will load immediate the value 0x12 to register AL
xor AL,AL
the result of operation in AL register is 0
lodsb
will load byte from DS:[ESI] (or DS:[SI] under 16 bit CPU) memory address to AL
mov AL,[ESI]
will load byte from DS:[ESI] (or DS:[SI] under 16 bit CPU) memory address to AL
mov AL,[0xFFFF]
will load byte from DS:[0xFFFF] memory address to AL
pop AX
will load byte from SS:[ESP] (or SS:[SP] under 16 bit CPU) memory address to AL
in AL, 0x123
will load byte from port address 0x123
xlatb [EBX + AL]
will load byte from DS:[EBX + AL] memory address
...