我想將彙編代碼轉換回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 –