0% found this document useful (0 votes)
6 views19 pages

2 Pass Assembler

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views19 pages

2 Pass Assembler

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

2 Pass Assemblers

Low Level Assembly Language


High Level Programming Languages
(Device Drivers / Embedded Systems /
Python / C ++
Real-time systems
print("Hello World")
e.g. STR 5

Interpreter / Compiler Assembler

Executable Machine Code

Executable by the CPU / Different for every machine

0100 01101001
2 Pass Assembler Process
Symbol Table
Variables / Labels

Literal Table
Constants

Assembly Pass 1 Pass 2 Object Executable


Linker
Code Analysis Synthesis Code Machine Code

Opcode Table At Run Time


opcode → binary

Executable Loader
Pass 1 - Analysis
This part scans the program looking for symbols, labels, variables, etc and
organises them in tables

● Passes through the instructions in sequence, looking for symbol addresses


● Create a symbol and literal table
● Keep track of the location counter
● Process Pseudo operations(macros / directives?)
● Error Checking

Macros Directives
Names subroutines can can be used Configuration instructions for
more than once. Designed to make assembler (such as memory allocation)
programming easier and more module Not a program instruction itself.
ORG #100

BeginProg LDV #countUp Labels


OUTCH
These are used to by the programmer to refer to
CMP NumA
specific lines in the code, rather than to referring
JMP Finish to them by a line number.
JNE MoveOn
This makes the program easier to read for
MoveOn LDD countUp humans as is allows the code to be broken down
INC into sections
STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100

BeginProg LDV #countUp Labels


OUTCH
These are used to by the programmer to refer to
CMP NumA
specific lines in the code, rather than to referring
JMP Finish to them by a line number.
JNE MoveOn
This makes the program easier to read for
MoveOn LDD countUp humans as is allows the code to be broken down
INC into sections
STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
Pass 1 Analysis
walkthrough
ORG #100
Symbol Table
BeginProg LDV #countUp

OUTCH

CMP NumA

JMP Finish

JNE MoveOn

MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH

CMP NumA

JMP Finish

JNE MoveOn

MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH
countUp

CMP NumA

JMP Finish

JNE MoveOn

MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH
countUp

CMP NumA
NumA
JMP Finish

JNE MoveOn

MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH
countUp

CMP NumA
NumA
JMP Finish
Finish
JNE MoveOn

MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH
countUp

CMP NumA
NumA
JMP Finish
Finish
JNE MoveOn
MoveOn
MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH
countUp

CMP NumA
NumA
JMP Finish
Finish
JNE MoveOn
MoveOn 105
MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH
countUp

CMP NumA
NumA
JMP Finish
Finish 109
JNE MoveOn
MoveOn 105
MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH
countUp 111

CMP NumA NumA

JMP Finish
Finish 109

JNE MoveOn MoveOn 105

MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
ORG #100
Symbol Table
BeginProg LDV #countUp
BeginProg 100

OUTCH
countUp 111

CMP NumA NumA 114

JMP Finish Finish 109

JNE MoveOn MoveOn 105

MoveOn LDD countUp

INC

STO countUp

JMP BeginProg

Finish LDM #25

END

countUp 200

21

35

NumA 20
Pass 2
If no errors are found in pass one then the second pass assembles the code into
object code.

This process often includes:

● Symbolic addresses are replaced with absolute addresses


● Symbolic opcodes are replace with binary opcodes
2 Pass Assembly Process
Symbol Table
Variables / Labels

Literal Table
Constants

Assembly Pass 1 Pass 2 Object Executable


Linker
Code Analysis Synthesis Code Machine Code

Opcode Table At Run Time


opcode → binary

Executable Loader

You might also like