Professional Documents
Culture Documents
Assembler Design Options: One-Pass Assemblers Multi-Pass Assemblers
Assembler Design Options: One-Pass Assemblers Multi-Pass Assemblers
Assembler Design Options: One-Pass Assemblers Multi-Pass Assemblers
One-pass assemblers
Multi-pass assemblers
One-Pass Assemblers
● Object code is generated in a single pass.
● Main problem
● forward references (Instruction operands
often are symbols that have not yet been
defined in the source program. Thus the
assembler does not know what address to
insert in the translated instruction)
● Solution
● data items: require all such areas be
defined before they are referenced Chap 2
One-Pass Assemblers
Chap 2
Eg: Forward reference free program
MOVE START 1000
ALPHARESW 1
FIVE WORD 5
CHARZ BYTE C’Z’
C1 RESB 1
LDA FIVE
STA ALPHA
LDCH CHARZ
STCH C1
END
Chap 2
SYMTAB for the above program
LABEL ADDRESS
ALPHA 1000
FIVE 1003
CHARZ 1006
C1 1007
Chap 2
Object code
MOVE START 1000
ALPHARESW 1
FIVE WORD 5 000005
CHARZ BYTE C’Z’ 5A
C1 RESB 1
LDA FIVE 001003
STA ALPHA0C1000
LDCH CHARZ 501006
STCH C1 541007
END
Chap 2
DEALING WITH FORWARD
REFERENCE
MOVE START 1000
ALPHA RESW 1
LDA FIVE
STA ALPHA
FIVE WORD 5
END
Chap 2
When encounter FIVE as operand(which is not in
SYMTAB), insert FIVE and a * with a reference to
1004.
LABEL ADDRESS
ALPHA 1000
FIVE * 1004
LABEL ADDRESS
ALPHA 1000
FIVE 1009
Chap 2
Object code
MOVE START 1000
ALPHA RESW 1
LDA FIVE 00----
STA ALPHA 0C1000
FIVE WORD 5 000005
END
001009
Chap 2
Load-and-go Assembler
● Characteristics
● Useful for program development and testing
● Avoids the overhead of writing the object
program out and reading it back
● Both one-pass and two-pass assemblers can
be designed as load-and-go.
● However one-pass also avoids the over head
of an additional pass over the source program
● For a load-and-go assembler, the actual
address must be known at assembly time, we
can use an absolute program
Chap 2
Forward Reference in One-pass Assembler
Chap 2
Load-and-go Assembler (Cont.)
● At the end of the program
● any SYMTAB entries that are still marked with *
indicate undefined symbols
● search SYMTAB for the symbol named in the
END statement and jump to this location to
begin execution
● The actual starting address must be
specified at assembly time
● Example
● Figure 2.18Figure 2.18, 2.19
Chap 2
Chap 2
Chap 2