Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 下面的汇编代码实际上是做什么的?_Assembly_X86 64_Low Level - Fatal编程技术网

Assembly 下面的汇编代码实际上是做什么的?

Assembly 下面的汇编代码实际上是做什么的?,assembly,x86-64,low-level,Assembly,X86 64,Low Level,我不确定下面应该做什么,但这就是我到目前为止得到的 两个代码片段通过EAX进行间接调用。如果两个片段中的EBX值相同,则当两个片段将EBX添加到eax时,将调用相同的代码。两个代码片段通过eax进行间接调用。如果两个片段中的EBX值相同,则当两个片段将EBX添加到eax时,将调用相同的代码。片段A的正确描述为: mov eax, 5 ; move 5 into register eax add eax, ebx ; add contents of ebx to eax, c

我不确定下面应该做什么,但这就是我到目前为止得到的


两个代码片段通过EAX进行间接调用。如果两个片段中的EBX值相同,则当两个片段将EBX添加到eax时,将调用相同的代码。

两个代码片段通过eax进行间接调用。如果两个片段中的EBX值相同,则当两个片段将EBX添加到eax时,将调用相同的代码。

片段A的正确描述为:

mov eax, 5       ; move 5 into register eax
add eax, ebx     ; add contents of ebx to eax, changing eax
nop              ; no operation
nop              ; no operation
push ebx         ; push contents of ebx onto the stack
nop              ; no operation
pop ebx          ; pop top of the stack into ebx
call [eax]       ; call the subroutine pointed to at location [eax]
nop
指令后接
push ebx
指令后接
nop
指令后接
pop ebx
指令同样不会更改任何内容(除了将以前的
ebx
值保留在堆栈空间中的可用位置之外)。因此,在功能上(尽管消耗的CPU周期和代码空间减少),这相当于:

mov eax, 5       ; move 5 into register eax
add eax, ebx     ; add contents of ebx to eax, changing eax
call [eax]       ; call the subroutine pointed to at location [eax]
片段B是:

mov eax, 5       ; move 5 into register eax
push ecx         ; push contents of ecx onto the stack
pop ecx          ; pop top of the stack into ecx
add eax, ebx     ; add contents of ebx to eax, changing eax
swap eax, ebx    ; swap the contents of eax and ebx
swap ebx, eax    ; swap the contents of eax and ebx
call [eax]       ; call the subroutine pointed to at location [eax]
nop              ; no operation
在一行中交换两个寄存器不会产生任何净影响,只会消耗CPU周期和代码空间。因此片段B在功能上归结为:

mov eax, 5       ; move 5 into register eax
add eax, ebx     ; add contents of ebx to eax, changing eax
call [eax]       ; call the subroutine pointed to at location [eax]

功能与片段A相同。

片段A的正确描述为:

mov eax, 5       ; move 5 into register eax
add eax, ebx     ; add contents of ebx to eax, changing eax
nop              ; no operation
nop              ; no operation
push ebx         ; push contents of ebx onto the stack
nop              ; no operation
pop ebx          ; pop top of the stack into ebx
call [eax]       ; call the subroutine pointed to at location [eax]
nop
指令后接
push ebx
指令后接
nop
指令后接
pop ebx
指令同样不会更改任何内容(除了将以前的
ebx
值保留在堆栈空间中的可用位置之外)。因此,在功能上(尽管消耗的CPU周期和代码空间减少),这相当于:

mov eax, 5       ; move 5 into register eax
add eax, ebx     ; add contents of ebx to eax, changing eax
call [eax]       ; call the subroutine pointed to at location [eax]
片段B是:

mov eax, 5       ; move 5 into register eax
push ecx         ; push contents of ecx onto the stack
pop ecx          ; pop top of the stack into ecx
add eax, ebx     ; add contents of ebx to eax, changing eax
swap eax, ebx    ; swap the contents of eax and ebx
swap ebx, eax    ; swap the contents of eax and ebx
call [eax]       ; call the subroutine pointed to at location [eax]
nop              ; no operation
在一行中交换两个寄存器不会产生任何净影响,只会消耗CPU周期和代码空间。因此片段B在功能上归结为:

mov eax, 5       ; move 5 into register eax
add eax, ebx     ; add contents of ebx to eax, changing eax
call [eax]       ; call the subroutine pointed to at location [eax]

功能上与片段A相同。

指令的作用取决于语法(英特尔或AT&T)。由于您似乎在使用英特尔汇编语法,因此
mov eax,5
确实会将
5
移动到寄存器
eax
中。但是,
addeax,ebx
ebx
添加到
eax
,反之亦然。因此,在执行此指令之后,
eax
的内容为5加上
ebx
的内容,并且
ebx
不变。指令的作用取决于语法(Intel或AT&T)。由于您似乎在使用英特尔汇编语法,因此
mov eax,5
确实会将
5
移动到寄存器
eax
中。但是,
addeax,ebx
ebx
添加到
eax
,反之亦然。因此,在执行此指令之后,
eax
的内容是5加上
ebx
之前的内容,
ebx
不变。您对
call
指令的描述不太正确。这是一个内存间接调用,因此
EAX
只是函数指针的地址,而不是值(子程序本身的位置)
EIP=[EAX]
,而不是
EIP=EAX
@PeterCordes是的,很好。我是一级间接关闭。非常有帮助,非常感谢这个解释,我肯定是在完全理解的路上,有一件事我仍然不明白你说的调用[eax]意味着调用指向位置[eax]的子例程,但是你说的是什么子例程,它从何而来[]寄存器周围有什么特别的意思?@SeanSogMiller,括号表示里面是所需的地址。在这种情况下,
eax
的值取决于进入代码的
ebx
的值。这些信息没有说明,所以我们不知道是什么子程序。我们只知道它的地址在
eax
中给出的位置。您对
call
指令的描述不太正确。这是一个内存间接调用,因此
EAX
只是函数指针的地址,而不是值(子程序本身的位置)
EIP=[EAX]
,而不是
EIP=EAX
@PeterCordes是的,很好。我是一级间接关闭。非常有帮助,非常感谢这个解释,我肯定是在完全理解的路上,有一件事我仍然不明白你说的调用[eax]意味着调用指向位置[eax]的子例程,但是你说的是什么子例程,它从何而来[]寄存器周围有什么特别的意思?@SeanSogMiller,括号表示里面是所需的地址。在这种情况下,
eax
的值取决于进入代码的
ebx
的值。这些信息没有说明,所以我们不知道是什么子程序。我们只知道它的地址在
eax
中给出的位置。