Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assemblers.

Similar presentations


Presentation on theme: "Assemblers."— Presentation transcript:

1 Assemblers

2 Define A program that translates programs from assembly language to machine language.

3 Elements: Mnemonic Operations Codes (Mnemonic opcodes):  Eliminates: Need to memorize numeric opcodes Enables: Helpful diagnostics Symbolic Operands: Symbolic Names Associated: Data or Instructions Performs: Memory Bindings Data Declarations Declared: Variety of notations Conversions: -5 into ( )2

4 Statement Format [ Label ] <Opcode> <operand spec> [,<operand spec>..] [..]  Enclosed Specification is optional Label  Symbolic name with memory <operand spec> <symbolic name> [+<displacement>] [<index register>]

5 Assembly Statements: Imperative Statement Declarative Statement
Assembler Statement

6 Imperative Statement:
Indicates: Action to be performed during execution of an assembly statement Translates: Into one Machine Instructions

7 Declarative Statement:
Syntax: [label] DS <constant> [label] DC `<values>’ DS: Reserves Area of Memory and associated with them DC: Constructs Memory words containing constants

8 Example: DS A DS Reserves a memory area of 1 word and associates with name A. G DS Constructs memory words containing constructs. DC One DC ‘1’ Associates: Name with a memory containing the value ‘1’ Conversions: Different forms Hexadecimal,binary,decimal

9 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

10 Constants Type: An immediate Operands: Literals:
Can be used in an assembly statement only if the architecture of the target machine includes the necessary features. Literals:

11 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

12 (Depends) Assembly Program
Synthesis Phase: 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

13 Symbol Table: (Fields) Name Address Mnemonic Table: (Fields) mnemonic opcode

14 Pass Structure of Assemblers:
Two Pass Translation Single Pass Translation

15 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 source Program for use by the second pass.

16 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

17 Advanced Assembler Directives:
ORIGIN <address spec> <symbol> EQU <address spec> 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.

18 EQU <symbol> EQU <address spec> 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>


Download ppt "Assemblers."

Similar presentations


Ads by Google