"Assembly Language" learning notes 5--instruction system and addressing method

Source: Internet
Author: User
Tags processing instruction

1. Assembly Instructions: Assembly instructions, pseudo-directives, macro directives (with semicolons for comments)

1. Assembly instruction: consists of the opcode field and the operation number segment

1. format: opcode operand

2. Operation segment: single-operand instruction, dual-operand instruction, and three-operand instruction. (due to the execution of the address of the operand to indicate, it is also known as an address instruction, two address instruction, three address instructions.) If only opcode, then 0 address instruction)

For a double-operand instruction, the first is the operand (representing the result of the operation), the second is the source operand (representing the source operand), and the two are separated by commas.

That is: opcode purpose operand, source operation number

2. Directive Properties

1. Instruction length: Divided into: Single-byte, double-byte, three-byte, four-byte, multi-byte. Instruction length can affect storage space (proportional), many types of instructions can finish the same task, the use of shorter instructions to effectively compress the storage space that the program occupies.

2. Execution time of the instruction: in CPU clock cycle. The execution speed of the program can be increased by using instructions with less execution time.

2. Instruction system: A collection of code instructions that all computers can execute

8086 instruction is divided into: data transmission instruction, arithmetic operation instruction, logic operation instruction, string processing instruction, control and transfer instruction, processor control instruction

3. How the instruction is addressed

1. Addressing is the way in which an operand or operand address is provided in the instruction, that is, the method of finding the address of the operand.

2. Operand types are divided into data operands and transfer operands.

Depending on the type of operand, the addressing method is divided into the data-related addressing method, and the addressing method associated with the transfer address.

In addition to transfer instructions, circular instructions, subroutine invocation instructions and other related to the transfer address, the other instructions are addressed to the data.

3. Data-related addressing methods: Immediate addressing, register addressing, memory addressing (direct addressing, register indirection, register relative addressing, base address addressing, relative base address addressing).

1. Immediate addressing: An immediate number of addresses (the number of operands to be found is directly written in the instruction, the number of operations called immediate) is called immediate Addressing (fastest)

Note: 1. Immediate addressing can only be used for source operation number Fields

2. The type of the immediate number must be the same as the type of the destination operand

2. Register addressing: Operand in register, specify register name in instruction (register can be 8-bit or 16-bit)

8-bit registers: AH, AL, BH, BL, CH, CL, DH, DL (16-bit high eight-bit, low eight-bit)

16-bit registers: AX, BX, CX, DX, SI, DI, BP, SP

3. Memory addressing: This type of addressing method in the instruction to represent a valid address ea.

For a dual-operand instruction, two operands do not allow memory addressing at the same time, i.e. two operands are storage units.

1. Direct addressing: An EA, called direct addressing, in which the CPU can obtain the operand directly during the fetch instruction phase

1. Form: MOV ax,ds:[2000h]

2. Valid address of the operand the EA is written directly in the instruction, using the value in [] as the offset address of the operand (valid address). The segment address of the operand is the data segment, which is indicated by the DS that the operand itself is stored in the data segment.

3.CPU calculates the physical address based on the EA and segment address DS, the value of the operand fetched in the access memory: the physical address of the operand = (DS) *10h+ea

4. For direct addressing you must prefix DS:, indicate that the unit is in the data segment. Debug a command to enter the instruction is not added, the system defaults to the data segment.

5. Direct addressing is suitable for handling univariate variables. (The name of the variable in the assembly is the address, the variable value is the variable content)

6. Memory Read and write operation:

The 1.MOV instruction enables the CPU to read and write to the memory:

READ: The purpose operand is the register of the CPU, the source operand is the storage unit

Write: The purpose of the operating room is the storage unit, the source operand is the register of the CPU

7. Symbolic Address: Define a name for the storage unit, the name is the address, if the unit is considered a variable, then the name is the variable name

1. If the storage unit name is defined with the pseudo-instruction DB, DW, the default field is the data segment. To define a symbolic address using the equ symbol definition pseudo-action, add DS:

8. Segment Beyond: memory-related addressing mode, the segment address of the operand defaults to the data segment

1.8086 the provisions of data processing can also be stored in other three kinds of segments, if the operand is stored in other segments known as the paragraph beyond. It needs to be indicated in the instruction with paragraph beyond the prefix, that is, the operand is preceded by a segment register name and a colon.

9. In the debug with a command input addressing mode instruction, can not use the symbolic address, to be changed to the specific offset address value, with paragraph beyond the instruction, the segment beyond the prefix needs to be entered separately in one line, do not write in the MOV instructions. Debug also does not recognize pseudo-directives.

2. Register indirect Addressing (the EA is indirectly obtained from the register, it becomes a register indirection)

1. Form: MOV AX,[BX]

2. The EA of the operand in the base register BX, BP or the variable address register Si, Di, the segment address of the operand is in the data segment DS or the stack segment SS.

3. Valid address is indicated by BX, SI, Di, then the corresponding data section. The corresponding stack segment is indicated by BP

1. Physical address of the operand = (DS) *10h+ (BX)/(SI)/(DI)

2. Physical address of the operand = (SS) *10h+ (BP)

4.EA (valid address) can only be BX, BP or variable address si, DI. "such as: MOV AX,[BX]". Operand also lesson available segment beyond prefix

3. Register relative addressing

1. The EA of the operand is the sum of the contents of a base address or a variable address register plus 8-bit or 16-bit displacement

Physical address of the operand = (DS) *10h+ (BX)/(SI)/(DI) + 8-bit (16-bit) displacement

form: mov ax,value+[si] or mov ax,[value+si]

Where value is the amount of displacement

2. This method is commonly used for table-checking operations: Using registers to do the first address, using the displacement of the pointer to find a specific unit in the table. or use the displacement of the first address of the table, register to do the pointer, to continuously check the table.

4. Base Address Address Change address

1. The EA of the operand is the sum of the contents of a base register and a variable address register.

Physical address of the operand = (DS) *10h+ (BX) + (DI)/(SI)

Physical address of the operand = (SS) *10h+ (BP) + (DI)/(SI)

2. This method is used for the processing of two-dimensional table

5. Addressing the relative base address variable address

1. The EA for the operand adds a displacement amount to a base register plus a variable address register.

Physical address of the operand = (DS) *10h+ (BX) + (SI)/di+8 bit (16-bit) displacement

Physical address of the operand = (BP) *10h+ (BX) + (SI)/di+8 bit (16-bit) displacement

form: mov ax,[bx+si+value] or mov ax,value[bx][si] or mov ax,[bx+si]. Value value is the amount of displacement

Valid address EA =value + (BX) + (SI) Physical address = (DS) *10h+ea

2. Convenient to find an element in the two-dimensional table, can make value as the first address of the table, BX represents the row, SI for the column

4. Choice of addressing methods

1. Immediate addressing for register, storage unit assignment, and immediate number in the operation instruction as the source operand use

2. Register addressing available in the source operand, also available in the destination operand.

3. Direct addressing for easy access to a storage unit

4. Register indirect addressing and register relative addressing are equivalent to pointers in C. As long as the register value is changed, the same command that accesses the storage unit can access different units.

5. Base address addressing and relative mechanism address addressing for arrays and two-dimensional tables

Assembly Language Learning note 5--instruction system and addressing method

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.