Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Module 4
Role of Assembler
Source Object
Assembler Linker
Program Code
Executable
Code
Loader
Module 4
Assembler’s functions
1. Convert mnemonic operation codes to their
machine language equivalent
2. Convert symbolic operands to their equivalent
machine addresses
3. Build the machine instruction in the proper format
4. Convert data constants to internal machine
representation.
5. Write the object program and assembly listing
Module 4
Issue noticed
Module 4
Module 4
Example of Instruction Assemble
STCH BUFFER,X 549039
8 1 15
opcode x address
m
(54)16 1 (001)2 (039)16
Forward reference
Module 4
Assembler directives –
Not translated into machine instructions
provide instructions to the assembler itself
(Eg. BYTE, RESB)
Module 4
Functions of Two Pass Assembler
Pass 1
Assign addresses to all statements in the program
Save the values assigned to all labels for use in Pass 2
Perform some processing of assembler directives
Pass 2
Assemble instructions
Generate data values defined by BYTE, WORD
Perform processing of assembler directives not done in Pass 1
Write the object program and the assembly listing
Module 4
Two Pass Assembler
Read from input line
LABEL, OPCODE, OPERAND
Source
program
Intermediate Object
Pass 1 Pass 2
file codes
Module 4
Module 4
Module 4
Data Structures
Operation Code Table (OPTAB)
Symbol Table (SYMTAB)
Literal table(LITTAB)
Module 4
OPTAB (operation code table)
Content
mnemonic, machine code (instruction format, length) etc.
Characteristic
static table
Implementation
array or hash table, easy for search
Module 4
Assembly program contains three kinds of statements:
1. Imperative statements
2. Declarative statements
3. Assembler directives
Module 4
Imperative statements
Statements indicates actions to be performed
during execution of the assembled program
Declarative statements
Statements declares constants or storage areas in a
program. Syntax: Label DS <constant>
Eg: A DS 1, B DC 1.
Assembler directives
Instruct the assembler to perform certain actions
during the assembly of the program
Eg: START, END
START 100 // Program starts from location 100
Module 4
Module 4
Phases of Assembler
Mnemon
ic table
Analysis Synthesis
Source Object
Phase Phase
Program program
Symbol
Table
Module 4
Analysis Phase
Isolate the lable, mnemonic operation code and
operand field of a statement
Enters the symbol found in lable field & address of
available machine word into symbol table
Validate the mnemonics operation code by looking in
the mnemonics table
Module 4
Mnemonics table
Module 4
Synthesis Phase
Obtain the machine operation code corresponding to
the mnemonic operation code by searching the
mnemonic table
Obtain address of the operand from the symbol table
Synthesis the machine instruction
Module 4