An assembly language statement consists of a "symbol", a "mnemonic", "operands", and a "comment".
Separate labels by colons or one or more whitespace characters. Whether colons or spaces are used, however, depends on the instruction coded by the mnemonic.
It is irrelevant whether blanks are inserted in the following location.
One or more blank is necessary in the following location.
One assembly language statement is described on one line. There is a line feed (return) at the end of the statement.
The characters that can be used in a source program (assembly language) supported by the asembler are the following 3 types of characters.
These characters are used to code instructions in the source.
Symbol indicating the start of a control instruction equivalent to an assembler option |
|
References the absolute address of a label and begins a comment (when used at the beginning of a line) |
|
Character data refers to characters used to write character string constant, character constant, and the quote-enclosed operands of some control instructions.
Character data can use all characters (including multibyte kanji, although the encoding depends on the OS). |
Comment characters are used to write comments.
The symbol field is for symbols, which are names given to addresses and data objects. Symbols make programs easier to understand.
Symbols can be classified as shown below, depending on their purpose and how they are defined.
Observe the following conventions when writing symbols.
The characters which can be used in symbols are the alphanumeric characters and special characters (@, _, .). |
The maximum number of characters for a symbol is 4,294,967,294 (=0xFFFFFFFE) (theoretical value). The actual number that can be used depends on the amount of memory, however. |
Reserved words cannot be used as symbols. |
The same symbol cannot be defined more than once. |
When a label is written in a symbol field, the colon ( : ) must appear immediately after the label name. |
CODE01 .cseg ; "CODE01" is a section name. VAR01 .set 0x10 ; "VAR01" is a name. LAB01: .dw 0 ; "LAB01" is a label. |
Write instruction mnemonics, directives, and macro references in the mnemonic field.
If the instruction or directive or macro reference requires an operand or operands, the mnemonic field must be separated from the operand field with one or more blanks or tabs.
mov1, r10 ; There is no blank between the mnemonic and operand fields. mo v 1, r10 ; The mnemonic field contains a blank. MOVE ; This is an instruction that cannot be coded in the mnemonic field. |
In the operand field, write operands (data) for the instructions, directives, or macro references that require them.
Some instructions and directives require no operands, while others require two or more.
When you provide two or more operands, delimit them with a comma ( , ).
The following types of data can appear in the operand field:
Constants (numeric constants, character constants, character string constants) |
See the user's manual of the target device for the format and notational conventions of instruction set operands.
The following sections explain the types of data that can appear in the operand field.
A constant is a fixed value or data item and is also referred to as immediate data.
There are numeric constants, character constants and character string constants.
Integer constants can be written in binary, octal, decimal, or hexadecimal notation.
Integer constants has a width of 32 bits. A negative value is expressed as a 2's complement. If an integer value that exceeds the range of the values that can be expressed by 32 bits is specified, the assembler uses the value of the lower 32 bits of that integer value and continues processing (it does not output any message).
Floating constants consist of the following elements. Specify the exponent and mantissa as decimal constants. Do not use (3), (4), or (5) if an exponent expression cannot be used.
(1) sign of mantissa part ("+" is optional)
(3) 'e' or 'E' indicating the exponent part
(4) sign of exponent part ("+" is optional)
You can indicate that the number is a floating constant by appending "0f" or "0F" to the front of the mantissa.
A character constant consists of a single character enclosed by a pair of single quotation marks (' ') and indicates the value of the enclosed characterNote.
If any of the escape sequences listed below is specified in " ' " and " ' ", the assembler regards the sequence as being a single character.
If a character constant is specified, the assembler assumes that an integer having the value of that character constant is specified. |
If a value exceeding "\377" is sp value of the escape sequence becomes the lower 1 byte. Cannot be of value more than 0377. For example value of"\777"is 0377. |
A character-string constant is expressed by enclosing a string of characters from those shown in "(1) Character set", in a pair of single quotation marks ( " ).
The following registers can be named in the operand field:
r0, zero, r1, r2, hp, r3, sp, r4, gp, r5, tp, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, r30, ep, r31, lp |
r0 and zero (Zero register), r2 and hp (Handler stack pointer), r3 and sp (Stack pointer), r4 and gp (Global pointer), r5 and tp (Text pointer), r30 and ep (Element pointer), r31 and lp (Link pointer) shows the same register.
For the ldsr and stsr instructions, the PSW, and system registers are specified by using the numbers. Further, in assembler, PC cannot be specified as an operand. |
The assembler supports the use of symbols as the constituents of the absolute expressions or relative expressions that can be used to specify the operands of instructions and directives.
An expression is a combination of constants and symbols, by an operator.
Expressions can be specified as instruction operands wherever a numeric value can be specified.
See "5.1.2 Expressions and operators" for more information about expressions.
In this example, "TEN - 0x05" is an expression.
In this expression, a symbol and a numeric value are connected by the - (minus) operator. The value of the expression is 0x0B, so this expression could be rewritten as "mov 0x0B, r10".
Describe comments in the comment field, after a semicolon ( ; ).
The comment field continues from the semicolon to the new line code at the end of the line, or to the EOF code of the file.
Comments make it easier to understand and maintain programs.
Comments are not processed by the assembler, and are output verbatim to assembly lists.
Characters that can be described in the comment field are those shown in "(1) Character set".