Symbols - Chysn/VIC20-wAx2 GitHub Wiki

wAx is a "somewhat symbolic assembler," allowing symbols to represent addresses or values. These symbols can then be used as instruction operands. Addresses and values can be represented as single-character symbols prefixed with the @ sigil. A symbol name may be a digit (0-9), a letter (A-Z), or an @ sign. There's also a special symbols, @&, which is always a forward reference (see Forward Reference Symbol, below).

10 .A 1800 LDA #"J"
20 .A *    LDY #22
30 .A * @P JSR $FFD2
40 .A *    DEY
50 .A *    BNE @P
60 .A *    RTS

The value of a symbol can be assigned in two ways:

.A addr @name
.@name value

Where name is a valid symbol name, addr is a valid 16-bit address, and value is a valid 8-bit or 16-bit value.

Symbols can be used before they are assigned to an address (called a "forward reference"), like this:

100 .A *    LDA $912D
110 .A *    AND #%01000000
120 .A *    BEQ @2
130 .A *    JMP $EABF
140 .A * @2 LDY $FA
150 .A *    etc...

High and Low Bytes

For instructions that require one-byte operands (immediate, zeropage, and X/Y indirect instructions), you may specify the high or low byte of a symbol's value by placing > or <, respectively, immediately before the symbol:

10 .@- ; CLEAR SYMBOL TABLE
15 .@C 900F ; SCREEN COLOR
20 .@V 0314 ; IRQ VECTOR
100 .* 6000
105 .A *     SEI
110 .A *     LDA #<@I  ; LOW BYTE OF IRQ HANDLER ADDRESS
115 .A *     STA @V
120 .A *     LDA #>@I  ; HIGH BYTE OF IRQ HANDLER ADDRESS
125 .A *     STA @V+1
130 .A *     CLI
140 .A *     RTS
145 .A * @I
150 .A *     INC @C
155 .A *     JMP $EABF

A symbol may be placed alone on a line, or with an instruction (or data) immediately after it on the same line.

Redefinition

wAx allows symbol redefinition without restriction. If a symbol is defined when it is used as an operand, the operand will be the symbol's value at the time the symbol is used. If a symbol is undefined when it is used, it will be recorded as a forward reference, to be filled in when the value is known.

Forward Reference Symbol

While other symbols (@[0-9], @[A-Z], and @@) keep their values after definition, the forward reference symbol (called @&) is cleared whenever it is used as an operand, allowing it to be used as a forward reference multiple times:

.A*    BCC @& ; BRANCH TO THE NEXT @&
.A*    BRK
.A* @& 
.A*    BEQ @& ; BRANCH TO THE NEXT @&
.A*    BRK
.A* @& 
.A*    ORA $FB
.A;    etc...

Note that you cannot define @& and use it as an operand in the same line of code. That's why, in this example, definition happens on separate lines.