Subroutine calls and return commands
1. Call call DST;
During the call, the IP or EIP pressure stack pushes the current value (the address of the next instruction of the Call Command) executed by the machine into the stack for the subroutine to return for use.
2. return ret
IP output stack upon return
Returned command ret n with Parameters
N is a 16-bit constant (even number). This command is to insert the return address into the IP or eip and then execute SP/ESP + n --> SP/ESP.
This command allows the returned address to change the pointer of the stack after the stack is output, which facilitates the sub-program to import the parameters required by the sub-program into the stack before calling the sub-program,
So that these parameters can be used when the subroutine is running. When the subroutine returns, these parameters are no longer used, you can modify the pointer to point to the parameter into the stack.
Previous value.
Interrupt command
An Interrupted service program can be considered as a special subroutine and can be stored anywhere in the primary storage. The first (START and entry) Address of the interrupt service program, which is arranged in the interrupt vector table.
The interrupt vector table is set to be in the primary memory at a minimum of 1 kb. The physical address ranges from 000 h ~ 3ffh. The vector table starts from 0. Each 4 bytes (double-byte) corresponds to an interrupt. Low-word Storage refers to the offset IP address of the interrupt service program, and high-word Storage refers to its segment address CS. The interrupt service program with the interrupt vector number N is stored in the physical address of the interrupt vector table 4×n.
During interruption, to ensure that the interrupted service program returns the original program correctly, the logical address Cs: IP address at the breakpoint of the interrupted program should be pushed to the stack for storage, you also need to save the flags that reflect the on-site status. Then, the entry address of the interrupt service program is sent to CS and IP register to execute the interrupt service program.
When the interrupted service program returns to the original program after execution, the breakpoint address Cs: IP address stored in the stack and the mark register should be restored. The iret of the interrupt return command is used to return the original program from the interrupt service program.
1. Int N; the interrupt type is N.
2. Into; overflow interrupt command
3. iret; content related to the interrupt return command should be output to the stack
Int 21 h; system function call command
By using int 21 h; then calling the function number specified in advance for each function, you can enter the corresponding interrupt service program entry.
How can I use the 21st interruption?
A: place the function call number in register ah, set the entry parameter, run int 21 H on the CPU, and finally provide the exit parameter.
Example:
MoV ah, 1; function No. 01 H-> ah
Int 21 h; call 21h Soft Interrupt
Function: Wait for keyboard input and send the display back.
MoV DL, 41 h; send the ASCII code of character a to-> DL
MoV ah, 2; 21h 2 Soft Interrupt, display DL content to the screen
Int 21 h
MoV ah, 4ch;
Int 21 h; function no. 4ch terminates the program and returns DoS