The CALL instruction
In the 8085 microprocessor the CALL and RET instructions play a vital role in subroutine handling, which is a fundamental programming concept for modular and well-organized code.
The CALL instruction is used to transfer program control to a subroutine. Its format is CALL addr, where addr is a 16-bit memory address that specifies the starting position of the subroutine.
The main purpose of the CALL instruction is to let the main program call a subroutine, execute the subroutine code, and then return to the main program at the required point.
The CALL instruction format
| Instruction | Description |
|---|---|
| CALL addr16 | Performs a subroutine call. |
Usage example
; Author: Evgeny Sergeevich Dovgopolov result: db 00h main: mvi b, 05h ; Load the hexadecimal value 05h into register B mvi c, 03h ; Load the hexadecimal value 03h into register C call add8b_v ; Call the add8b_v procedure. The result is in A sta result ; Store the accumulator value in the variable result hlt ; Stop program execution add8b_v: mov a, b ; Copy the value of register B into register A add c ; Add the value of register C to register A ret ; Return from the procedure back to the call site
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Processor status flags
S
NoZ
NoAC
NoP
NoCY
No