It is essential to save the registers and flags used by any procedure or interrupt and restore them after the procedure or interrupt has finished its work. Use push and pushf to save. Use pop and popf to restore values.
Assembler
|
Machine Code
|
Explanation
|
CALL 30
|
CA 30
|
Call the procedure at address 30.
The return address is pushed onto the stack and the Instruction Pointer (IP) is set to 30.
CA is the machine instruction for CALL.
30 is the address of the start of the procedure being called.
|
RET
|
CB
|
Return from the procedure.
Set the Instruction Pointer (IP) to the return address popped off the stack.
CB is the machine instruction for Return.
|
INT 03
|
CC 03
|
The Instruction Pointer (IP) is set to the address of the interrupt vector retrieved from RAM address 03.
The return address is pushed onto the stack.
CC is the machine instruction for INT.
03 is the address of the interrupt vector used by the INT command.
|
IRET
|
CD
|
Return from the interrupt.
Set the Instruction Pointer (IP) to the return address popped off the stack.
CD is the machine instruction for IRET.
|