0% found this document useful (0 votes)
49 views

SP2.4 Assembler-Design-Options

The document discusses different types of assembler designs including one-pass, multi-pass, and two-pass assemblers. One-pass assemblers can have issues with forward references while multi-pass assemblers prohibit forward references in the first pass. Two-pass assemblers with an overlay structure can be used when memory is limited.

Uploaded by

tanjuner01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

SP2.4 Assembler-Design-Options

The document discusses different types of assembler designs including one-pass, multi-pass, and two-pass assemblers. One-pass assemblers can have issues with forward references while multi-pass assemblers prohibit forward references in the first pass. Two-pass assemblers with an overlay structure can be used when memory is limited.

Uploaded by

tanjuner01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Chapter 2 Assemblers

-- Assembler Design Options

Tzong-Jye Liu
Department of Information Engineering and Computer Science
Feng Chia University
[email protected]

Outline

n One-pass assemblers
n Multi-pass assemblers
n Two-pass assembler with overlay structure

[email protected] System Programming 2


Load-and-Go Assembler
n Load-and-go assembler generates their object code
in memory for immediate execution.
n No object program is written out, no loader is needed.
n It is useful in a system with frequent program
development and testing
n The efficiency of the assembly process is an important
consideration
n Programs are re-assembled nearly every time they
are run, efficiency of the assembly process is an
important consideration.

System Programming 3

One-Pass Assemblers
n Scenario for one-pass assemblers
n Generate their object code in memory for immediate execution –
load-and-go assembler
n External storage for the intermediate file between two passes is slow
or is inconvenient to use
n Main problem
n Forward references
n Data items
n Labels on instructions
n Solution
n Require that all areas be defined before they are referenced.
n It is possible, although inconvenient, to do so for data items.
n Forward jump to instruction items cannot be easily eliminated.
n Insert (Label, address to be modified) to SYMTAB
n Usually, address to be modified is a linked-list
System Programming 4
Sample program for a one-pass assembler
Figure 2.18, pp. 94

[email protected] System Programming 5

Forward Reference
in One-pass Assembler
n Omits the operand address if the symbol has not yet been
defined
n Enters this undefined symbol into SYMTAB and indicates that it
is undefined
n Adds the address of this operand address to a list of forward
references associated with the SYMTAB entry
n When the definition for the symbol is encountered, scans the
reference list and inserts the address.
n At the end of the program, reports the error if there are still
SYMTAB entries indicated undefined symbols.
n For Load-and-Go assembler
n Search SYMTAB for the symbol named in the END statement and jumps
to this location to begin execution if there is no error

System Programming 6
Object Code in Memory and SYMTAB
Figure 2.19(a), pp.95
After scanning line 40 of prog. In Fig. 2.18

System Programming 7

Object Code in Memory and SYMTAB


Figure 2.19(b), pp.96
After scanning line 160 of prog. In Fig. 2.18

[email protected] System Programming 8


If One-Pass Assemblers Need to Produce
Object Codes
n If the operand contains an undefined symbol, use 0
as the address and write the Text record to the object
program.
n Forward references are entered into lists as in the
load-and-go assembler.
n When the definition of a symbol is encountered, the
assembler generates another Text record with the
correct operand address of each entry in the
reference list.
n When loaded, the incorrect address 0 will be updated
by the latter Text record containing the symbol
definition.

System Programming 9

Object program for one-pass assembler


Figure 2.18, pp.97

System Programming 10
Multi-Pass Assemblers

n For a two pass assembler, forward references in


symbol definition are not allowed:
ALPHA EQU BETA
BETA EQU DELTA
DELTA RESW 1
n Symbol definition must be completed in pass 1.
n Prohibiting forward references in symbol
definition is not a serious inconvenience.
n Forward references tend to create difficulty for a person
reading the program.

System Programming 11

Implementation
n For a forward reference in symbol definition, we store
in the SYMTAB:
n The symbol name
n The defining expression
n The number of undefined symbols in the defining expression
n The undefined symbol (marked with a flag *)
associated with a list of symbols depend on this
undefined symbol.
n When a symbol is defined, we can recursively
evaluate the symbol expressions depending on the
newly defined symbol.

System Programming 12
Multi-pass assembler example
Figure 2.21, pp. 99-101
# of undefined symbols in the
defining expression
The defining expression

Depending list

Undefined symbol

System Programming 13

Multi-pass assembler example


Figure 2.21, pp. 99-101

2 MAXLEN EQU BUFEND-BUFFER 3 PREVBT EQU BUFFER-1

System Programming 14
Multi-pass assembler example
Figure 2.21, pp. 99-101

4 BUFFER RESB 4096 5 BUFEND EQU *

System Programming 15

Two-pass assembler
with overlay structure
n When memory is not enough
n Pass 1 and pass 2 are never required at the same time
n Three segments
n Overlay program

Shared table Driver


& Routines Shared table
Pass 1 table & Routines
& Routines
Pass 2 table Pass 1 table Pass 2 table
& Routines & Routines
& Routines

System Programming 16

You might also like