Upload
magnus-holland
View
212
Download
0
Embed Size (px)
Citation preview
A program that translates programs from assembly language to machine language.
Elements:
Mnemonic Operations Codes (Mnemonic opcodes): Eliminates: Need to memorize numeric opcodes Enables: Helpful diagnostics
Symbolic Operands:Symbolic NamesAssociated: Data or Instructions Performs: Memory Bindings Data DeclarationsDeclared: Variety of notationsConversions: -5 into (11111010)2
[ Label ] <Opcode> <operand spec> [,<operand spec>..]
[..] Enclosed Specification is optional
Label Symbolic name with memory
<operand spec>
<symbolic name> [+<displacement>] [<index register>]
Assembly Statements:
• Imperative Statement
• Declarative Statement
• Assembler Statement
Imperative Statement:
• Indicates: Action to be performed during execution of an
assembly statement
• Translates: Into one Machine Instructions
Declarative Statement:
• Syntax:
• [label] DS <constant>
[label] DC `<values>’
DS: Reserves Area of Memory and associated with them
DC: Constructs Memory words containing constants
Example:
• DS
• A DS 1Reserves a memory area of 1 word and associates with name A.
• G DS 200Constructs memory words containing constructs.
• DC
• One DC ‘1’
Associates: Name with a memory containing the value ‘1’
Conversions: Different forms Hexadecimal,binary,decimal
Constants Use:
• Use: Initializes memory words to given values
• Values: Not protected by Assembler It can be changed by new values into the memory
word
Constants Type:
• An immediate Operands: Can be used in an assembly statement only if the
architecture of the target machine includes the necessary
features.
• Literals:
Design Specification:
• Identify : Necessary to perform task
• Design : Suitable data structure to record the information
• Determine :
Processing necessary to obtain and maintain the information
Processing necessary to perform the task
• Assembly Statement:
MOVER BREG,ONE
• ONE: Address of Memory Word
(Depends) Source Program
• MOVER: Machine Operation Code
(Depends) Assembly Program
Considers Two Data Structures:
1) Symbol Table
2) Mnemonics Table
Synthesis Phase:
Symbol Table:
(Fields)Name
Address
Mnemonic Table:
mnemonic
opcode
(Fields)
Pass Structure of Assemblers:
Two Pass Translation
Single Pass Translation
Two Pass Translation
Can handle forward references easily
1st Pass: LC processing, symbols entered in the symbol table Symbols defined in the program are entered
Performs: Analysis of Source Program 2nd Pass: Synthesizes the target form using the address information found in the information table
Performs: Synthesis of Target Program
The first pass constructs an intermediate representation of the sourceProgram for use by the second pass.
Design of a Two Pass Assembler
• Pass I : 1. Separate the Symbol, mnemonic opcode and
operand fields
2. Build the Symbol table
3. Perform LC Processing
4. Construct Intermediate Representations
• Pass 2 : Synthesize the target Program
Advanced Assembler Directives:
• ORIGIN <address spec>
<address spec> or <constants>s
• ORIGIN statement is useful when the target program does not consist of consecutive memory words
• <address spec> in the ORIGIN statement provides the ability to perform LC processing in a relative rather than absolute manner.
ORIGIN <address spec> <symbol> EQU <address spec>
<symbol> EQU <address spec>
EQU
where <address spec> is an <operand spec> or <constant>
EQU Defines the symbol to represent <address spec>
EQU Associates the name <symbol> with <address spec>