Professional Documents
Culture Documents
Coo Oomp
Coo Oomp
Coo Oomp
EC31FB1
Conditional jump
Following are the conditional jump instructions used on signed data used for
arithmetic operations –
JC , JB, JNAE Jump if Carry (Below, Not Above Equal). CF = 1 JNC, JNB, JAE
JNC , JNB, JAE Jump if Not Carry (Not Below, Above Equal). CF = 0 JC, JB, JNAE
ZF = 0
Jump if Greater (>).
JG , JNLE and JNG, JLE
Jump if Not Less or Equal (not <=).
SF = OF
ZF = 1
Jump if Less or Equal (<=).
JLE , JNG or JNLE, JG
Jump if Not Greater (not >).
SF <> OF
CF = 0
Jump if Above (>).
JA , JNBE and JNA, JBE
Jump if Not Below or Equal (not <=).
ZF = 0
CF = 1
Jump if Below or Equal (<=).
JBE , JNA or JNBE, JA
Jump if Not Above (not >).
ZF = 1
JZ Instruction Example:
include 'emu8086.inc'
ORG 100h
MOV AL, 5
CMP AL, 5
JZ label1
PRINT 'AL is not equal to 5.'
JMP exit
label1:
PRINT 'AL is equal to 5.'
exit:
RET
JS Instruction Example:
include 'emu8086.inc'
ORG 100h
MOV AL, 10000000b ; AL = -128
OR AL, 0 ; just set flags.
JS label1
PRINT 'not signed.'
JMP exit
label1:
PRINT 'signed.'
exit:
RET
include 'emu8086.inc'
ORG 100h
MOV AL, 00000111b ; AL = 7
OR AL, 0 ; just set flags.
JPO label1
PRINT 'parity even.'
JMP exit
label1:
PRINT 'parity odd.'
exit:
RET
JPE Instruction Example:
include 'emu8086.inc'
ORG 100h
MOV AL, 00000101b ; AL = 5
OR AL, 0 ; just set flags.
JPE label1
PRINT 'parity odd.'
JMP exit
label1:
PRINT 'parity even.'
exit:
RET
JE instruction Example:
include emu8086.inc
ORG 100h
MOV AL, 25 ; set AL to 25.
MOV BL, 10 ; set BL to 10.
CMP AL, BL ; compare AL - BL.
JE equal ; jump if AL = BL (ZF = 1).
PUTC 'N' ; if it gets here, then AL <> BL,
JMP stop ; so print 'N', and jump to stop.
equal: ; if gets here,
PUTC 'Y' ; then AL = BL, so print 'Y'.
stop:
RET ; gets here no matter what.
END