18

A program that translates programs from assembly language to machine language.programassembly languagemachine language

Embed Size (px)

Citation preview

Page 1: A program that translates programs from assembly language to machine language.programassembly languagemachine language
Page 3: A program that translates programs from assembly language to machine language.programassembly languagemachine 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

Page 4: A program that translates programs from assembly language to machine language.programassembly languagemachine language

[ Label ] <Opcode> <operand spec> [,<operand spec>..]

[..] Enclosed Specification is optional

Label Symbolic name with memory

<operand spec>

<symbolic name> [+<displacement>] [<index register>]

Page 5: A program that translates programs from assembly language to machine language.programassembly languagemachine language

Assembly Statements:

• Imperative Statement

• Declarative Statement

• Assembler Statement

Page 6: A program that translates programs from assembly language to machine language.programassembly languagemachine language

Imperative Statement:

• Indicates: Action to be performed during execution of an

assembly statement

• Translates: Into one Machine Instructions

Page 7: A program that translates programs from assembly language to machine language.programassembly languagemachine language

Declarative Statement:

• Syntax:

• [label] DS <constant>

[label] DC `<values>’

DS: Reserves Area of Memory and associated with them

DC: Constructs Memory words containing constants

Page 8: A program that translates programs from assembly language to machine language.programassembly languagemachine language

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

Page 9: A program that translates programs from assembly language to machine language.programassembly languagemachine language

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

Page 10: A program that translates programs from assembly language to machine language.programassembly languagemachine language

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:

Page 11: A program that translates programs from assembly language to machine language.programassembly languagemachine language

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

Page 12: A program that translates programs from assembly language to machine language.programassembly languagemachine language

• 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:

Page 13: A program that translates programs from assembly language to machine language.programassembly languagemachine language

Symbol Table:

(Fields)Name

Address

Mnemonic Table:

mnemonic

opcode

(Fields)

Page 14: A program that translates programs from assembly language to machine language.programassembly languagemachine language

Pass Structure of Assemblers:

Two Pass Translation

Single Pass Translation

Page 15: A program that translates programs from assembly language to machine language.programassembly languagemachine language

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.

Page 16: A program that translates programs from assembly language to machine language.programassembly languagemachine language

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

Page 17: A program that translates programs from assembly language to machine language.programassembly languagemachine language

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>

Page 18: A program that translates programs from assembly language to machine language.programassembly languagemachine language

<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>