Hca.geocities.com/JLABELLE@rogers.com/nsasm/docs/c826.htmlca.geocities.com/JLABELLE_rogers.com/nsasm/docs/c826.htmldelayedxmJ"OKtext/html@'"b.HTue, 07 Dec 2004 00:49:39 GMT2Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98)en, *mJ"Assignment Statements

Chapter 5. Assignment Statements

The syntax for an assignment statement is as follows:

[label:] symbol=expression [;comment]

[label:] symbol=expression :BYTE [;comment]

[label:] symbol=expression :WORD [;comment]

The assignment statement assigns the value and all other attributes of the expression on the right of the equal sign to the symbol on the left of the equal sign. The assignment statement does not generate machine code. It simply assigns the expression to a symbol. When the symbol is used in an instruction statement operand field, the assigned value is used in code generation. The size attribute is passed to the debugger through the COFF file. :BYTE or :WORD may be optionally used to assign a size to the symbol. If used, it will override the size of the expression. The & operator may be used to force a null expression. :BYTE may also be specified as :B and :WORD as :W.

		Y  = 5      ; assign the value 5 to Y.
		B1 = 6:BYTE ; B1 is a byte expression with a value of 6
	

The assignment statement may also refer to the current value of the location counter. The location counter symbol (".") may appear on both sides of the assignment statement equal sign. If it appears on the left, it is assigned the value of the expression to the right side of the equal sign. In that case, the expression on the right must be defined during the first pass so that the pass 1 label assignments may be made.

		.   = X'1020 ; set location counter to address X'1020
		             ; this is same as .ORG X'1020
		LOC = .      ; save current location counter value in "LOC"
	

A symbol may be assigned only one value during an assembly with an assignment statement. Attempting to redefine the value of the symbol will result in an error message. The .set directive, however, allows symbol values to be redefined during an assembly.

Some memory reference symbols are predefined, and may not be redefined. These are the registers SP, A, B, and X.