Pseudo-operation in assembly

Source: Internet
Author: User
Tags format define definition comments expression connect

Assembly Language Program statements can be composed of pseudo operation and macro instruction in addition to instructions. Pseudo-operations are also called pseudo directives, which are not executed by the computer as machine instructions are performed during the program's operation, which are handled by the assembler during the assembler's compilation of the source program, which can be accomplished as data definition, allocation storage area, Indicates functions such as end of program.
Data definition and memory allocation pseudo operation
The format of this type of pseudo operation is:
[Variable] Mnemonic Operand,..., operand[; Comments]
where the variable (Variable) field is optional, it is represented by a symbolic address that is the same as the label before the instruction statement, but is not followed by a colon. If a variable is in the statement, the assembler makes it the offset address of the first byte.
The annotation (Comments) field is used to illustrate the functionality of the pseudo operation and is optional.
The mnemonics (mnemonic) field describes the mnemonics used in the pseudo operation, which are commonly used in the following ways:
The DB pseudo operation is used to define the byte, and each operand thereafter occupies a byte.
The DW pseudo operation is used to define the word, and each operand thereafter occupies a word (the low byte is in the first byte address, and the high byte is in the second byte address).
The DD pseudo operation is used to define two words, and each operand thereafter occupies two words.
The DQ pseudo operation is used to define four words, and each subsequent operation takes four words.
A DT pseudo operation is used to define 10 bytes (five words), and each operand thereafter occupies 10 bytes, forming a compressed BCD code.
Action numeric segments can also use the copy operator (duplication opreator) to copy an operand, as in the following example:
ARRAY1 DB 2 DUP (0,1,2,?)
Note 1: You can specify the type attribute of the operand by using the PTR property operator.
Cases:
MOV Ax,word PTR OPER1
Note 2: Use the label pseudo operation to make the same variable have different type attributes.
Cases:
Byte_array LABEL BYTE
Word_array DW DUP (?)

Ii. expression Assignment pseudo-operation Equ
Format: variable name EQU expression
Cases:
CONST EQU 256 number assigned to symbol name
The DATA EQU height+12 address expression is assigned a symbol name
ALPHA EQU 7
BETA EQU ALPHA-2
b EQU [bp+8] variable address reference to symbol name B
P8 EQU Ds:[bp+8]
Another similar to equ = pseudo operation can also be used as an assignment operation. The difference is that the expression name in the equ pseudo operation is not allowed to be defined repeatedly, while the = pseudo operation allows duplicate definitions.
Cases:
Emp=7
Emp=emp+1

Three, segment definition pseudo action
The physical address of the memory is a combination of segment address and offset address, when the assembler converts the source program into the target program, it must determine the offset address of the label and variable, and transmit the relevant information to the connecting program through the target module, This allows the connector to connect different segments and modules together to form an executable program. To do this, you need to define a pseudo operation with a segment that defines a pseudo operation in the following format:
Segment_name segment
...
Segment_name ENDS
The Shing part, for the data section, the additional segment and the stack segment, is generally the memory unit definition, the allocation and so on pseudo operation, for the code snippet is the instruction and the pseudo operation.
In addition, the relationship between segment and segment storage must be clarified, which can be implemented using assume pseudo operations, in the form of:
Assume Assignment,...,assignment
Where assignment describes the allocation, in the form of:
Segment_register_name:segment_name
The segment register name must be one of CS, DS, ES, and SS, and the segment name must be the segment name in the segment defined by segment. Assume nothing then cancels the segment registers previously specified by the assume.
Since the assume pseudo operation simply specifies which segment register a segment is assigned to, it does not load the segment address into the segment register, so in the code snippet, you must also load the segment address into the corresponding segment register. However, the code snippet does not need to do this, and the operation of the code snippet is done when the program is initialized.
The segment pseudo operation can also increase the description of the type and the attributes, in the following format:
Segname SEGMENT [Align_type]
[Combine_type]
[' class ']
...
Segname ENDS
In general, these instructions may not be used. However, these instructions are required if you need to connect this program to other program modules by using a connection program. The following are described separately:
. The location type (Align_type) can be:
PARA specifies that the starting address of the segment must start at a small boundary, that is, the lowest 16 decimal digits of the segment address must be 0.
BYTE This paragraph can start at any address
Word must start at the boundary of the word, where the segment address must be even
Page This must start at the edge of the page, where the minimum two 16 digits of the segment address must be 0 (the address can be divisible by 256)
. The combination type (Combine_type) can be:
Public the segment connects with other segments that have the same name. The connection order is specified by the connection command.
COMMON This segment has the same starting address as other segments of the same name when connected, resulting in an overlay. The common connection length is the maximum length in each segment.
At expression the starting address of the segment is the 16-bit address computed by the expression. But it cannot be used to specify code snippets.
stack specifies that the segment is part of the stack segment at run time.
MEMORY Specifies that this will be assigned to the front of all other connected segments (on high addresses), and if there are several segments of the specified MEMORY when the connection is connected, the first segment that is encountered is the MEMORY segment and the other segment as the common segment.
. Category (' class ') the name used to compose the group of segments when connected.

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.