The JG/JNLE instructions

Jump if greater (for signed numbers).

Format of the JG/JNLE instructions

InstructionDescription
JG rel8 / JNLE rel8Short jump if greater/not less than or equal (ZF=0 and SF=OF).
JG rel16 / JNLE rel16Near jump if greater/not less than or equal (ZF=0 and SF=OF).

JG (Jump if Greater) and JNLE (Jump if Not Less or Equal) are synonyms. They are used for jumps after comparing signed numbers. The condition for the jump is: (ZF = 0) and (SF = OF). In other words, the jump is performed if the first operand (in CMP) is greater than the second.

Usage example

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

code segment public        ; Start of the code segment
    assume cs:code

    main proc              ; Start of the main procedure
        mov     ax, 6      ; Copy the value 6 into the ax register; AX = 0006
        cmp     ax, 5      ; Compare the value in ax with 5
        jg      Skip_1     ; If ZF=0 and SF=OF, jump to the Skip_1 label

        mov     bx, 2
        imul    bx

    Skip_1:
        mov     ax, 5      ; Copy the value 5 into the ax register; AX = 0005
        cmp     ax, 6      ; Compare the value in ax with 6
        jg      Skip_2     ; If ZF=0 and SF=OF, jump (here the condition is false)

        mov     bx, 2
        imul    bx         ; Perform signed multiplication of ax by bx; AX = 000A

    Skip_2:
        mov     ax, 5      ; Copy the value 5 into the ax register; AX = 0005
        cmp     ax, 5      ; Compare the value in ax with 5
        jg      Skip_3     ; If ZF=0 and SF=OF, jump (here the condition is false, because ZF=1)

        mov     bx, 2
        imul    bx         ; Perform multiplication

    Skip_3:
        mov     ax, 4C00h  ; Copy the process termination function number into ah and the value into al
        int     21h        ; Call the interrupt
    main endp              ; End of the main procedure

code ends                  ; End of the code segment
end main                   ; End of file. The main procedure is the entry point

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Processor status flags

CF
No
PF
No
AF
No
ZF
No
SF
No
TF
No
IF
No
DF
No
OF
No