Symbol, label and variable symbol of assembly language

Source: Internet
Author: User
Tags definition variables

A prominent advantage of computer assembly language is the use of symbols (symbol) to replace the target code, that is, a large number of binary code symbols to express, so that the assembly language source program easy to understand, easy to remember.

In the Macro assembly language, all variable names, label names, record names, instruction mnemonics, and register names are collectively referred to as symbols. These symbols can be renamed by assembling the pseudo operation commands of the control statement, or by giving it an instruction to define other names and new type attributes. So it brings great flexibility to program design. Symbols are identifiers defined by programmers in programs that represent a storage unit, data, expression, and name, and can be divided into registers, labels, variables, numbers, and names.

Assembly Statement form:

Start:add Ax,buffer

Data segment

Buffer db 01H, 02H

Data ends

JMP start where start,buffer,data are all symbols, they represent labels, variable names, segment names, and they have completely different specific meanings.

Label

A label is a name for a set of machine instructions. Label is optional, only if you need to use the symbolic address to access the statement, to give this statement to the label. Marking is the target of the program, always associated with an address, for transfer or circular instruction control transfer use.

2 1 attributes of the label

Because the label represents the instruction address, it has three attributes, the segment attribute, the Offset property, and the Type property. Segment property is the segment address, and the label segment must be in CS. The offset property is the distance from the label to the first address of the segment, in bytes, and is a 16-bit unsigned integer. The type attribute is a distance attribute, The distance between the indicator number and the transfer instruction, the marking is quoted in this paragraph, the distance is called short marking between -128~+127, the distance attribute is shorter, when the marking is in this paragraph, the distance between -32768~+32767 is called near marking, the distance attribute is neat, When the instruction and marking of the reference label are not called far in the same paragraph, the distance attribute is far.

2 definition of the 2 label
There are three different ways to define a label:

2 2 1 implies that the label distance attribute is short and near. You can use an implied description, which is defined in the code snippet, followed by a colon, and placed in front of a assembler instruction operator. Example:

Next:mov AX,BX

----------

Loop Next

--------

NEXT1:CMP AX,BX

JA NEXT1

Where next and NEXT1 are the label names.

2 2 2 define labels with label

This definition can be used for labels with attributes of near and far. The format is:

Label name Label Near/far

For example: Next label Near/far

--------

Loop Next

2 2 3 define labels with equ

The label for near and far can also be equ defined. The format is:

Label name Equ this Neat/far

For example:

Next equ this near

--------

Loop Next

2 use of the 3 label

2 3 1 Unconditional transfer instruction in the label as the transfer address

Format:

JMP Marking

of which the marking can be short marking, near marking or far marking

. 2 3 2 Cyclic instructions, the label as the transfer address

Format: Loop label

Where the label can only be a short label

2 3 3 Condition Transfer label as transfer address

Format:

Conditional Transfer Instruction Label

Where the label can only be used for short marking

2 3 4 Property Separator

2.3. 4.1 Take segment address operator SEG

Example: mov ax,seg next
SEG Next is the segment address of the paragraph where the label next is taken.

2 3 4 2 take offset operator

For example: MOV bx, offset NEX

Where offset next is the valid address of the label next, which is equivalent to: Lea BX, next

2 3 4 3 Take type operator types

For example:

mov ax, type next

If Next is near-numbered, the type next value is FFFFh (-1), and if Next is a far-numbered type next value of Fffeh (-2). of which-1 and-2 have no real physical meaning, only the label type is represented numerically.

Variable

A variable (variable) represents data stored in certain storage units, these data can be modified at any time while the program is running. Variables are referenced in the program by the variable name, which is actually the name of a data area in the store, and is used by the programmer as the variable name data, as an instruction or pseudo. Operands of an instruction , greatly facilitates the program designer.

Because variables are defined in logical segments. This determines that variables and labels have the same segment attributes, offset attributes, and type attributes, and the first two and label properties are the same, while the type attribute is the byte (byte), Word (word), or number (DWORD) of the data item that indicates the data area. And so on. The main difference between the visible variable and the label is that the variable refers to the data, and the label corresponds to the instruction

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.