Transfer instruction note (1)

Source: Internet
Author: User

The 8086CPU transfer instruction is divided into the following categories:
1. Unconditional transfer instructions (e.g., JMP)
2. Conditional Transfer Directives
3. Cyclic instructions (e.g. loop)
4. Process
5. Interrupts

One, operator offset
Handled by the compiler, is a pseudo-instruction, the function is to get the offset address of the label

In question 9.1, the data to be copied: the length of the mov ax,bx instruction (machine code) is two bytes, or 1 characters. NOP machine code takes one byte

Second, the JMP directive
Unconditional transfer, can only modify IP, you can also modify CS and IP

The JMP directive gives you two kinds of information:
Destination address of the transfer
Distance transferred (inter-segment transfer, intra-segment short transfer, intra-segment near transfer)
JMP short designator (execution instruction at transfer label)
The implementation is a short transfer in the segment, the IP modification range is -128~127, that is, forward transfer can be up to 128 bytes, backward transfer can be up to 127 bytes
In the machine instruction does not contain the destination address of the transfer, the CPU does not need this destination address can implement the IP modification
In fact, the function of the "JMP short label" is: (IP) = (IP) + 8-bit displacement.
(1) 8-bit displacement = Address of the label at the first byte after the-jmp instruction;
(2) short indicates that the displacement here is 8-bit displacement;
(3) The range of 8-position displacement is -128~127, which is indicated by complement;
(4) The 8-bit displacement has a compiler calculated at compile time.

In the same vein, jmp near PTR designator, which realizes the close transfer of the paragraph, except that it shifts the displacement to 16 bits, the range is -32768~32767, with the complement expression

The above two kinds of direct displacement, the corresponding machine code does not transfer the destination address, but relative to the current IP transfer displacement

Third, jmp far PTR designator, transfer between segments, functions as follows:
(CS) = Segment Address of the segment where the label is located
(IP) = offset address in the segment where the label is located
Far PTR indicates that the instruction uses the segment address and offset address of the designator to modify CS and IP.
The corresponding machine instruction indicates the destination address of the transfer, the high address is the segment address of the transfer, the low address is the offset address

IV, JMP 16 is a register for short or near transfer within a segment
Function: ip= (16 for register)

Five, jmp word PTR memory cell address (intra-segment transfer)
The previous address is either in the Register or a label, translated into Idata, and is now in memory
Function: From the memory unit address from the beginning to store a word, is the purpose of the transfer of the destination offset address (IP is 16 bits, Word is 16 bits, it can not give CS value)
The memory unit address can be given in any format of the addressing method

Six, jmp DWORD ptr memory cell address (inter-segment transfer)
Function: From the memory unit address at the beginning of the two words, the high address of the word is the destination of the transfer of the address, the low address is the purpose of the transfer of the destination offset address.
(CS) = (Memory Unit address +2)
(IP) = (Memory unit address)
Memory unit addresses are given in any format that can be addressed.

Seven, JCXZ directive
The JCXZ instruction is a conditional transfer instruction, and all conditional transfer instructions are short-shifted, including the shifted displacement in the corresponding machine code, not the destination address. The range of modifications to IP is -128~127

Eight, Loop command
Loop command is a circular instruction, all the circular instructions are short transfer, in the corresponding machine code contains the shifted displacement, not the destination address, the IP modification range is -128~127

Nine, the significance of transfer according to displacement
JMP Short Label
JMP near PTR label
JCXZ Marking
Loop label
and other instructions, their modifications to the IP are based on the displacement between the destination address and the transfer start address. The destination address of the transfer is not included in their corresponding machine code. And it contains the displacement distance to the destination address.
This design facilitates the floating assembly of the program segment in memory
Note that, according to the displacement of the instructions, their transfer range is limited by the transfer of displacement, if there is a problem in the source program of the transition range, the compiler will error when compiling

Transfer instruction note (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.