我试图自己做,但我无法正确管理它。以下是我的考试问题,我想要正确地做并理解它是如何运作的。如果你能帮助我,我将不胜感激。
确定目标(寄存器或存储器地址)以及以下程序片段的每条指令所存储的值:
mov eax, 0x8000
mov ebx, 0x40000
lea esp, [ebx]
shl eax, 16
sar ebx, 23
lea ecx, [ebx+0xff]
push ecx
sar eax, 31
push eax
mov eax, [esp+4]
sub eax, [esp]
答案 0 :(得分:5)
注释您的代码:
mov eax, 0x8000 ; Move the 32-bit value 0x8000 into register eax
mov ebx, 0x40000 ; Move the 32-bit value 0x40000 into register ebx
lea esp, [ebx] ; Load the value of register ebx into register esp
shl eax, 16 ; Take the value of register eax, shift left 16 bits, and store back into eax
sar ebx, 23 ; Take the value of register ebx, shift right 23 bits (copying sign bit), and store back into ebx
lea ecx, [ebx+0xff] ; Load the value of (register ebx) + 0xFF into register ecx
push ecx ; Push the value of register ecx onto the stack (the memory near the address of the value of register esp)
sar eax, 31 ; Take the value of register ebx, shift right 31 bits (copying sign bit), and store back into ebx
push eax ; Push the value of register eax onto the stack
mov eax, [esp+4] ; Move the vaule of register the memory at address (esp + 4) and store into eax
sub eax, [esp] ; Subtract the value of the memory at address esp from eax and store into eax
答案 1 :(得分:3)
这是intel汇编语法,因此每一行始终是
instruction destination source
eax
,esp
等都是注册名称。
数字被解释为数字常量。
[ expression ]
可用于计算地址,然后从该地址加载值。
我很乐观你可以通过阅读obvious wikipedia page来解决这个问题(并学到更多),甚至可以链接到a whole wikibook on x86 assembler。