Page 338 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 338
PROBLEMS 315
LDA ABB ALP DCB $01
ADD BAB GAM DCB $00
STA BBA DEL DCB $04
SWI BET DCB $03
ABB DCB $01 LDA ALP
BAB DCB $02 ADD BET
BBA DCB $00 ADD DEL
END STA GAM
SWI
END
A two-pass assembler is required, and labels and opcodes must be stored as linked
lists. Use subroutines GETS and CHKEND (Problem 19) to input labels or opcode
mnemonics, and FIND (Problem 20) to search both the symbol table and the
mnemonics, in your assembler. Show the storage structure for your mnemonic's
binary tree (it is preloaded) following the graph shown in Figure 10.15. On the
first pass, just get the lengths of each instruction or dkectives and save the labels
and their addresses in a linked list. End pass one when END is encountered. On
pass two, put the opcodes and addresses in the sring OBJ.
Figure 10.15. Graph of Linked List for Problem 10