问题描述
你能告诉我汇编语言中JUMP IF ABOVE 和JUMP 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 = 0
和ZF = 0
则跳转(无符号以上:无进位且不相等)jg
如果SF = OF
和ZF = 0
跳转(有符号大,不包括相等)
ja
jumps ifCF = 0
andZF = 0
(unsigned Above: no carry and not equal)jg
jumps ifSF = OF
andZF = 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在装配上的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!