Assembly 这些装配线意味着什么?

Assembly 这些装配线意味着什么?,assembly,x86,x86-64,Assembly,X86,X86 64,我正在努力做作业,因为我不明白这些行的意思是什么 mov rax, qword ptr [rbp - 0x28] mov rax, qword ptr [rax] mov eax, dword ptr [rax] mov dword ptr [rbp - 0x10], eax mov rax, qword ptr [rbp - 0x28] mov rax, qword ptr [rax] mov rax, qword ptr [rax + 8] mov qword ptr [rbp - 8],

我正在努力做作业,因为我不明白这些行的意思是什么

mov rax, qword ptr [rbp - 0x28]
mov rax, qword ptr [rax]
mov eax, dword ptr [rax]
mov dword ptr [rbp - 0x10], eax
mov rax, qword ptr [rbp - 0x28]
mov rax, qword ptr [rax]
mov rax, qword ptr [rax + 8]
mov qword ptr [rbp - 8], rax
据我所知,这些行只是将rbp-0x28中的内容复制到rbp-0x10中。然后它接受rbp-0x20中的任何内容,因为rax+8=rbp-0x28+8=rbp-0x20并将其放入rbp-8中

稍后我们有以下几行:

mov rax, dword ptr [rbp - 8]
mov eax, dword ptr [rax]
mov dword ptr [rbp - 0x10], eax
mov rax, qword ptr [rbp - 8]
mov rax, qword ptr [rax + 8]
mov qword ptr [rbp - 8], rax
我相信它会将rbp-8中的任何内容转换成rbp-0x10,然后再转换成rbp中的任何内容,因为rax+8=rbp-8+8=rbp,然后将其转换成rbp-8,但在我看来确实是错误的

有人能给我解释一下这些代码行吗,这样我就可以改进了

事先非常感谢,
祝您愉快

您共享的代码很可能与访问和复制对象属性/变量有关:

mov rax, qword ptr [rbp - 0x28]    ; gets the QWORD pointer of the object from the local variable at RBP-40 (which is the 64-bit address of the object)
mov rax, qword ptr [rax]           ; dereferences the QWORD pointer to set RAX to point to the beginning of the object
mov eax, dword ptr [rax]           ; retrieves the value of the first DWORD of the object (often this is the pointer to the DESTRUCTOR of the object, but in this case this makes no sense)
mov dword ptr [rbp - 0x10], eax    ; copies the DWORD value in EAX to the DWORD variable at RBP-16
mov rax, qword ptr [rbp - 0x28]    ; again, same object as above
mov rax, qword ptr [rax]           ; again, dereference
mov rax, qword ptr [rax + 8]       ; retrieve the QWORD value at position +8 (often this is a pointer to a method, this depends on the object structure - but in this case it seems to be the pointer to another object, see below)
mov qword ptr [rbp - 8], rax       ; copies the QWORD value to the local variable at RBP-8
因此,这段代码很可能访问一个对象,并将其两个属性/方法指针复制到相对于当前方法堆栈框架的基点errbp的局部变量

通常,析构函数的地址位于对象的基址,但在这种情况下,只复制一个DWORD,因此可能还有其他情况发生

在第二种情况下,它可能是复制到局部变量的另一个对象的地址。下面的代码很可能会导致这种情况

关于第二个样本:

mov rax, dword ptr [rbp - 8]     ; Get the QWORD variable (the second from the above code)
mov eax, dword ptr [rax]         ; dereference it (see above)
mov dword ptr [rbp - 0x10], eax  ; and copy it to the local variable at RBP-16 (notice that the value from the above code is overwritten!!!)
mov rax, qword ptr [rbp - 8]     ; again, get the object PTR
mov rax, qword ptr [rax + 8]     ; again, dereference it
mov qword ptr [rbp - 8], rax     ; and replace the value of the local variable at RBP-8 (the old object PTR) with the address of the (first?) (QWORD) value/address of the object (also overwritten!!!)

看起来像是未优化的调试模式代码,使用RBP作为帧指针,因此与它的小偏移量是局部变量。其中两个局部变量是指针或指向指针的指针,可能指向一个链表结构,给定加载值的解引用量。你是否忽略了mov-rax,[rax+8]是一个类似于p=p->next的负载,而不仅仅是rax上的数学?括号[…]表示内存访问。所以mov-rax,qword-ptr[rax]解引用一个指针,然后该值作为另一个指针被mov-eax,dword-ptr[rax]解引用