Вы находитесь на странице: 1из 10

Chapter 4

ASSEMBLER
Elements of Assembly
Language Programming
Assembly Language: Assembly Language is a machine dependent, low level
programming language which is specific to certain computer system.

Features that simplify programming:


qMnemonic Operation Codes(Opcodes)
Ex: MOVER or MOVEM

qSymbolic Operand:
Ex: DS – Declare as storage
DC – Declare as Constant

qData Declaration:
Ex: X DC ‘-10.5’

Statement Format:
[label] <opcode> <operand spec> [< operand spec >,…..]

01/26/10 Chapter 4: Assembler 2


A Simple Assembly
Language
 Possible Operand Forms:
 AREA – Refers to memory word with which the name is
associated.
 AREA + 5 – Refers to memory word 5 words away from
AREA.
 AREA(4) – Indexing with index register 4.
 AREA + 5(4) – By combining above two.

 Each statement has 2 operands, the first operand is always a register


(AREG, BREG, CREG & DREG). The second operand refers to a
memory word using a sysmbolicname & an optional
displacement.

01/26/10 Chapter 4: Assembler 3


Instruction Format:

Sign Opcode Reg Memory Operand

Ex: Page 88, Fig 4.3

Assembly Language Statements:


1.Imperative statements
Ex: ADD BREG, ONE

1.Declarative statements
Ex: [Label] DS <constant> [Label] DC ‘<value>’
DS (Declare as Storage): Allots memory word of block value same as tha
of the constant mentioned in the statement.
DC (Declare as constant): Constructs memory word containing the value.

Use of constants: Immediate operands and Literals

1.Assembler directives
Ex: Start <constant>

01/26/10 Chapter 4: Assembler 4


A Simple Assembly
scheme
Steps to develop a design specification for an assembler
1. Identify the information necessary to perform a task.
2. Design a suitable data structure to record the information.
3. Determine the processing necessary to obtain and maintain the
information.
4. Determine the processing necessary to perform the task.
Analysis & Synthesis Phase:


Mnemonic Table
Mnemonic Opcode Length

ADD 01 1
SUB 02 1

Source Target
Program
Analysis Phase Synthesis Phase Program

Symbol Address
N 113 Data Access
01/26/10 Chapter 4: Assembler Control Transfer5
Symbol Table
Mnemonics Table is a fixed table which is merely accessed by the analysis and
synthesis phases, while the Symbol table is constructed during analysis and
used during synthesis

Analysis Phase Synthesis Phase

01/26/10 Chapter 4: Assembler 6


Pass Structure of
Assembler
Start

Initialize Data Structures


E
Read Next Statement

Yes
Label Present ? Enter (Lable, LC) in SYMTAB

No

Search in OPTAB

01/26/10 Chapter 4: Assembler 7


Yes
M/C Instruction ?

LC = LC + Length No

No
No DC/DS ?
Literal Used ?
Type of Directive
Yes
Yes
LTORG ORIGIN END
Calculate Storage Size
Enter into LITTAB

Allocate literals update Evaluate


LITTAB POOLTAB
operand
Correct
ADD
SYMTAB E

A
01/26/10 Chapter 4: Assembler
B C D 8
E A B C D

Yes
END ?

No
Go to Pass II
Update LC

Generate Intermediate Code

01/26/10 Chapter 4: Assembler 9


Pass II Structure of
Assembler
Start

Initialize target code area/file set END FLAG=OFF

Read Next Statement

Search in OPTAB

Yes
M/C Instruction ?

No
A
B
01/26/10 Chapter 4: Assembler 10

Вам также может понравиться