A166 User's GuideA166 Introduction Assembling Programs Operands and Expressions Instruction Operands Expressions Numbers Character Strings Location Counter Symbols Operators Control Statements Macro Processor Error Messages Appendix
Symbols representing numeric values or addresses make a program easier to read and understand. Symbols have the following attributes:
Once a symbol's attributes are defined, the symbol can be used as a numeric operand in expressions.
After a symbol is defined, it is named. Symbol names must follow the style conventions listed below.
The assembler contains predefined symbols for mnemonics, operands, and C16x/ST10 specific data and bit-addresses. These names are reserved words and cannot be used by the programmer to define symbols or labels.
Because a label is a symbol, the rules for symbols also apply to labels. A label is the first field in a line, but it can be preceded by tabs or spaces and followed by a colon. Only one label is permitted per line. When defined, a label receives the current numerical value of the address counter of the currently active section. A label may not be defined more than once or have the name of a reserved word. The following box shows label use:
LABEL2: ; a comment line with a label COPY: MOVB [R1],RL4
Special Assembly Symbols
Some symbols are predefined as reserved words and usually refer to names of the processor registers. For example, R0 through R15 refer to names of general-purpose registers (GPRs). The dollar sign ($) represents the current offset in the active section. Each section has a separate address counter and the length increases after each instruction. If needed, the ORG directive can change the address counter's value. Otherwise, the address counter automatically changes to the new section if the current section is changed.
MSG: DB LEN, 'THIS IS A MESSAGE',0 LEN EQU $ - MSG - 1 HALT: JMP $: ; jump to 'HALT' TABLE: DW $, $, $, $ ;
Expressions containing variables or labels defined in relocatable sections cannot be evaluated at assembly time because the final address is unknown. The L166 evaluates the address later.
Relocatable symbols are listed below.
The following examples show how the previously mentioned relocatable symbols are generated:
Example 1—Section names:
D100 SECTION DATA ; relocatable data section V1 DSW 1 ; reserve one word V2 DSB 1 ; reserve one byte D100 ENDS ; end of data section D200 SECTION DATA SBASE DW D100 ; init word with base of sect. D100 GBASE DW DGR ; init word with base of group 'DGR' D200 ENDS MOV R5,#DGR ; DGR is relocatable MOV R4,#V2-V1 ; V2-V2 is absolute (2) MOV R1,#XVAL ; use external constant (data4 short form) MOV R3,#4 * 8 ; absolute expression
Example 2—Group name using sections from example 1:
DGR DGROUP D100, D200 ; group consists of section D100 and D200
Example 3—External constants:
EXTRN XVAL : DATA4: ; an external 4-bit constant EXTRN YVAL : DATA8: ; an external 8-bit constant
of your data.