Back to the index of Compute II

COMPUTE II ISSUE 1 / APRIL/MAY 1980 / PAGE 40

PRINTING A SYMBOL TABLE FOR THE AIM-65 ASSEMBLER

Richard F. Olivo
Biological Sciences, Smith College
Northampton, MA 01063

The assembler for Rockwell's AIM 65 makes assembly-language programming very convenient, particularly in conjunction with the excellent editor that is part of AIM 65's monitor. However, the assembler does not include an option to print the symbol table, although it does create such a table in memory. The following program is one way of decoding and printing the symbol table. In revising a program, a print-out of the symbol table can be very helpful.

On entering the AIM 65 assembler from the monitor, you are asked for the addresses that start and end the symbol table. The assembler places your answers in zero-page addresses 3A, 3B (“FROM”) and 3E, 3F (“TO”). After assembly, the total number of symbols is available in addresses 0B, 0C (in high, low order). The symbol table itself consists of sequential eight-byte entries. The first six bytes of each entry are the symbol name, in ASCII characters (the assembler enters spaces if the symbol is less than six characters), and the last two bytes are the symbol's address, in hex notation.

The program to print the table reads through the table using indirect addressing indexed by Y. It establishes the variable ADDR (at locations 00 and 01), which provides the address of the first character of the current symbol. ADDR is initially set equal to the address in “FROM (3A, 3B); it is incremented by eight after each symbol is printed. For each symbol, the Y register is incremented from zero to seven to access the successive bytes of that symbol.

A second variable, COUNT (addresses 02 and 03), keeps track of the number of symbols that remained to be printed. COUNT is initially set equal to one less than the total number of symbols (from addresses 0B and 0C), and it is decremented by one after each symbol is printed. After COUNT reaches zero (the last symbol is numbered zero, which is why the initial count is one less than the total), the program exits and prints the total number of symbols in hex notation. The program uses AIM monitor subroutines to print the ASCII and hex characters. It also turns the AIM printer on and off at the start and end of the table, which I find very handy.

The listing given below places the program at locations 0200-027D, which are available on every AIM 65. The program could of course be placed in other memory locations, and it would be very convenient in a PROM. At the end of the listing, the program was run to list its own symbol table.


==0000 	BLANK=$E83E
==0000 	CRLOW=$EA13
==0000 	EQUAL=$E7D8
==0000 	PRIASC=$E97A
==0000 	PRIFLG=$A411
==0000 	PRIHX2=$EA46
==0000 	ADDR=0
==0000 	COUNT=ADDR+2
==0000
 	*=$0200
----------------------
INITL ADDR, COUNT, Y

==0200 	
;"FROM" =3A,3B
==0200 	SYMTBL
A53A 	LDA $3A
8500 	STA ADDR
A53B 	LDA $3B
8501 	STA ADDR+1
;ADDR ACCESSES TABLE

A50B 	LDA $0B
8502 	STA COUNT
A50C 	LDA $0C
8503 	STA COUNT+1
==0210 	
;COUNT=SYMBOLS TO GO
C603 	DEC COUNT+1
;FIRST SYMB=0, NOT 1
A000 	LDY #0
;INDX 8 BYTES/SYMBOL
A980 	LDA #$80
8D11A4 	STA PRIFLG
;TURN 	PRINTER ON
2013EA 	JSR CRLOW
2013EA 	JSR CRLOW
;SKIP 	2 LINES AT TOP
----------------------
MAIN LOOP

==021F 	SYMLP
B100 	LDA (ADDR), Y
C006 	CPY #6
;BYTES 	0-5 =ASCII
F007 	BEQ SPACE
;PRINT 	6 ASCII CHAR.
207AE9 	JSR PRIASC
C8 	INY
4C1F02 	JMP SYMLP
;PRINT 	SPACE & EQUAL
==022C 	SPACE
48 	PHA
203EE8 	JSR BLANK
20D8E7 	JSR EQUAL
203EE8 	JSR BLANK
;NEXT 2 BYTES = HEX
68 	PLA
2046EA 	JSR PRIHX2
C8 	INY
B100 	LDA (ADDR), Y
==023D 	
2046EA 	JSR PRIHX2
2013EA 	JSR CRLOW
;HAVE PRINTED 1 LINE
----------------------
DECR COUNT & TEST

C603 	DEC COUNT+1
A9FF 	LDA 	$FF
C503 	CMP COUNT+1
;FF = BORROW
D006 	BNE NXTADR
C602 	DEC COUNT
==024D 	
C502 	CMP COUNT
;FF = DONE
F012 	BEQ DONE
----------------------
UPDATE ADDRESS

==0251 	NXTADR
18 	CLC
A500 	LDA ADDR
;LOW BYTE
6908 	ADC #8
8500 	STA ADDR
A501 	LDA ADDR+1
;HIGH BYTE
6900 	ADC #0
8501 	STA ADDR+1
A000 	LDY #0
4C1F02 	JMP SYMLP
----------------------
PRINT TOTAL & EXIT

==0263 	DONE
2013EA 	JSR CRLOW
A50B 	LDA $0B
2046EA 	JSR PRIHX2
A50C 	LDA $0C
2046EA 	JSR PRIHX2
;PRINT TOTAL, SKIP LN
2013EA 	JSR CRLOW
==0273 	
2013EA 	JSR CRLOW
A900 	LDA #0
8D11A4 	STA PRIFLG
;TURN PRINTER OFF
4C82E1 	JMP $E182
;JUMP TO MONITOR

        .END

BLANK   = E83E
CRLOW 	= EA13
EQUAL 	= E7D8
PRIASC 	= E97A
PRIFLG 	= A411
PRIHX2 	= EA46
ADDR 	= 0000
COUNT 	= 0002
SYMTBL 	= 0200
SYMLP 	= 021F
SPACE 	= 022C
NXTADR 	= 0251
DONE 	= 0263

000D