The JZ instruction
The JZ instruction is used to transfer program control to the specified memory address if Z=1 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 JZ instruction format
| Instruction | Description |
|---|---|
| JZ addr16 | Performs a jump to an address or label if the Z flag is 1. |
Usage example
; Author: Evgeny Sergeevich Dovgopolov main: mvi a, 02h ; Load the hexadecimal value 02h into register A cpi 03h ; Compare the accumulator with 03h jz Equal ; If Z=1, jump to the label Equal adi 03h ; Add 03h to the value in register A hlt ; Stop program execution Equal: adi 02h ; Add 02h to the value in register A hlt ; Stop program execution
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Processor status flags
S
NoZ
NoAC
NoP
NoCY
No