0% found this document useful (0 votes)
198 views3 pages

Ans 3

The document describes the data structures and two-pass flow of an assembler. For pass 1, it lists the data structures as the input source program, location counter, machine operation table, pseudo operation table, symbol table, and literal table. For pass 2, it adds the base table, instruction work space, print line work space, punch card work space, and output deck. It then explains the two-pass assembler flow. Pass 1 performs analysis of the source program, building symbol tables and setting location counters. It generates an intermediate representation for pass 2. Pass 2 synthesizes the target program using the information from pass 1, such as symbols and their addresses.

Uploaded by

sazizulla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
198 views3 pages

Ans 3

The document describes the data structures and two-pass flow of an assembler. For pass 1, it lists the data structures as the input source program, location counter, machine operation table, pseudo operation table, symbol table, and literal table. For pass 2, it adds the base table, instruction work space, print line work space, punch card work space, and output deck. It then explains the two-pass assembler flow. Pass 1 performs analysis of the source program, building symbol tables and setting location counters. It generates an intermediate representation for pass 2. Pass 2 synthesizes the target program using the information from pass 1, such as symbols and their addresses.

Uploaded by

sazizulla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

3.

Explain the following with respect to the design


specifications of an Assembler:
A) Data Structures
B) pass1 & pass2 Assembler
flow chart
Ans –
A) Data Structure
The second step in our design procedure is to establish the databases
that we have to work with.
Pass 1 Data Structures
1. Input source program
2. A Location Counter (LC), used to keep track of each instruction’s
location.
3. A table, the Machine-operation Table (MOT) that indicates the symbolic mnemonic,
for each instruction and its length (two, four, or six bytes)
4. A table, the Pseudo-Operation Table (POT) that indicates the symbolic
mnemonic and action to be taken for each pseudo-op in pass 1.
5. A table, the Symbol Table (ST) that is used to store each label and its
corresponding value.
6. A table, the literal table (LT) that is used to store each literal
encountered and its corresponding assignment location.
7. A copy of the input to be used by pass 2.
Pass 2 Data Structures
1. Copy of source program input to pass1.
2. Location Counter (LC)
3. A table, the Machine-operation Table (MOT), that indicates for each instruction,
symbolic mnemonic, length (two, four, or six bytes), binary machine opcode and format
of instruction.
4. A table, the Pseudo-Operation Table (POT), that indicates the symbolic
mnemonic and action to be taken for each pseudo-op in pass 2.
5. A table, the Symbol Table (ST), prepared by pass1, containing each
label and corresponding value.
6. A Table, the base table (BT), that indicates which registers are currently specified as
base registers by USING pseudo-ops and what the specified contents of these registers
are.
7. A work space INST that is used to hold each instruction as its various
parts are being assembled together.
8. A work space, PRINT LINE, used to produce a printed listing.
9. A work space, PUNCH CARD, used prior to actual outputting for converting the
assembled instructions into the format needed by the loader.
10. An output deck of assembled instructions in the format needed by
the loader.

Format of Data Structures


The third step in our design procedure is to specify the format and content of each of
the data structures. Pass 2 requires a machine operation table (MOT) containing the
name, length, binary code and format; pass 1 requires only name and length. Instead of
using two different tables, we construct single (MOT). The Machine operation table
(MOT) and pseudo-operation table are example of fixed tables. The contents of these
tables are not filled in or altered during the assembly process.

B) pass1 & pass2 Assembler flow chart


Pass Structure of Assemblers

Here we discuss two pass and single pass assembly schemes in this
section:
Two pass translation
Two pass translation of an assembly language program can handle forward references
easily. LC processing is performed in the first pass and symbols defined in the program
are entered into the symbol table. The second pass synthesizes the target form using
the address information found in the symbol table. In effect, the first pass performs
analysis of the source program while the second pass performs synthesis of the target
program. The first pass constructs an intermediate representation (IR) of the source
program for use by the second pass. This representation consists of two main
components–data structures, e.g. the symbol table, and a processed form of the source
program. The latter component is called intermediate code (IC).
Single pass translation
LC processing and construction of the symbol table proceed as in two pass translation.
The problem of forward references is tackled using a process called backpatch-ing. The
operand field of an instruction containing a forward reference is left blank initially. The
address of the forward referenced symbol is put into this field when its definition is
encountered.

MOVER BREG, ONE


can be only partially synthesized since ONE is a forward reference. Hence the
instruction opcode and address of BREG will be assembled to reside in location 101.
The need for inserting the second operand’s address at a later stage can be indicated
by adding an entry to the Table of Incomplete Instructions (TII). This entry is a pair
(instruction address>,
<symbol>), e.g. (101, ONE) in this case.
By the time the END statement is processed, the symbol table would contain the
addresses of all symbols defined in the source program and TII would contain
information describing all forward references. The assembler can now process each
entry in TII to complete the concerned instruction. For example, the entry (101, ONE)
would be processed by obtaining the address of ONE from symbol table and inserting it
in the operand address field of the instruction with assembled address 101.
Alternatively, entries in TII can be processed in an incremental manner. Thus, when
definition of some symbolsymb is encountered, all forward references to symb can be
processed.
Design of A Two Pass Assembler

Tasks performed by the passes of a two pass assembler are as follows:

Pass I:

1. Separate the symbol, mnemonic opcode and operand fields.

2. Build the symbol table.

3. Perform LC processing.

4. Construct intermediate representation.

Pass II: Synthesize the target program.


Pass I performs analysis of the source program and synthesis of the intermediate
representation while Pass II processes the intermediate representation to synthesize
the target program. The design details of assembler passes are discussed after
introducing advanced assembler directives and their influence on LC processing.

You might also like