JA和JG在装配上的区别

JA和JG在装配上的区别

本文介绍了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?

推荐答案

作为 Intel 的手册解释, 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在装配上的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 07:03