JA和JG在汇编中的区别 [英] Difference between JA and JG in assembly

查看:349
本文介绍了JA和JG在汇编中的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能告诉我汇编语言中 JUMP IF ABOVEJUMP IF GREATER 之间的区别吗?我什么时候使用它们?他们会给我不同的结果吗?

Can you please tell me the difference between JUMP IF ABOVE AND JUMP IF GREATER in Assembly language? when do i use each of them? do they give me different results?

推荐答案

正如英特尔手册说明, JG 将标志解释为比较有符号,而 JA 将标志解释为比较无符号(当然,如果设置标志的操作不是比较或减法,那可能没有意义).所以是的,它们是不同的.准确地说,

As Intel's manual explains, JG interprets the flags as though the comparison was signed, and JA interprets the flags as though the comparison was unsigned (of course if the operation that set the flags was not a comparison or subtraction, that may not make sense). So yes, they're different. To be precise,

  • ja 如果 CF = 0ZF = 0 则跳转(上面无符号:无进位且不等于)
  • jg 如果 SF = OFZF = 0 则跳转(有符号大于,不包括相等)
  • ja jumps if CF = 0 and ZF = 0 (unsigned Above: no carry and not equal)
  • jg jumps if SF = OF and ZF = 0 (signed Greater, excluding equal)

例如,

cmp eax, edx
ja somewhere ; will go "somewhere" if eax >u edx
             ; where >u is "unsigned greater than"

cmp eax, edx
jg somewhere ; will go "somewhere" if eax >s edx
             ; where >s is "signed greater than"

>u>s 同意最高位为零的值,但最高位设置的值被 > 视为负数.s>u 一样大(当然如果两个操作数都设置了最高位,>u>s 再次同意).

>u and >s agree for values with the top bit zero, but values with the top bit set are treated as negative by >s and as big by >u (of course if both operands have the top bit set, >u and >s agree again).

这篇关于JA和JG在汇编中的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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