问题
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