Assembly Language Command System

Source: Internet
Author: User

1. mov has been introduced in the previous article

2. the push and pop commands must be used to determine the storage unit of the stack into or out of the stack based on the content of the current SP, And the pointer must be modified in time to ensure that (SP) points to the top of the current stack.
(1) stack access must be in the unit of words (the byte stack is not allowed in ibm pc), so the push and pop commands can only be used for word operations.
(2) They can use addressing methods other than the initial immediate number.
(3) The instruction can also specify the segment register as the operand. Note that the POP definitely cannot use the segment register (CS.
(4) The two commands do not affect the flag space.

Use the stack for on-site protection:
Push BX
. Other programs to be executed
Pop BX
Pop ax
Pay attention to the order in and out of the stack.

Xchg switch command
Format: xchg oprolactin, opr2
Perform the operation: (oprolactin) <1> (opr2) Where OPR represents the operand. One of the two operands of this instruction must be in a register. Therefore, it can be between registers. Information is exchanged between registers and memory. Note that segment registers cannot be used. The command allows word and byte operations without affecting the flag.

4. Dedicated transfer commands of the Accumulators
In (input) Input
Out (output) Output
Xlat (translate) for code
This set of commands is limited to transmitting information using the accumulators ax and Al.

(1) All the communication between the I/O port and the CPU is completed by the in and out commands. In, information is transmitted from I/O to CPU, while out information is transmitted from CPU to I/O.
(2) The CPU only receives or sends information with the accumulators (ax or Al). A maximum of 64 K external ports can be provided, and the port number is 0000 h-ffffffh.
(3) long format: For the first 256 ports, you can directly specify them in the command. This is the port in the common format ).
(4) short format: when the port number is greater than or equal to 256, you must first put the port number in the DX register, and then use in or out for information transmission.
(5) note that when in/out is used for information transmission, all the port numbers (or DX content) are addresses, and all the transmitted are the content of the port number.
The input and output commands do not affect the flag spaces.
Example in ax, 28 h
MoV data_word, ax
These two commands transmit the content of the local port 28 to the storage unit data_word through ax.
Example mov dx, 3fch
In ax, DX
Send a word from Port 03fch to the ax register.
Example 5, Al
Output A byte from the Al register to Port 5

5. xlat code change command
Format:; xlat OPR
Or xlat
Operation: (Al) <1 (BX) 10 (Al ))
Function: converts one type of code to another type of code.
Before using this command, you should create a byte table. The first address of the table is saved to the Bx register in advance, the code to be converted should be stored in the Al register in advance relative to the displacement of the table's first address. The table content is the code to be converted, after the command is executed, the converted code can be obtained in Al.
This command can use either xlat or xlat opr. When xlat OPR is used, OPR is the first address of the table (generally the symbolic address ), however, the OPR here is only set to improve the readability of the program. During command execution, only the first address of the table already saved in BX is used, and the value specified in Assembly format is not used. This command is not shadow.
For example, (BX) = 0040 h, (Al) = 0fh, (DS) = f000h
Command xlat
Send the content of f0000h + 0040 H + 0fh to Al, so after the command is executed: (Al) = 2ch
That is, the command converts the code 0fh in Al to 2ch.
Note that because Al is an 8-bit binary, the maximum table length cannot exceed 256.

6. Address Transfer command
Lea valid address sending register
LDS pointer sending register and DS
Les pointer to send registers and ES
This group of commands completes the function of sending the address to the specified register.
1. Send register with Lea valid address
Format: Lea Reg, SRC
Execution Process: (REG) <-Src
Function completed: the Command sends the valid address to the specified register.
2. LDS pointer to send registers and DS
Format: lDs Reg, SRC
Operation: (REG) <1 (SRC)
(DS) <-(SRC 10 2)
Send the four successive bytes specified by the source operand to the registers and DS registers specified by the instruction. This command is usually used to specify Si registers.
3. Les pointer to send registers and ES
Format: Les Reg, SRC
Operation: (REG) <1 (SRC)
(ES) <-(SRC 10 2)
Send the four successive bytes specified by the source operand to the registers and ES registers specified by the instruction. This command is usually used to specify the di register.
Note: The preceding three commands cannot specify block registers. The command operation does not affect the flag bit.
This group of commands sends the variable's offset address (LEA), segment address, and offset address (LDS and LES) to the Register to provide tools for accessing the variable.
Example: Lea BX, [BX 10 Si 10 0f62h]
For example, before the command is executed (BX) = 0400 h, (SI) = 003ch
After the command is executed (BX) = 0400 ten 003c ten 0f62 = 139eh
Note that here, the Bx register obtains the offset address rather than the content of the storage unit.
Example: lDs Si, [10 h]
For example, before the command is executed (DS) = c000h, (c0010h) = 0180 h, (c0012 H) = 2000 h
After the command is executed (S1) = 0180 h, (DS) = 2000 h
For example, les Di, [BX]
For example, before the command is executed (DS) = b000h, (BX) = 080ah, (0b080ah) = 05aeh, (0b080ch) = 4000 H
After the command is executed (D1) = 05aeh, (ES) = 4000 H

7. Flag register transfer command
The low byte of the lahf mark register is sent to ah
Low byte of the sahf Ah flag register
Pushf flag into Stack
Popf marks the output Stack
1. The lahf flag sends the ah command
Format: lahf
Operation: (AH) <-(low byte of the psw register)
2. sahf Ah flag register instruction
Format: sahf
Operation performed: (low-byte psw) 1> (Ah)
3. pushf Mark into the stack command
Format: pushf
Operation: (SP) <-(SP)-2
(SP) + 1, (SP) <-(psw)
4. popf marks the output Stack
Format: popf
Execution Process: (psw) <-- (SP) 10 1, (SP ))
(SP) <1 (SP) 10 2
The lahf and pushf commands in this group do not affect the flag. The value of the Flag position is determined by the loaded value of the sahf phase popf.

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: 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.