%人在C code寄存器 [英] %al register in C code

查看:109
本文介绍了%人在C code寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  TESTB $ 1%人
JE .L3
莱亚尔1(%eax中,EAX%,2),%eax中
JMP .L4

我给上面的装配code,并要求将其翻译为C code。

我知道几乎所有的它是干什么的,我只是不知道该怎么办C code代表%人注册。

下面,大会code的其余部分,如果有帮助

  prob2:
pushl%EBP
MOVL%ESP,EBP%
MOVL 8(EBP%),%EAX
CMPL $ 1,%eax中
JE .L1
.L6:
TESTB $ 1,%人
JE .L3
莱亚尔1(%eax中,EAX%,2),%eax中
JMP .L4
.L3:
SHRL%EAX
.L4:
CMPL $ 1,%eax中
JNE .L6
.L1:
popl%EBP
RET


解决方案

此处无关紧要。在位0 AL 是相同的位0在 EAX 。的8位操作是可靠编译器的优化。所以,你可以阅读 AL EAX

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

解决方案

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.

这篇关于%人在C code寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆