我有以下代码:
0000000000400526 <main>:
400526: 55 push rbp
400527: 48 89 e5 mov rbp,rsp
40052a: 48 83 ec 20 sub rsp,0x20
40052e: 89 7d ec mov DWORD PTR [rbp-0x14],edi
400531: 48 89 75 e0 mov QWORD PTR [rbp-0x20],rsi
400535: c7 45 f4 4d 3c 2b 1a mov DWORD PTR [rbp-0xc],0x1a2b3c4d
40053c: 48 8d 45 f4 lea rax,[rbp-0xc]
400540: 48 89 45 f8 mov QWORD PTR [rbp-0x8],rax
400544: c7 45 f0 00 00 00 00 mov DWORD PTR [rbp-0x10],0x0
40054b: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
40054f: 0f b6 00 movzx eax,BYTE PTR [rax]
400552: 0f be c0 movsx eax,al
400555: c1 e0 18 shl eax,0x18
400558: 89 c2 mov edx,eax
40055a: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
40055e: 48 83 c0 01 add rax,0x1
400562: 0f b6 00 movzx eax,BYTE PTR [rax]
400565: 0f be c0 movsx eax,al
400568: c1 e0 10 shl eax,0x10
40056b: 09 c2 or edx,eax
40056d: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
400571: 48 83 c0 02 add rax,0x2
400575: 0f b6 00 movzx eax,BYTE PTR [rax]
400578: 0f be c0 movsx eax,al
40057b: c1 e0 08 shl eax,0x8
40057e: 09 c2 or edx,eax
400580: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
400584: 48 83 c0 03 add rax,0x3
400588: 0f b6 00 movzx eax,BYTE PTR [rax]
40058b: 0f be c0 movsx eax,al
40058e: 09 d0 or eax,edx
400590: 89 45 f0 mov DWORD PTR [rbp-0x10],eax
400593: 8b 55 f0 mov edx,DWORD PTR [rbp-0x10]
400596: 8b 45 f4 mov eax,DWORD PTR [rbp-0xc]
400599: 89 c6 mov esi,eax
40059b: bf 44 06 40 00 mov edi,0x400644 ; "a = %#x\nb = %#x\n"
4005a0: b8 00 00 00 00 mov eax,0x0
4005a5: e8 56 fe ff ff call 400400 <printf@plt>
4005aa: b8 00 00 00 00 mov eax,0x0
4005af: c9 leave
4005b0: c3 ret
4005b1: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0]
4005b8: 00 00 00
4005bb: 0f 1f 44 00 00 nop DWORD PTR [rax+rax*1+0x0]
这是一段x64汇编代码,我想把这段代码改写成C。我看了一天的汇编书籍,还是有些困难。我只是想了解这段代码在做什么。从乱来,我认为它对 int (这就是为什么我认为 DWORD 在那里)和 long (这就是 QWORD 在那里的原因)执行一些操作。我认为这是真的,因为我用这些数据结构重新编译了 C 代码,并且这些词出现在等价的 Assembly 中,但我可能是错的。
任何帮助解码此代码表示赞赏。
对于 Amigag:第二段代码
0000000000400966 <my_tolower>:
400966: 55 push rbp
400967: 48 89 e5 mov rbp,rsp
40096a: 48 89 7d f8 mov QWORD PTR [rbp-0x8],rdi
40096e: eb 2d jmp 40099d <my_tolower+0x37>
400970: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
400974: 0f b6 00 movzx eax,BYTE PTR [rax]
400977: 3c 40 cmp al,0x40
400979: 7e 1d jle 400998 <my_tolower+0x32>
40097b: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
40097f: 0f b6 00 movzx eax,BYTE PTR [rax]
400982: 3c 5a cmp al,0x5a
400984: 7f 12 jg 400998 <my_tolower+0x32>
400986: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
40098a: 0f b6 00 movzx eax,BYTE PTR [rax]
40098d: 83 c0 20 add eax,0x20
400990: 89 c2 mov edx,eax
400992: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
400996: 88 10 mov BYTE PTR [rax],dl
400998: 48 83 45 f8 01 add QWORD PTR [rbp-0x8],0x1
40099d: 48 8b 45 f8 mov rax,QWORD PTR [rbp-0x8]
4009a1: 0f b6 00 movzx eax,BYTE PTR [rax]
4009a4: 84 c0 test al,al
4009a6: 75 c8 jne 400970 <my_tolower+0xa>
4009a8: 90 nop
4009a9: 5d pop rbp
4009aa: c3 ret
4009ab: 0f 1f 44 00 00 nop DWORD PTR [rax+rax*1+0x0]
