首页 > 解决方案 > 为什么 JB 没有做准确的 CMP

问题描述

在emu8086中,我写了这段代码

include 'emu8086.inc'

org 100h

MOV AX,-1  
CMP AX,0
JB case1 

case2:
    printn 'This line should not be displayed'

case1:
    print 'I want this line'

ret

它应该只打印案例 1,但在这种情况下,输出显示了这两种情况。我究竟做错了什么?

标签: assemblyemu8086

解决方案


JB(Jump if below) 用于类似于JNAE(Jump if Not Above or Equal) 的无符号整数。

因此,如果要与有符号整数(在您的情况下为 -1)进行比较,则必须使用JL(Jump if Less) 或JNGE(Jump if Not Greater or Equal)


推荐阅读