436 Accumulator addressing Th final addressing mode used by the assembler is known as accumulator addressing. This is where the accumulator is addressed rather than a memory location, and is specified by placing A in the operand field. For example: ASL A means ‘shift the contents of the accumuator one bit to the left’. Note that this means that ‘A’ cannot be used as a variable name within an assembly language program. Finally, it must be re-emphasised that each assembly language mnemonic can only use some of the addressing modes detailed above; see the table in the appendix for the addressing modes used by each instruction.
Placing machine code programs in memory When the assembler is creating a machine code program the code produced is placed in memory starting from the address in P% (unless O% is used, see OPT below). The assembler updates the value in P% as it is assembling, and at the end of an assembly operation the value in P% represents the address of the first ‘free’ memory location after the machine code program. In the example program shown above, the value of P% is allocated directly (at line 20). This method of setting up P% is somewhat dangerous, since you have to be sure that location &3500 and (in this case) the nine locations beyond &3500 do not contain anything important.
A much safer way of setting up P% is to dimension a block of memory using a variation of the BASIC DIM keyword. The example program below illustrates this feature, and other features used with assembly language: 5 REM Uses assembly code to change to mode 4 and draw a triangle 10 OSWRCH=&FFE3 20 DIM GAP% 100 30 DIM data &1C 40 FOR opt%=0 TO 3 STEP 3 50 P%=GAP% 60 [ 70 OPT opt% 80 .entry LDX#0 \ set data block offset to zero 90 .loop LDA data,X \ load VDU parameter from data block 100 JSR OSWRCH \ perform VDU command 110 INX \ increment offset 120 CPX #&1C \ has all data been loaded?