Machine language commands on IBM PC

Source: Internet
Author: User

Machine language commands on an ibm pc are multi-byte commands, which can contain 1-7 bytes. The operation code (expressed by OP) of the command uses binary code to represent the operation performed by the command. On an IBMs machine, it is usually represented by the first byte of the command, sometimes it is not enough to use 8 bits. Therefore, the second byte of the instruction may occupy 3 bits of operation code, and other bytes are used to represent the address code.

In most operation codes, some bits are often used to indicate certain information. For example

----------------------
| Op | d | w |
----------------------

The W-bit indicates whether the command operates on the word (W = 1) or the byte (W = 0.

The D value is valid only in the dual-operand command. The ibpc requires that the two operands of the dual-operand instruction must have one operand in the register. The D-bit specifies whether the register is used for the destination operand (D = 1) or the source operand (D = 0 ).
In addition, when immediate addressing is used, the operation code uses the S bit to represent symbol extension;

----------------------
| Op | S | w |
----------------------

For example, if the number of bytes immediately is 8 bits, but it is required to be expanded to 16 bits (the maximum valid bits of the high bits are extended as symbols), and the S bit is L.
Therefore, when the command is executed in bytes, SW = 00. When the command has 16 digits immediately and is used as a word operation, SW = 01; when the command has eight immediate digits but needs to be expanded to six immediate digits by symbol for the word operation, SW = 11

An addressing byte is used by the ibpc to indicate the addressing method of the operands. Generally, it is the 2nd bytes of the machine instruction. The addressing mode byte can be expressed as follows:

MoD Reg R/m

In this example, Reg indicates the register method. In the case of dual-effect commands, an operation must be performed in the Register, which is specified by the reg field. It is combined with the W phase in the operation code byte to determine the register as shown in the following table.
The MOD field is combined with the R/M (Register/memory) field to determine the addressing mode of another operand.
Reg is composed of 000 ~ The number between 111 to determine if it is bx bp ...... Of

The segment register under each item in the above table refers to the implicit segment register used when no segment spans the prefix. If the specified segment spans the prefix, a byte prior to the instruction is used in the machine language to determine which segment spans.

IBM PCs do not allow cross-segment prefixes in the following three cases;
1. The commands used to access the stack (such as push and call) Use SP as the offset address pointer and can only use ss as the segment odd memory.
2. string processing commands require that the source register use Si. The source string is in the DS segment, and the destination Register uses Di. The destination string must be in the es segment. Here, if you want to use a segment to cross the prefix, it can only be used for the source but not for the purpose. That is to say, Si can replace the segment register, while DI can only use ES as the segment register, segment replacement across prefix is not allowed.
3. commands can only be stored in code segments.
According to the above instructions, we have a general understanding of the machine commands of the idm pc. The following uses the addition commands as an example to analyze the machine commands.

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.