There are five classes of tokens:
Identifiers (symbols)
Keywords
Numerical constants
String Constants
Operators
An identifier is an arbitrarily-long sequence of letters and digits. The first character must be a letter; the underscore (_) (ASCII 0x5F) and the period (.) (ASCII 0x2E) are considered to be letters. Case is significant: uppercase and lowercase letters are different.
Keywords such as x86 instruction mnemonics (“opcodes”) and assembler directives are reserved for the assembler and should not be used as identifiers. See Chapter 3, Instruction Set Mapping for a list of the Solaris x86 mnemonics. See Assembler Directives for the list of as assembler directives.
Numbers in the x86 architecture can be integers or floating point. Integers can be signed or unsigned, with signed integers represented in two's complement representation. Floating-point numbers can be: single-precision floating-point; double-precision floating-point; and double-extended precision floating-point.
Integers can be expressed in several bases:
Decimal. Decimal integers begin with a non-zero digit followed by zero or more decimal digits (0–9).
Binary. Binary integers begin with “0b” or “0B” followed by zero or more binary digits (0, 1).
Octal. Octal integers begin with zero (0) followed by zero or more octal digits (0–7).
Hexadecimal. Hexadecimal integers begin with “0x” or “0X” followed by one or more hexadecimal digits (0–9, A–F). Hexadecimal digits can be either uppercase or lowercase.
Floating point constants have the following format:
Sign (optional) – either plus (+) or minus (–)
Integer (optional) – zero or more decimal digits (0–9)
Fraction (optional) – decimal point (.) followed by zero or more decimal digits
Exponent (optional) – the letter “e” or “E”, followed by an optional sign (plus or minus), followed by one or more decimal digits (0–9)
A valid floating point constant must have either an integer part or a fractional part.
A string constant consists of a sequence of characters enclosed in double quotes ( ") (ASCII 0x22). To include a double-quote character ("), single-quote character ('), or backslash character (\) within a string, precede the character with a backslash (\) (ASCII 0x5C). A character can be expressed in a string as its ASCII value in octal preceded by a backslash (for example, the letter “J” could be expressed as “\112”). The assembler accepts the following escape sequences in strings:
Escape Sequence |
Character Name |
ASCII Value (hex) |
---|---|---|
\n |
newline |
0A |
\r |
carriage return |
0D |
\b |
backspace |
08 |
\t |
horizontal tab |
09 |
\f |
form feed |
0C |
\v |
vertical tab |
0B |
The assembler supports the following operators for use in expressions. Operators have no assigned precedence. Expressions can be grouped in square brackets ([]) to establish precedence.
Addition
Subtraction
Multiplication
Division
Bitwise logical AND
Bitwise logical OR
Shift right
Shift left
Remainder
Bitwise logical AND NOT
Bitwise logical XOR
The asterisk (*), slash (/), and percent sign (%) characters are overloaded. When used as operators in an expression, these characters must be preceded by the backslash character (\).