开发者

What does the jg instruction do on classic Intel processors?

开发者_如何学编程

For the code:

cmp $5, %eax
jg 804940f

This compares by doing %eax - $5 and then sets a flag(s) if it's greater, equal, or negative, correct? Then jg will proceed to that address if the flags dictate that %eax is greater than $5?


It does do a subtraction, but it does not keep the result. It then sets the flags accordingly. You are also correct about the second line, if its greater then it jumps, if not then it skips the jump and continues executing whatever is next.

EDIT: In case you are new to assembly, you may also find it helpful to have access to the contents of the flags register. There are a few ways to do this in Intel assembly, if you need the lower 8 bits then you can do lahf which will load them into ah. If you want the entire contents of the register, then you can use pushf and popf. I hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜