assembly branch instruction

offset

In assembly language, it is a symbol processed by the compiler. Its function is to obtain the offset address of the label.

 s1:
 	mov ax,offset s1  ;相当于mov ax,0
 s2:
 	mov ax,offset s2 ;相当于mov ax,3

 

jmp 

Unconditional branch instruction, can modify CS and IP

Two kinds of information are required, the destination address of the transfer and the distance of the transfer

Shift jmp short label according to displacement

Function: (IP) = (IP) + 8-bit displacement

8-bit displacement = address at label - address of the first byte after the jmp instruction

short indicates that the displacement here is an 8-bit displacement

The range of 8-bit displacement is -128--127 expressed in complement

The 8-bit displacement is calculated by the compiler at compile time

jmp near label, indicating the near transfer within the segment (IP) = (IP) + 16-bit displacement

start:
    mov ax,0
    jmp short s
    add ax,1
s:
    add ax,2

jmp far pter label, which implements inter-segment transfer, also known as far transfer

Function: (CS) = segment address of the segment where the label is located, (IP) = offset address of the label in the segment

far ptr specifies that the instruction modifies CS and IP with the segment address and offset address of the label

 

jmp 16-bit reg

Function: (IP) = (16-bit reg)

 

jmp word ptr memory unit address (intra-segment transfer)

Function: A word is stored from the memory unit address, which is the destination offset address of the transfer

(IP)= (memory unit address)

 

jmp dword ptr memory unit address (transfer between segments)

Function: Two words are stored from the memory unit address, which is the destination offset address of the transfer, the high address is the target segment address, and the low address is the target offset address

(CS) = (memory cell address + 2)

(IP) = (memory cell address)

 

jcxz is a conditional transfer. All conditional transfers are short transfers. The corresponding machine code contains the displacement of the transfer, not the destination address. The modification range of IP is -128~127.

jcxz label

Function: When (CX)==0, transfer to the label for execution, (IP)=(IP)+8-bit displacement

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325086402&siteId=291194637