%al register in C code

守給你的承諾、 提交于 2020-01-17 04:54:05

问题


testb  $1, %al
je     .L3
leal   1(%eax,%eax,2), %eax
jmp    .L4

I am given the above assembly code and asked to translate it to c code.

I know what almost all of it is doing, I just don't know how to to do C code for the %al register.

Here Is the rest of the assembly code if it helps

prob2:
pushl  %ebp
movl   %esp, %ebp
movl   8(%ebp), %eax
cmpl   $1, %eax
je     .L1
.L6:
testb  $1, %al
je     .L3
leal   1(%eax,%eax,2), %eax
jmp    .L4
.L3:
shrl   %eax
.L4:
cmpl   $1, %eax
jne    .L6
.L1:
popl   %ebp
ret

回答1:


Doesn't matter here. Bit0 in AL is the same as Bit0 in EAX. The 8-bit operation was surely an optimization of the compiler. So you can read AL as EAX.



来源:https://stackoverflow.com/questions/33504262/al-register-in-c-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!