The JP instruction

The JP instruction is used to transfer program control to the specified memory address if P=1 (positive result) in the flag register. In other words, it allows the program to choose a different execution path based on the result of a previous arithmetic or logical operation.

The JP instruction format

InstructionDescription
JP addr16 Performs a jump to an address or label if the flag has a positive value.

Usage example

; Author: Evgeny Sergeevich Dovgopolov

main:
    mvi     a, 0FFh   ; Load the hexadecimal value FFh into register A
    adi     02h       ; Add 02h to the value in register A
    jp      Positive  ; If P=1, jump to the label Positive

    sui     02h       ; Subtract the value 02h from register A
    hlt               ; Stop program execution

Positive:
    adi     03h       ; Add 03h to the value in register A

    hlt               ; Stop program execution

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

Processor status flags

S
No
Z
No
AC
No
P
No
CY
No