The instructions that can modify IP or cs:ip are called transfer instructions.
Only modify IP, called intra-segment transfer such as JMP Ax, is divided into short transfers and near transitions based on the range of IP modifications, ranging from 128 to 127 and 32768 to 32767, respectively
Simultaneous modification of CS and IP instructions is called inter-segment transfer, such as JMP 1000:0
9.1 Offset
The offset designator, used to take the label of the offsets address, such as MOV ax,offset start equivalent to MOV ax,0 start for the code segment designator
9.2 JMP Instructions
JMP is an unconditional transfer instruction that can modify IP or Cs:ip to modify
The JMP directive gives one of the following two types of information:
(1) Transfer Destination Address
(2) Transfer displacement
9.3 Transfer According to displacement
The JMP short designator represents a shorter transition within a segment, with a 8 byte length representing the amount of displacement, so it can be expressed as a range: Forward 128 bytes to backward 127 bytes
i.e. ip=ip+8 bit displacement, 8-bit displacement = label offset address-The offset address of the next instruction in JMP
JMP near PTR designator indicates proximal transfer in the segment, ip=ip+16 bit displacement
Both of these transfers give the target address after the compiler compiles, but the machine code gives the displacement address
9.4 Destination address of the transfer in the instruction
JMP far PTR designator, to achieve inter-segment transfer is also called remote transfer, the segment address of the label and the offset address into the CS:IP
This transfer compiler gives the destination address after compiling, and the machine code also specifies the destination address of the transfer
9.5 Transfer addresses in JMP
JMP 16-bit Reg
IP = 16-bit reg value
9.6 Transfer address in memory
JMP Word ptr memory address: The value of the unit of memory as the IP
JMP DWORD PTR memory Unit address: The first word cell at the memory cell as the IP value, the second word unit as the CS value
Detection Point 9.1
(1) The procedure is as follows:
Assume Cs:code
Data segment
?
Data ends
Code segment
Start
MOV Ax,data
MOV Ds,ax
MOV bx,0
JMP word ptr [bx+1]
Code ends
End Start
What should I do in data to make JMP Cs:ip point to the first instruction after it executes?
Analysis: JMP word ptr [1] is to put 1 address word cell value into the IP, that is, let Cs:ip point to cs:0, so let 1 address Word cell value 0
So the data should be DB 0,0,0.
(2) The procedure is as follows
Assume Cs:code
Data segment
DD 12345678H
Data ends
Code segment
Start
MOV Ax,data
MOV Ds,ax
MOV bx,0
mov [BX],
mov [bx+2],
JMP DWORD ptr ds:[0]
Code ends
End Start
The completion program makes JMP execute after Cs:ip points to the first instruction of the program
Analysis: JMP DWORD ptr ds:[0] means to put 0 address word cells into the IP2 address word cell into CS
So let 0 address word cell into 0, 2 address word cell into CS,
So: mov [BX],BX can not be used here with MOV [bx],0 because of the need to determine the instruction data length
mov [Bx+2],cs
(3) Using debug to view the memory, the results are as follows:
2000:1000 be 00 06 00 00 00 .....
At this point, the CPU executes the instruction
MOV ax,2000h
MOV Es,ax
JMP DWORD ptr es:[1000h]
Post CS = 0006H, IP = 00BEH
9.7
Assembly Language: Nineth Chapter principle of transfer instruction