汇编语言:ja 和 jg 之间的区别?
我无法理解汇编语言的 ja 和 jg 之间的区别。我有一段代码:
cmp dh, dl
j-- hit
我询问哪个条件跳转将采用 DX = 0680 的十六进制值进行命中(替换 j-- hit)。
这将使 dl = 06 和 dh = 80,因此在比较时, 80> 06.我知道 jg 适合这个,因为我们可以直接比较结果,但是如果 ja 适合(或者在这种情况下,不适合)这段代码,我应该如何解决?
I am having trouble understanding the difference between ja and jg for assembly language. I have a section of code:
cmp dh, dl
j-- hit
and am asked which conditional jump to hit (that replaces j-- hit) will be taken with the hex value of DX = 0680.
This would make dl = 06 and dh = 80, so when comparing, 80 > 06. I know that jg fits this as we can directly compare results, but how should I approach solving if ja fits (or in this case, does not fit) this code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jg
,因为 6 > -128,但6< 128.jg
进行有符号比较;ja
进行无符号比较。dx
is 0x0680, thendh
is 0x06 anddl
is 0x80.jg
, since 6 > -128, but 6 < 128.jg
does signed comparison;ja
does unsigned comparison.ja
和jg
之间的区别在于,ja
的比较是无符号的,而jg
的比较是有符号的(将寄存器为有符号整数与无符号整数)。如果数字保证为正(即符号位为 0),那么应该没问题。否则你必须小心。
如果
ja
适用,您确实无法根据比较指令本身进行直觉判断。您必须查看上下文并确定符号是否会成为问题。The difference between
ja
andjg
is the fact that comparison is unsigned forja
and signed forjg
(treating the registers as signed vs unsigned integers).If the numbers are guaranteed to be positive (i.e. the sign bit is 0) then you should be fine. Otherwise you have to be careful.
You really can't intuit based on the comparison instruction itself if
ja
is applicable. You have to look at the context and decide if sign will be an issue.