我想将汇编代码转换回C代码,但我注意到这一个操作称为sarq。我认为q是地址的大小,但我不知道sarq对地址做了什么。我评论了我相信代码的作用。汇编语言 - sarq在代码中做了什么?
.LC0 .string "ans %d\n"
main:
.LFB0: val = -8(%rbp), result = -12(%rbp)
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movabsq $53162464113523643, %rax
movq %rax, -8(%rbp) //val(variable) address -8,inputs value in %rax
movl $0, -12(%rbp) //result(variable) address -12, inputs 0
jmp .L2 //starts loop
.L3:
movq -8(%rbp), %rax //moves value in val into rax
andl $1, %eax //dunno what eax is but adds 1 into it
xorl %eax, -12(%rbp) //compares the value of eax and result to see if they are not equal. so compares 1 to 0
sarq -8(%rbp) //does something to val?
.L2:
cmpq $0, -8(%rbp) //compares val to 0
jg .L3 //if greater, goes to L3
movl -12(%rbp), %eax //else, moves value from result into eax
movl %eax, %esi //moves eax into esi
movl $.LC0, %edi //Moves w/e $.LC0 is into edi. Based on the top, edi now holds that string?
movl $0, %eax //moves 0 into eax
call printf //print statement
leave
ret
[SAR记录在英特尔的insn set ref手册中](http://www.felixcloutier.com/x86/SAL:SAR:SHL:SHR.html)。另请参阅http://stackoverflow.com/tags/x86/info –