Anda di halaman 1dari 122

1 MC9224 System Software Department of Computer Applications

ADHIPARASAKTHI ENGINEERING COLLEGE


OmSakthi
Melmaruvathur-603 319
2 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Outline
Basic Assembler Functions
A simpler SIC Assembler
Assembler Algorithm and Data Structures
Machine-Dependent Assembler Features
Instruction Formats and Addressing Modes
Program Location
Machine-Independent Assembler Features
Literals
Symbol-Defining Statements
Expressions
Program Blocks
Control Section and Program Linking
Assembler Design Options
One-Pass Assembler
Multi-Pass Assembler
Implementation Examples
MASM Assembler
3 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1. Basic Assembler Functions
Example Program SIC Assembler
Purpose
Reads records from input device (code F1) and store in BUFFER
Copies them to output device (code 05)
At the end of the file, writes an extra EOF on the output device,
then RSUB to the operating system
Data transfer (RD, WD)
End of each record is marked with a null character
End of the file is indicated by a zero-length record
Subroutines (JSUB, RSUB)
RDREC, WRREC
Save link register first before nested jump
4 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1. Basic Assembler Functions
5 COPY START 1000 LOAD PROG AT LOC 1000
10 FIRST STL RETADR SAVE RETURN ADDRESS
15 CLOOP JSUB RDREC READ INPUT RECORD
20 LDA LENGTH TEST FOR EOF (LENGTH = 0)
25 COMP ZERO
30 JEQ ENDFIL EXIT IF EOF FOUND
35 JSUB WRREC WRITE OUTPUT RECORD
40 J CLOOP LOOP
45 ENDFIL LDA EOF INSERT END OF FILE MARKER
50 STA BUFFER
55 LDA THREE SET LENGTH = 3
60 STA LENGTH
65 JSUB WRREC WRITE EOF
70 LDL RETADR GET RETURN ADDRESS
75 RSUB RETURN TO CALLER
80 EOF BYTE CEOF
85 THREE WORD 3
90 ZERO WORD 0
95 RETADR RESW 1
100 LENGTH RESW 1
105 BUFFER RESB 4096 4096-BYTE BUFFER AREA
5 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1. Basic Assembler Functions
110 .
115 . SUBROUTINE TO READ RECORD INTO BUFFER
120 .
125 RDREC LDX ZERO CLEAR LOOP COUNTER
130 LDA ZERO CLEAR A TO ZERO
135 RLOOP TD INPUT TEST INPUT DEVICE
140 JEQ RLOOP LOOP UNTIL READY
145 RD INPUT READ CHARACTER INTO A
150 COMP ZERO TEST FOR END OF RECORD
155 JEQ EXIT EXIT LOOP IF EOR
160 STCH BUFFER,X STORE CHAR IN BUFFER
165 TIX MAXLEN LOOP UNLESS MAX LENGTH
170 JLT RLOOP HAS BEEN REACHED
175 EXIT STX LENGTH SAVE RECORD LENGTH
180 RSUB RETURN TO CALLER
185 INPUT BYTE XF1 CODE FOR INPUT DEVICE
190 MAXLEN WORD 4096
6 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1. Basic Assembler Functions
195 .
200 . SUBROUTINE TO WRITE RECORD FROM BUFFER
205 .
210 WRREC LDX ZERO CLEAR LOOP COUNTER
215 WLOOP TD OUTPUT TEST OUTPUT DEVICE
220 JEQ WLOOP LOOP UNTIL READY
225 LDCH BUFFER,X GET CHAR FROM BUFFER
230 WD OUTPUT WRITE CHARACTER
235 TIX LENGTH LOOP UNTIL ALL CHAR
240 JLT WLOOP HAVE BEEN WRITTEN
245 RSUB RETURN TO CALLER
250 OUTPUT BYTE X05 CODE FOR OUTPUT DEVICE
255 END FIRST
7 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1. Basic Assembler Functions
Assembler Directives
Pseudo-Instructions / Basic assembler directives
Not translated into machine instructions
Providing information to the assembler
Basic assembler directives
START Specifies starting memory address of object program
END Marks the end of the program
BYTE Generate Character / Hexadecimal constant 1 byte
WORD Generate 1 word constant
RESB Reserve the indicated number of bytes for data area
RESW Reserve the indicated number of words for data area
8 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler
Mnemonic code (or instruction name) opcode
Symbolic operands (e.g., variable names) Machine
addresses
Choose the proper instruction format and addressing
mode
Constants Equivalent Internal Machine representation
Output to object files and listing files
9 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Example Program &
Object Code
Line Loc Source statement Object code
5 1000 COPY START 1000
10 1000 FIRST STL RETADR 141033
15 1003 CLOOP JSUB RDREC 482039
20 1006 LDA LENGTH 001036
25 1009 COMP ZERO 281030
30 100C JEQ ENDFIL 301015
35 100F JSUB WRREC 482061
40 1012 J CLOOP 3C1003
45 1015 ENDFIL LDA EOF 00102A
50 1018 STA BUFFER 0C1039
55 101B LDA THREE 00102D
60 101E STA LENGTH 0C1036
65 1021 JSUB WRREC 482061
70 1024 LDL RETADR 081033
75 1027 RSUB 4C0000
10 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Example Program &
Object Code
Line Loc Source statement Object code

80 102A EOF BYTE CEOF 454F46
85 102D THREE WORD 3 000003
90 1030 ZERO WORD 0 000000
95 1033 RETADR RESW 1
100 1036 LENGTH RESW 1
105 1039 BUFFER RESB 4096
11 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Example Program &
Object Code
110 .
115 . SUB TO READ RECORD INTO BUFFER
120 .
125 2039 RDREC LDX ZERO 041030
130 203C LDA ZERO 001030
135 203F RLOOP TD INPUT E0205D
140 2042 JEQ RLOOP 30203F
145 2045 RD INPUT D8205D
150 2048 COMP ZERO 281030
155 204B JEQ EXIT 302057
160 204E STCH BUFFER,X 549039
165 2051 TIX MAXLEN 2C205E
170 2054 JLT RLOOP 38203F
175 2057 EXIT STX LENGTH 101036
180 205A RSUB 4C0000
185 205D INPUT BYTE XF1 F1
190 205E MAXLEN WORD 4096 001000
12 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Example Program &
Object Code
195 .
200 . SUB TO WRITE RECORD FROM BUFFER
205 .
210 2061 WRREC LDX ZERO 041030
215 2064 WLOOP TD OUTPUT E02079
220 2067 JEQ WLOOP 302064
225 206A LDCH BUFFER,X 509039
230 206D WD OUTPUT DC2079
235 2070 TIX LENGTH 2C1036
240 2073 JLT WLOOP 382064
245 2076 RSUB 4C0000
250 2079 OUTPUT BYTE X05 05
255 END FIRST
13 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler
Mnemonic code (or instruction name) opcode
Examples:
STL 1033 14 10 33




LDA 1036 00 10 36
0001 0100 0 001 0000 0011 0011
0000 0000 0 001 0000 0011 0110
14 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Converting Symbol
to Numbers
Isnt it straightforward?
Isnt it simply the sequential processing of the source
program, one line at a time?
Not so, if we have forward references
we dont know the value of the symbol, because it is
defined later in the code Need two pass Assembler
Loc Label Operator Operand
1000 FIRST STL RETADR
1003 CLOOP JSUB RDREC

1012 J CLOOP

1033 RETADR RESW 1
15 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Symbolic Operands
We are not likely to write memory addresses
directly in our code
Instead, we will define variable names
Other examples of symbolic operands:
Labels (for jump instructions)
Subroutines
Constants
16 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Two Pass Assembler
Pass1
Scan the source program
Identify the label definitions and assign addresses
Pass2
All other assembler operations
Load and Execution

17 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Record Types
Object Program contains three Records
Header
Col. 1 H
Col. 2~7 Program name
Col. 8~13 Starting address (hex)
Col. 14-19 Length of object program in bytes (hex)
Text
Col.1 T
Col.2~7 Starting address in this record (hex)
Col. 8~9 Length of object code in this record in bytes (hex)
Col. 10~69 Object code (69-10+1)/6=10 instructions
End
Col.1 E
Col.2~7 Address of first executable instruction (hex)
18 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler Object Program
H
^
COPY
^
001000
^
00107A
T
^
001000
^
1E
^
141033
^
482039
^
001036
^
281030
^
301015
^
482061
^
3C1003
^
00102A
^
0C1039
^
00102D
T
^
00101E
^
15
^
0C1036
^
482061
^
081044
^
4C0000
^
454F46
^
000003
^
000000
T
^
002039
^
1E
^
041030
^
001030
^
E0205D
^
30203F
^
D8205D
^
281030
^
302057
^
549039
^
2C205E
^
38203F
T
^
002057
^
1C
^
101036
^
4C0000
^
F1
^
001000
^
041030
^
E02079
^
302064
^
509039
^
DC2079
^
2C1036
T
^
002073
^
07
^
382064
^
4C0000
^
05
E
^
001000 starting address

19 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.1. A Simple SIC Assembler
Pass 1
Assign addresses to all statements in the program
Save the values assigned to all labels for use in Pass 2
Perform some processing of assembler directives
Pass 2
Assemble instructions by translating opcode and symbolic
operands
Generate data values defined by BYTE, WORD
Perform processing of assembler directives not done in Pass 1
Write the object program and the assembly listing
Functions of a Two Pass Assembler
20 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
Internal Data Structures
Two Major Data structures
Operation Code Table (OPTAB)
Symbol Table (SYMTAB)
One variable - Location Counter (LOCCTR)
Pass 1 Pass 2
Intermediate
file
OPTAB SYMTAB SYMTAB
Source
program
Object
code
21 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
OPTAB (Operation Code Table)
Content
Mnemonic names, machine code (instruction format, length for
SIC/XE) etc.
Characteristic
Static table (assembler itself written)
Implementation
Array or hash table(mnemonic operation code as key), easy for
search
Usage
Pass 1 - look up and validate mnemonic operation codes in the
source program
Pass 2 translate opcodes into machine language
22 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
SYMTAB (Symbol Table)
Content
Label name, value, flag, (type, length for data
area ) etc.
Characteristic
Dynamic table (insert, delete, search)
Implementation
Hash table, non-random keys, hashing
function
Usage
Pass 1 - enter symbol names into SYMTAB
along with the assign address ( from LOCCTR)
Pass 2 look up symbols, fetch address and
insert in object code
COPY 1000
FIRST 1000
CLOOP 1003
ENDFIL 1015
EOF 1024
THREE 102D
ZERO 1030
RETADR 1033
LENGTH 1036
BUFFER 1039
RDREC 2039
23 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
Intermediate File
Pass1 and pass2 use source program as input.
Other information should be passed between two
passes.
Pass 1 writes an intermediate file
Each source statement together with its assigned address
Error indicators
Used as input for pass 2



24 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
Algorithm for Pass1 Assembler
25 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
Algorithm for Pass1 Assembler
26 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
Algorithm for Pass2 Assembler
27 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
Algorithm for Pass2 Assembler
28 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.1.2. Assembler Algorithm and Data Structures
Object Program Loading
1000
1 4 1 0 3 3
4 8 2 0 3 9
0 0 1 0 3 6
2 8 1 0 3 0
3 0 1 0 1 5
1003
1006
1009
100C
0 8 1 0 3 3
1024
4 C 0 0 0 0
1027
4 5 4 F 4 6
102A
0 0 0 0 0 3
102D
0 0 0 0 0 0
1030
STL RETADR
JSUB RDREC
LDA LENGTH
COMP ZERO
JEQ ENDFIL
LDL RETADR
RSUB
E O F
3
0
x x x x x x
1033


1036
x x x x x x
BYTE CEOF
WORD 3
WORD 0
RESW 1
RESW 1
RETADR
LENGTH
29 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2. Machine-Dependent Assembler Features
SIC/XE Assembler
We have learned the 2-pass assembler for SIC
Whats new for SIC/XE?
More addressing modes
Program relocation
30 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
SIC/XE:
PC-relative or base-relative addressing: op m
Indirect addressing: op @m
Immediate addressing: op #c
Extended format: +op m
Index addressing: op m,x
Register-to-register instructions
Larger memory multi-programming (program
allocation)
31 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
Register translation during pass 2
Register name (A, X, L, B, S, T, F, PC, SW) translated to
their ids (0,1, 2, 3, 4, 5, 6, 8, 9)
Use separate table or may be preloaded in SYMTAB
Address translation
Register-memory instructions: try PC-relative first, then
base-relative addressing
Assembler makes its own decision
User must specify extended format (format 4), otherwise error
will be generated by the assembler
Format 3: 12-bit displacement
Base-relative: 0~4095 PC-relative: -2048~2047
Format 4: 20-bit address field
32 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
Line Loc Source statement Object code
5 0000 COPY START 0
10 0000 FIRST STL RETADR 17202D
12 0003 LDB #LENGTH 69202D
13 BASE LENGTH
15 0006 CLOOP +JSUB RDREC 4B101036
20 000A LDA LENGTH 032026
25 000D COMP #0 290000
30 0010 JEQ ENDFIL 332007
35 0013 +JSUB WRREC 4B10105D
40 0017 J CLOOP 3F2FEC
45 001A ENDFIL LDA EOF 032010
50 001D STA BUFFER 0F2016
55 0020 LDA #3 010003
60 0023 STA LENGTH 0F200D
65 0026 +JSUB WRREC 4B10105D
70 002A J @RETADR 3E2003
80 002D EOF BYTE CEOF 454F46
95 0030 RETADR RESW 1
100 0033 LENGTH RESW 1
105 0036 BUFFER RESB 4096
33 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
115 . READ RECORD INTO BUFFER
120 .
125 1036 RDREC CLEAR X B410
130 1038 CLEAR A B400
132 103A CLEAR S B440
133 103C +LDT #4096 75101000
135 1040 RLOOP TD INPUT E32019
140 1043 JEQ RLOOP 332FFA
145 1046 RD INPUT DB2013
150 1049 COMPR A,S A004
155 104B JEQ EXIT 332008
160 104E STCH BUFFER,X 57C003
165 1051 TIXR T B850
170 1053 JLT RLOOP 3B2FEA
175 1056 EXIT STX LENGTH 134000
180 1059 RSUB 4F0000
185 105C INPUT BYTE XF1 F1
34 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
195 .
200 . WRITE RECORD FROM BUFFER
205 .
210 105D WRREC CLEAR X B410
12 105F LDT LENGTH 774000
215 1062 WLOOP TD OUTPUT E32011
220 1065 JEQ WLOOP 332FFA
225 1068 LDCH BUFFER,X 53C003
230 106B WD OUTPUT DF2008
235 106E TIXR T B850
240 1070 JLT WLOOP 3B2FEF
245 1073 RSUB 4F0000
250 1076 OUTPUT BYTE X05 05
255 END FIRST
35 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
10 0000 FIRST STL RETADR 17202D


Displacement= RETADRPC = 00300003 = 02D

40 0017 J CLOOP 3F2FEC



Displacement= CLOOPPC= 0006001A= 14= FEC
OPCODE e Address n i x b p
0001 01 0 (02D)
16
1 1 0 0 1
OPCODE e Address n i x b p
0011 11 0 (FEC)
16
1 1 0 0 1
PC Relative Addressing
36 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
Base Relative Addressing Mode
BASE register and directive:
12 LDB #LENGTH
13 BASE LENGTH
Base register is under the control of programmer
BASE directive tells assembler that LENGHTH is base address;
NOBASE releases the binding, until B value will be used as Base
address
160 104E STCH BUFFER, X 57C003




Displacement= BUFFERB = 00360033 = 3
Compare lines 20 and 175 (PC vs Base addressing)
OPCODE e Address n i x b p
0101 01 0 (003)
16
1 1 1 1 0
37 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
Base Relative Addressing Mode
Why cannot we use PC-relative?
Assembler knows the PC value at execution time, it cannot
be changeable
Base register is under the control of programmer, and set
initially and changeable
38 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319

55 0020 LDA #3 010003





133 103C +LDT #4096 75101000


OPCODE e Address n i x b p
0000 00 0 (003)
16
0 1 0 0 0
OPCODE e Address n i x b p
0111 01 1 (01000)
16
0 1 0 0 0
2.2.1. Instruction Formats and Addressing Modes
Immediate Address Translation
39 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
Immediate Address Translation
12 0003 LDB #LENGTH 69202D




12 0003 LDB #LENGTH 690033




The immediate operand is the value of the symbol LENGTH, which is
the address assigned to LENGTH
LENGTH=0033=PC+displacement=0006+02D
OPCODE e Address n i x b p
0110 10 0 (02D)
16
0 1 0 0 1
OPCODE e Address n i x b p
0110 10 0 (033)
16
0 1 0 0 0
40 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.1. Instruction Formats and Addressing Modes
Indirect Address Translation
Target addressing is computed as usual (PC-relative
or BASE-relative)
Only the n bit is set to 1
70 002A J @RETADR 3E2003



TA=RETADR=0030
TA=(PC)+displacement=002D+0003

OPCODE e Address n i x b p
0011 11 0 (003)
16
1 0 0 0 1
41 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2.2. Program Relocation
Need for program relocation
Example :
If program starts at 1000
55 101B LDA THREE 00102D
If program starts at 2000
55 201B LDA THREE 00202D
Some lines need not be modified (line 85, value 3)
Assembler does not know that where the program will
be loaded, but it can inform to loader via modification
records.
42 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Loaded at 0000
Loaded at 5000
Loaded at 7420
2.2.2. Program Relocation
43 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Example Fig. 2.2
Absolute program, starting address 1000
5 2000 1000 COPY START 1000
10 2000 1000 FIRST STL RETADR 141033 142033
15 2003 1003 CLOOP JSUB RDREC 482039 483039
20 2006 1006 LDA LENGTH 001036 002036
25 2009 1009 COMP ZERO 281030 282030
30 200C 100C JEQ ENDFIL 301015 302015
35 200F 100F JSUB WREC 482061 483061
40 2012 1012 J CLOOP 3C1003 3C2003
45 2015 1015 ENDFIL LDA EOF 00102A 00202A
50 2018 1018 STA BUFFER 0C1039 0C2039
55 201B 101B LDA THREE 00102D 00202D
60 201E 101E STA LENGTH 0C1036 0C2036
65 2021 1021 JSUB WREC 482061 483061
70 2024 1024 LDL RETADR 081033 082033
75 2027 1027 RSUB 4C0000 4C0000
80 202A 102A EOF BYTE C'EOF' 454E46 454E46
85 202D 102D THREE WORD 3 000003 000003
90 2030 1030 ZERO WORD 0 000000 000000
95 2033 1033 RETADR RESW 1
100 2036 1036 LENGTH RESW 1
105 2039 1039 BUFFER RESB 4096
==== 2000
==== 2000
2.2.2. Program Relocation
44 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Example Fig. 2.6:
Except for absolute address, rest of the instructions need not be modified
not a memory address (immediate addressing)
PC-relative, Base-relative
Parts requiring modification at load time are those with absolute addresses
== 1000 5 1000 0000 COPY START 0
10 1000 0000 FIRST STL RETADR 17202D 17202D
12 1003 0003 LDB #LENGTH 69202D 69202D
13 BASE LENGTH
15 1006 0006 CLOOP +JSUB RDREC 4B101036 4B102036
20 100A 000A LDA LENGTH 032026 032026
25 100D 000D COMP #0 290000 290000
30 1010 0010 JEQ ENDFIL 332007 332007
35 1013 0013 +JSUB WRREC 4B10105D 4B10205D
40 1017 0017 J CLOOP 3F2FEC 3F2FEC
45 101A 001A ENDFIL LDA EOF 032010 032010
50 101D 001D STA BUFFER 0F2016 0F2016
55 1020 0020 LDA #3 010003 010003
60 1023 0023 STA LENGTH 0F200D 0F200D
65 1026 0026 +JSUB WRREC 4B10105D 4B10205D
70 102A 002A J @RETADR 3E2003 3E2003
80 102D 002D EOF BYTE C'EOF' 454F46 454F46
95 1030 0030 RETADR RESW 1
100 1036 0036 BUFFER RESB 4096
2.2.2. Program Relocation
45 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Use relative addresses
Did you notice that we didnt modify the addresses for JEQ, JLT
and J instructions?
We didnt modify the addresses for RETADR, LENGTH, and
BUFFER in Figure 2.6 either.
The sample SIC/EX program is easier
Mostly PC or base relative
Only extended format instructions have direct addresses and
require modification
Making Program Relocation Easier
2.2.2. Program Relocation
46 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
An object program that contains information needed for
address modification for loading
Modification record
Col 1 M
Col 2-7 Starting location of the address field to be modified,
relative to the beginning of the program (count in bytes)
Col 8-9 length of the address field to be modified, in half-bytes
(address field to be modified may not occupy an integral
number of bytes, e.g. 20 bits)
Relocatable Program
2.2.2. Program Relocation
47 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Modification records are added to the object files.
(See pp.67 and Figure 2.8.)
Example:
HCOPY 001000 001077
T000000 1D 17202D4B101036
T00001D

M000007 05 Modification Record

E000000
Object File with M-Records
2.2.2. Program Relocation
48 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Modification Record
0009
3 6
1 0
1 0
4 B
2 D
0008
0007
0006
0005
+JSUB RDREC
0004
2 0
6 9
2 D
2 0
1 7
0003
0002
0001
0000
LDB #LENGTH
STL RETADR
000C
2 6
2 0
0 3
000B
000A
LDA LENGTH
M000007 05
Address 0007
5 half-bytes
2.2.2. Program Relocation
49 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Object Code
2.2.2. Program Relocation
50 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
Design idea
Let programmers write the value of a constant
operand as a part of the instruction that uses it
Avoids having to define the constant elsewhere in
the program and make up a label for it
Example (Fig. 2.10)
045 001A ENDFIL LDA =CEOF
215 1062 WLOOP TD =X05
2.3. Machine-Independent Assembler Features - Literals
51 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Example Program
5 0000 COPY START 0
10 0000 FIRST STL RETADR 17202D
13 0003 LDB #LENGTH 69202D
14 BASE LENGTH
15 0006 CLOOP +JSUB RDREC 4B101036
20 000A LDA LENGTH 032026
25 000D COMP #0 290000
30 0010 JEQ ENDFIL 332007
35 0013 +JSUB WRREC 4B10105D
40 0017 J CLOOP 3F2FEC
45 001A ENDFIL LDA =CEOF 032010
50 001D STA BUFFER 0F2016
55 0020 LDA #3 010003
60 0023 STA LENGTH 0F200D
65 0026 +JSUB WRREC 4B10105D
70 002A J @RETADR 3E2003
93 LTORG
95 0030 RETADR RESW 1
100 0033 LENGTH RESW 1
105 0036 BUFFER RESB 4096
106 1036 BUFEND EQU *
107 1000 MAXLEN EQU BUFEND - BUFFER
52 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Example Program
115 . READ RECORD INTO BUFFER
120 .
125 1036 RDREC CLEAR X B410
130 1038 CLEAR A B400
132 103A CLEAR S B440
133 103C +LDT #MAXLEN 75101000
135 1040 RLOOP TD INPUT E32019
140 1043 JEQ RLOOP 332FFA
45 1046 RD INPUT DB2013
150 1049 COMPR A,S A004
155 104B JEQ EXIT 332008
160 104E STCH BUFFER,X 57C003
165 1051 TIXR T B850
170 1053 JLT RLOOP 3B2FEA
175 1056 EXIT STX LENGTH 134000
180 1059 RSUB 4F0000
185 105C INPUT BYTE XF1 F1
53 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Example Program
195 .
200 . WRITE RECORD FROM BUFFER
205 .
210 105D WRREC CLEAR X B410
212 105F LDT LENGTH 774000
215 1062 WLOOP TD =X05 E32011
220 1065 JEQ WLOOP 332FFA
225 1068 LDCH BUFFER,X 53C003
230 106B WD =X05 DF2008
235 106E TIXR T B850
240 1070 JLT WLOOP 3B2FEF
245 1073 RSUB 4F0000
255 END FIRST
54 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.2. Machine-Independent Assembler Features - Literals
Literal vs. Immediate Operands
Immediate operands
Operand value is assembled as part of the machine
instruction
55 0020 LDA #3 010003
Literals
The assembler generates the specified value as a constant
at some other memory location
45 001A ENDFIL LDA =CEOF 032010
Compare (Fig. 2.6)
45 001A ENDFIL LDA EOF 032010
80 002D EOF BYTE CEOF 454F46
55 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Literal Implementation (1/4)
Literal pools
All the literals used in the program grouped together in to
one or more literal pools
Normally literals are placed into a pool at the end of the
program
See Fig. 2.10 (after END statement)
In some cases, it is desirable to place literals into a pool at
some other location in object program
Use assembler directive LTORG: create a literal pool that
contains all of the literal operands used since the previous
LTROG, and place it where LTORG was encountered
Reason: keep literal operand close to the instruction
56 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Example Program with Literal Implementation
5 0000 COPY START 0
10 0000 FIRST STL RETADR 17202D
13 0003 LDB #LENGTH 69202D
14 BASE LENGTH
15 0006 CLOOP +JSUB RDREC 4B101036
20 000A LDA LENGTH 032026
25 000D COMP #0 290000
30 0010 JEQ ENDFIL 332007
35 0013 +JSUB WRREC 4B10105D
40 0017 J CLOOP 3F2FEC
45 001A ENDFIL LDA =CEOF 032010
50 001D STA BUFFER 0F2016
55 0020 LDA #3 010003
60 0023 STA LENGTH 0F200D
65 0026 +JSUB WRREC 4B10105D
70 002A J @RETADR 3E2003
93 LTORG
002D * =CEOF 454F46
95 0030 RETADR RESW 1
100 0033 LENGTH RESW 1
105 0036 BUFFER RESB 4096
106 1036 BUFEND EQU *
107 1000 MAXLEN EQU BUFEND - BUFFER
57 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
115 . READ RECORD INTO BUFFER
120 .
125 1036 RDREC CLEAR X B410
130 1038 CLEAR A B400
132 103A CLEAR S B440
133 103C +LDT #MAXLEN 75101000
135 1040 RLOOP TD INPUT E32019
140 1043 JEQ RLOOP 332FFA
145 1046 RD INPUT DB2013
150 1049 COMPR A,S A004
155 104B JEQ EXIT 332008
160 104E STCH BUFFER,X 57C003
165 1051 TIXR T B850
170 1053 JLT RLOOP 3B2FEA
175 1056 EXIT STX LENGTH 134000
180 1059 RSUB 4F0000
185 105C INPUT BYTE XF1 F1
Example Program with Literal Implementation
58 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Example Program with Literal Implementation
195 .
200 . WRITE RECORD FROM BUFFER
205 .
210 105D WRREC CLEAR X B410
212 105F LDT LENGTH 774000
215 1062 WLOOP TD =X05 E32011
220 1065 JEQ WLOOP 332FFA
225 1068 LDCH BUFFER,X 53C003
230 106B WD =X05 DF2008
235 106E TIXR T B850
240 1070 JLT WLOOP 3B2FEF
245 1073 RSUB 4F0000
255 END FIRST
1076 * =X05 05
59 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Duplicate literals
215 1062 WLOOP TD =X05
230 106B WD =X05
Assembler should recognize duplicate literals and
store only one copy of specified data value
By comparing defining character string, e.g. =X05
By comparing the generated data value, e.g. =CEOF and
=X454F46, but benefits are usually not great enough to
justify the additional complexity in the assembler
Literal Implementation (2/4)
60 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Literal Implementation (3/4) Problem of duplicate literal
recognition
'*' denotes a literal refer to the current value of
location counter.
Some have same name, but different values.
BASE *
LDB =*
If the literal value represents an 'address' in the
program, the assembler must also generate the
appropriate 'Modification records'
61 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3. Machine-Independent Assembler Features - Literals
Literal Implementation (4/4)
Use LITTAB:
Literal name, operand value & length, operand address
Pass 1
Build LITTAB with literal name, operand value/length
When LTORG is encountered, assign address to each literal not yet
assigned an address, update LOCCTR
Pass 2
Search LITTAB for each literal encountered and generate the
operand address
Data values of literals in literal pool are generated similarly as using
BYTE or WORD statements
Generate modification record for literals that represent an address
in the program
62 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.2. Machine-Independent Assembler Features Symbol Defining
statement
Users can define labels on instructions or data areas
The value of a label is the address assigned to the statement
Users can also define symbols with values
symbol EQU value
value can be constants, other symbols, expressions
Making source program easier to understand
No forward reference
63 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.2. Machine-Independent Assembler Features Symbol Defining
statement
Example 1: replacing symbolic names
133 LDT #4096
replaced as
MAXLEN EQU 4096
133 +LDT #MAXLEN
Example 2: defining mnemonic names for registers
A EQU 0
X EQU 1

RMO A,X
can be replaced as

RMO 0,1
64 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.2. Machine-Independent Assembler Features Symbol Defining
statement
Example 3: defining registers with symbolic namesv(SIC)
BASE EQU R1
COUNT EQU R2
INDEX EQU R3
To represent registers 1,2,3

65 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.2. Machine-Independent Assembler Features Symbol Defining
statement
Assembler directive ORG
Allow the assembler to reset the PC to values.
ORG values
Use to indirectly assign values to symbols
When ORG is encountered, the assembler resets its
LOCCTR to the specified value
ORG will affect the values of all labels defined until the
next ORG.
If the previous value of LOCCTR can be automatically
remembered, we can return to the normal use of
LOCCTR by simply write ORG
66 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.2. Machine-Independent Assembler Features Symbol Defining
statement
In the data structure
Symbol :6 bytes
Value :3 bytes
Flags :2 bytes

If EQU statements are used
STAB RESB 1100
SYMBOL EQU STAB
VALUE EQU STAB+6
FLAG EQU STAB+9
Symbol table structure to support ORG
Symbol Value Flags
STAB
(100 entries)
: : :
67 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.2. Machine-Independent Assembler Features Symbol Defining
statement
If ORG statements are used
STAB RESB 1100
ORG STAB Set LOCCTR to STAB
SYMBOL RESB 6
VALUE RESW 1 Size of each field
FLAGS RESB 2
ORG STAB +1100 Restore LOCCTR
VALUE field fetched by
LDA VALUE,X
68 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.2. Machine-Independent Assembler Features Symbol Defining
statement
All symbols used in the right hand side must be defined
previously in the program
ALPHA RESW 1
BETA EQU ALPHA

BETA EQU ALPHA
ALPHA RESW 1

ALPHA EQU BETA
BETA EQU DELTA
DELTA RESW 1

Restriction with EQU
Valid
Invalid
Invalid
69 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.2. Machine-Independent Assembler Features Symbol Defining
statement
All symbols used to specify the new location counter
value must have been previously defined

ORG ALPHA
BYTE1 RESB 1
BYTE2 RESB 2
BYTE3 RESB 3
ORG
ALPHA RESB 1

Restriction with ORG
Invalid
70 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.3. Machine-Independent Assembler Features Expressions
Assemblers allow the use of expressions as operand
The assembler calculates the expressions and produce a single
operand address or value.
Operator +,-,*,/
Division is usually defined to produce an integer result
Expressions may be constants, user-defined symbols or special
terms.
106 1036 BUFFEND EQU *
Gives BUFFEND a value that is the address of the next byte after
the buffer area
Examples
MAXLEN EQU BUFEND-BUFFER
STAB RESB (6+3+2)*MAXENTRIES

71 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.3. Machine-Independent Assembler Features Expressions
Values of terms can be
Absolute (independent of program location)
Constants
Relative (to the beginning of the program)
Address labels
* (value of LOCCTR)


72 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.3. Machine-Independent Assembler Features Expressions
Expressions can be
Absolute
Only absolute terms
Relative terms in pairs with opposite signs for each pair.
Relative
All the relative terms except one can be paired as described in
absolute.
The remaining unpaired relative term must have a positive
sign.
No relative terms may enter into a multiplication or division
operation
Expressions that do not meet the conditions of either
absolute or relative should be flagged as errors.
73 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.3. Machine-Independent Assembler Features Expressions
Assembler needs to track type of an
expression, to generate Modification
records if needed
Need a flag in the SYMTAB for
indication
Absolute value
BUFFEND BUFFER

Illegal
BUFFEND + BUFFER
100 BUFFER
3* BUFFER

Handling relative terms in SYMTAB
Symbol Type Flag
RETADR R 0030
BUFFER R 0036
BUFEND R 1036
MAXLEN A 1000
74 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
Allow the generated machine instructions and data to
appear in the object program in a different order
Gather all code segments, data segments and stack segments
Program blocks vs. Control sections
Program blocks
Segments of code that are rearranged within a single object
program unit
Control section
Segments of code that are translated into independent object
program units
75 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
Assembler directive : USE
USE [blockname]
At the beginning, statements are assumed to be part of the unnamed
(default) block
If no USE statements are included, the entire program belongs to this
single block
Each program block may actually contain several separate segments of
the source program
Assembler rearrange these segments to gather together the pieces of
each block and assign address
Separate the program into blocks in a particular order
Large buffer area is moved to the end of the object program
Program readability is better if data areas are placed in the source
program close to the statements that reference them
76 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
Three blocks are used
default: executable instructions
CDATA: all data areas that are less in length
CBLKS: all data areas that consists of larger
blocks of memory
77 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
Line Source statement Object Code
5 0000 0 COPY START 0
10 0000 0 FIRST STL RETADR 17202D
15 0003 0 CLOOP JSUB RDREC 4B2021
20 0006 0 LDA LENGTH 032026
25 0009 0 COMP #0 290000
30 000C 0 JEQ ENDFIL 332006
35 000F 0 JSUB WRREC 4B203B
40 0012 0 J CLOOP 3F2FEE
45 0015 0 ENDFIL LDA =CEOF 032055
50 0018 0 STA BUFFER 0F2056
55 001B 0 LDA #3 010003
60 001E 0 STA LENGTH 0F2048
65 0021 0 JSUB WRREC 4B2029
70 0024 0 J @RETADR 3E203F
92 0000 1 USE CDATA
95 0000 1 RETADR RESW 1
100 0003 1 LENGTH RESW 1
103 0000 2 USE CBLKS
105 0000 2 BUFFER RESB 4096
106 1000 2 BUFEND EQU *
107 1000 MAXLEN EQU BUFEND - BUFFER
(Figure 2.11)
78 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
115 . READ RECORD INTO BUFFER
120 .
123 0027 0 USE
125 0027 0 RDREC CLEAR X B410
30 0029 0 CLEAR A B400
132 002B 0 CLEAR S B440
133 002D 0 +LDT #MAXLEN 75101000
135 0031 0 RLOOP TD INPUT E32038
140 0034 0 JEQ RLOOP 332FFA
145 0037 0 RD INPUT DB2032
150 003A 0 COMPR A,S A004
155 003C 0 JEQ EXIT 332008
160 003F 0 STCH BUFFER,X 57A02F
165 0042 0 TIXR T B850
170 0044 0 JLT RLOOP 3B2FEA
175 0047 0 EXIT STX LENGTH 13201F
180 004A 0 RSUB 4F0000
183 0006 1 USE CDATA
185 0006 1 INPUT BYTE XF1 F1
79 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
195 .
200 . WRITE RECORD FROM BUFFER
205 .
208 004D 0 USE
210 004D 0 WRREC CLEAR X B410
212 004F 0 LDT LENGTH 772017
215 0052 0 WLOOP TD =X05 E3201B
220 0055 0 JEQ WLOOP 332FFA
225 0058 0 LDCH BUFFER,X 53A016
230 005B 0 WD =X05 DF2012
235 005E 0 TIXR T B850
240 0060 0 JLT WLOOP 3B2FEF
245 0063 0 RSUB 4F0000
252 0007 1 USE CDATA
253 LTORG
0007 1 * =CEOF 454F46
000A 1 * =X05 05
255 END FIRST
80 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
Pass 1
A separate location counter for each program block
Save and restore LOCCTR when switch between blocks
At the beginning of a block, LOCCTR is set to 0.
Assign each label an address relative to the start of the block
Store the block name or number in the SYMTAB along with the assigned
relative address of the label
Indicate the block length as the latest value of LOCCTR for each block
at the end of Passssss1
Assign to each block a starting address in the object program by
concatenating the program blocks in a particular order
Pass 2
The address of each symbol can be computed by adding the assigned
block starting address and the relative address of the symbol to that
block
81 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
Line Loc/Block Source statement Object Code
5 0000 0 COPY START 0
10 0000 0 FIRST STL RETADR 17202D
15 0003 0 CLOOP JSUB RDREC 4B2021
20 0006 0 LDA LENGTH 032026
25 0009 0 COMP #0 290000
30 000C 0 JEQ ENDFIL 332006
35 000F 0 JSUB WRREC 4B203B
40 0012 0 J CLOOP 3F2FEE
45 0015 0 ENDFIL LDA =CEOF 032055
50 0018 0 STA BUFFER 0F2056
55 001B 0 LDA #3 010003
60 001E 0 STA LENGTH 0F2048
65 0021 0 JSUB WRREC 4B2029
70 0024 0 J @RETADR 3E203F
92 0000 1 USE CDATA
95 0000 1 RETADR RESW 1
100 0003 1 LENGTH RESW 1
103 0000 2 USE CBLKS
105 0000 2 BUFFER RESB 4096
106 1000 2 BUFEND EQU *
107 1000 MAXLEN EQU BUFEND - BUFFER
(Figure 2.12)
3 blocks:
Default (0)
CDATA (1)
CBLKS (2)
82 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
115 . READ RECORD INTO BUFFER
120 .
123 0027 0 USE
125 0027 0 RDREC CLEAR X B410
30 0029 0 CLEAR A B400
132 002B 0 CLEAR S B440
133 002D 0 +LDT #MAXLEN 75101000
135 0031 0 RLOOP TD INPUT E32038
140 0034 0 JEQ RLOOP 332FFA
145 0037 0 RD INPUT DB2032
150 003A 0 COMPR A,S A004
155 003C 0 JEQ EXIT 332008
160 003F 0 STCH BUFFER,X 57A02F
165 0042 0 TIXR T B850
170 0044 0 JLT RLOOP 3B2FEA
175 0047 0 EXIT STX LENGTH 13201F
180 004A 0 RSUB 4F0000
183 0006 1 USE CDATA
185 0006 1 INPUT BYTE XF1 F1
83 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
195 .
200 . WRITE RECORD FROM BUFFER
205 .
208 004D 0 USE
210 004D 0 WRREC CLEAR X B410
212 004F 0 LDT LENGTH 772017
215 0052 0 WLOOP TD =X05 E3201B
220 0055 0 JEQ WLOOP 332FFA
225 0058 0 LDCH BUFFER,X 53A016
230 005B 0 WD =X05 DF2012
235 005E 0 TIXR T B850
240 0060 0 JLT WLOOP 3B2FEF
245 0063 0 RSUB 4F0000
252 0007 1 USE CDATA
253 LTORG
0007 1 * =CEOF 454F46
000A 1 * =X05 05
255 END FIRST
84 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
At the end of pass1, assembler constructs a tab
Each source line is given a relative address and a block
number



Absolute symbol has no block number (line 107)
20 0006 0 LDA LENGTH 032060
LENGTH = (Block 1) + 0003 = 0066 + 0003 = 0069
LOCCTR = (Block 0) + 0009 = 0009
Displacement = 0069 0009 = 060
Block Name Block Number Address Length
(default) 0 0000 066
CDATA 1 0066 000B
CBLKS 2 0071 1000
85 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
Program readability
No extended format instructions (lines 15, 35, 65)
No need for base relative addressing (line 13, 14)
LTORG is used to make sure the literals are placed
ahead of any large data areas (line 253)
Object code
It is not necessary to physically rearrange the
generated code in the object program; loader can
handle it
See Fig. 2.13, Fig. 2.14
86 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
CDATA
87 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.4. Machine-Independent Assembler Features Program Blocks
88 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
Control sections
Most often used for subroutines or other logical
subdivisions of a program
Programmer can assemble, manipulate, and load
each of these control sections separately
Instructions in one control section may need to refer
to instructions or data in another section
Thus, there should be some means for linking control
sections together
Fig. 2.15, 2.16: three control sections (COPY, RDREC,
WRREC)
89 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
(Figure 2.16)
90 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
91 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
92 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
External definition
EXTDEF name [, name]
Declare symbols that are defined in this control section and used by
other sections
External reference
EXTREF name [,name]
Declare symbols that are used in this control section and are defined
elsewhere
For EXTREF labels, assembler has no idea where the corresponding
control section will be loaded use 0
15 0003 CLOOP +JSUB RDREC 4B100000
160 0017 +STCH BUFFER,X 57900000
190 0028 MAXLEN WORD BUFEND-BUFFER 000000
External Definition and References
93 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
Assembler must include information in object program that will
cause loader to insert proper values where required
Define record
Col. 1 D
Col. 2-7 Name of external symbol defined in this control
section
Col. 8-13 Relative address within this control section (hex)
Col.14-73 Repeat info in Col. 2-13 for other external symbols
Refer record
Col. 1 R
Col. 2-7 Name of external symbol referred to in this section
Col. 8-73 Name of other external reference symbols
Implementation
94 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
Modification record
Col. 1 M
Col. 2-7 Starting address of the field to be modified (hex)
Col. 8-9 Length of the field to be modified, in half-bytes (hex)
Col.11-16 External symbol whose value is to be added to or subtracted
from the indicated field
Note: control section name is automatically an external symbol, i.e. it is
available for use in Modification records.
Example
Figure 2.17
M00000405+RDREC
M00000705+COPY

Modification Record
95 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
H COPY 000000 001033
D BUFFER 00033 BUFEND 001033 LENGTH 00002D
R RDREC WRREC
T 000000 1D 172027 4B100000 032023 290000 332007 4B100000 ...
T 00001D 0D 010003 0F200A 4B10000 3E2000
T 000030 03 454F46
M 000004 05+RDREC
M 000011 05+WRREC
M 000024 05+WRREC
E 000000
Figure 2.17 (1/2)
96 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
H RDREC 000000 00002B
R BUFFER LENGTH BUFEND
T 000000 1D B410 B400 B440 77201F E3201B 332FFA DB2015 ...
T 00001D 0E 3B2FE9 13100000 4F0000 F1 000000
M 000018 05+BUFFER
M 000021 05+LENGTH
M 000028 06+BUFEND
M 000028 06-BUFFER
E

H WRREC 000000 00001C
R LENGTH BUFFER
T 000000 1C B410 77100000 E32012 332FFA 53900000 DF2008 ...
M 000003 05+LENGTH
M 00000D 05+BUFFER
E
Figure 2.17 (2/2)
190 MAXLEN WORD BUFEND - BUFFER
97 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.3.5. Machine-Independent Assembler Features Control section
and Program Linking
Earlier definitions
Required all of the relative terms be paired in an expression (an
absolute expression), or that all except one be paired (a relative
expression)
New restriction
Both terms in each pair must be relative within the same control
section
Ex: BUFEND-BUFFER
Ex: RDREC-COPY
In general, assembler cannot determine whether or not the
expression is legal at assembly time. This work will be handled
by a linking loader.
External Reference in Expressions
98 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Main problem
Forward references
Data items
Labels on instructions
Solution
Data items: require all such areas be defined
before they are referenced
Labels on instructions: no good solution
99 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Two types of one-pass assembler
Type 1: Load-and-go
Produces object code directly in memory for
immediate execution
Type 2:
Produces usual kind of object code for later
execution
100 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Characteristics
Useful for program development and testing
Avoids the overhead of writing the object program
out and reading it back
Both one-pass and two-pass assemblers can be
designed as load-and-go
However one-pass also avoids the overhead of an
additional pass over the source program
For a load-and-go assembler, the actual address
must be known at assembly time, we can use an
absolute program
Load-and-Go Assembler
101 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Load-and-Go Assembler
Assembler operations:
1. Omit address translation for any undefined symbol
2. Insert the symbol into SYMTAB, mark it undefined
3. The address that refers to the undefined symbol is
added to a list of forward references associated with
the symbol table entry
4. When the definition for a symbol is encountered, the
proper address for the symbol is then inserted into
any instructions previously generated according to
the forward reference list
102 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Load-and-Go Assembler
At the end of the program
Any SYMTAB entries that are still marked with *
indicate undefined symbols
Search SYMTAB for the symbol named in the END
statement and jump to this location to begin
execution
The actual starting address must be specified at
assembly time
103 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Program for one pass assembler Fig 2.18
Line Loc Source statement Object code
0 1000 COPY START 1000
1 1000 EOF BYTE CEOF 454F46
2 1003 THREE WORD 3 000003
3 1006 ZERO WORD 0 000000
4 1009 RETADR RESW 1
5 100C LENGTH RESW 1
6 100F BUFFER RESB 4096
10 200F FIRST STL RETADR 141009
15 2012 CLOOP JSUB RDREC 48203D
20 2015 LDA LENGTH 00100C
25 2018 COMP ZERO 281006
30 201B JEQ ENDFIL 302024
35 201E JSUB WRREC 482062
40 2021 J CLOOP 3C2012
45 2024 ENDFIL LDA EOF 001000
50 2027 STA BUFFER 0C100F
55 202A LDA THREE 001003
60 202D STA LENGTH 0C100C
65 2030 JSUB WRREC 482062
70 2033 LDL RETADR 081009
75 2036 RSUB 4C0000
104 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Program for one pass assembler Fig 2.19(a) Before Line 40
Memory
Address Contents

1000 454F4600 00030000 00xxxxxx xxxxxxxx
1010 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
.
.
2000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxx14
2010 100948-- --00100C 28100630 ----48--
2020 --3C2012
.
.
Address unknown yet
105 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Program for one pass assembler Fig 2.19(a) - SYMTAB
LENGTH 100C
RDREC *
THREE 1003
ZERO 1006
WRREC *
EOF 1000
ENDFIL *
RETADR 1009
BUFFER 100F
CLOOP 2012
FIRST 200F
... ...
Symbol Value
2013

201F

201C

106 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Program for one pass assembler Fig 2.19(a) After Line 45
Memory
Address Contents

1000 454F4600 00030000 00xxxxxx xxxxxxxx
1010 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
.
.
2000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxx14
2010 100948-- --00100C 28100630 202448--
2020 --3C2012 001000
.
.
107 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Program for one pass assembler Fig 2.19(a) - SYMTAB
LENGTH 100C
RDREC *
THREE 1003
ZERO 1006
WRREC *
EOF 1000
ENDFIL 2024
RETADR 1009
BUFFER 100F
CLOOP 2012
FIRST 200F
... ...
Symbol Value
2013

201F

108 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Program for one pass assembler Fig 2.18
110 .
115 . SUB TO READ RECORD INTO BUFFER
120 .
121 2039 INPUT BYTE XF1 F1
122 203A MAXLEN WORD 4096 001000
124 .
125 203D RDREC LDX ZERO 041006
130 2040 LDA ZERO 001009
135 2043 RLOOP TD INPUT E02039
140 2046 JEQ RLOOP 302043
145 2049 RD INPUT D82039
150 204C COMP ZERO 281006
155 204F JEQ EXIT 30205B
160 2052 STCH BUFFER,X 54900F
165 2055 TIX MAXLEN 2C203A
170 2058 JLT RLOOP 382043
175 205B EXIT STX LENGTH 10100C
180 205E RSUB 4C0000
109 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Program for one pass assembler Fig 2.19 (b) After Line 160
Memory
Address Contents

1000 454F4600 00030000 00xxxxxx xxxxxxxx
1010 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
.
2000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxx14
2010 10094820 3D00100C 28100630 202448--
2020 --3C2012 0010000C 100F0010 030C100C
2030 48----08 10094C00 00F10010 00041006
2040 001006E0 20393020 43DB2039 28100630
2050 ----5490 0F
.
110 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
LENGTH 100C
RDREC
203D
THREE 1003
ZERO 1006
WRREC *
EOF 1000
ENDFIL 2024
RETADR 1009
BUFFER 100F
CLOOP 2012
FIRST 200F
MAXLEN 203A
INPUT 2039
EXIT *
RLOOP 2043
... ...
201F
2031

2050

Program for one pass assembler Fig 2.19 (b) After Line 160
111 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Program for one pass assembler Fig 2.18
195 .
200 . SUB TO WRITE RECORD FROM BUFFER
205 .
206 2061 OUTPUT BYTE X05 05
207 .
210 2062 WRREC LDX ZERO 041006
215 2065 WLOOP TD OUTPUT E02061
220 2068 JEQ WLOOP 302065
225 206B LDCH BUFFER,X 50900F
230 206E WD OUTPUT DC2061
235 2071 TIX LENGTH 2C100C
240 2074 JLT WLOOP 382065
245 2077 RSUB 4C0000
255 END FIRST
112 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Type 2 Assembler
Will produce object code
Assembler operations:
Forward references are entered into list as before
Instruction referencing are written into object file as a Text
record, even with incorrect addresses
When definition of a symbol is encountered, assembler must
generate another Text record with the correct operand
address
Loader is used to insert correct addresses into instructions
with forward references that could not be handled by the
assembler
Object program records must be kept in original order when
they are presented to the loader
113 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Type 2 Assembler Fig 2.20 (Partial)
H COPY 001000 00107A
T 001000 09 454F46 000003 000000
T 00200F 15 141009 480000 00100C 281006 300000 480000 3C2012
T 00201C 02 2024
T 002024 19 001000 0C100F 001003 0C100C 480000 081009 4C0000
T 002013 02 203D

E 00200F
114 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4. 1 Assembler Design Options One Pass Assembler
Type 2 Assembler Fig. 2.20
115 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4.2 Assembler Design Options Multi Pass Assembler
Restriction on EQU and ORG
No forward reference, since symbols value cant be
defined during the first pass
Example:
ALPHA EQU BETA
BETA EQU DELTA
DELTA RESW 1
Assemblers with 2 passes cannot resolve
116 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4.2 Assembler Design Options Multi Pass Assembler
Resolve forward references with as many
passes as needed
Portions that involve forward references in symbol
definition are saved during Pass 1
Additional passes through stored definitions
Finally a normal Pass 2
Example implementation:
Use link lists to keep track of whose value depend
on an undefined symbol
117 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4.2 Assembler Design Options Multi Pass Assembler
1 HALFSZ EQU MAXLEN/2
2 MAXLEN EQU BUFEND-BUFFER
3 PREVBT EQU BUFFER-1
...
4 BUFFER RESB 4096
5 BUFEND EQU *
HALFSZ &1 MAXLEN/2
MAXLEN *
1 symbol undefined
HALFSZ

Fig. 2.21 (a) After Pass 1
118 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4.2 Assembler Design Options Multi Pass Assembler
1 HALFSZ EQU MAXLEN/2
2 MAXLEN EQU BUFEND-BUFFER
3 PREVBT EQU BUFFER-1
...
4 BUFFER RESB 4096
5 BUFEND EQU *
BUFEND *
HALFSZ &1 MAXLEN/2
MAXLEN &2 BUFEND-
BUFFER
BUFFER * MAXLEN

MAXLEN

HALFSZ

Fig. 2.21 (c) MAXLEN defined
119 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4.2 Assembler Design Options Multi Pass Assembler
1 HALFSZ EQU MAXLEN/2
2 MAXLEN EQU BUFEND-BUFFER
3 PREVBT EQU BUFFER-1
...
4 BUFFER RESB 4096
5 BUFEND EQU *
BUFEND *
HALFSZ &1 MAXLEN/2
MAXLEN &2 BUFEND-
BUFFER
BUFFER * MAXLEN

MAXLEN

HALFSZ

Fig. 2.21 (c) MAXLEN defined
120 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4.2 Assembler Design Options Multi Pass Assembler
Fig. 2.21 (d) PERVBT defined
1 HALFSZ EQU MAXLEN/2
2 MAXLEN EQU BUFEND-BUFFER
3 PREVBT EQU BUFFER-1
...
4 BUFFER RESB 4096
5 BUFEND EQU *
BUFEND *
HLFSZ &1 MAXLEN/2
PREVBT &1 BUFFER-1
MAXLEN &2 BUFEND-
BUFFER
BUFFER *
MAXLEN

PREVBT

HALFSZ

MAXLEN
121 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4.2 Assembler Design Options Multi Pass Assembler
Fig. 2.21 (e) After Line 4
1 HALFSZ EQU MAXLEN/2
2 MAXLEN EQU BUFEND-BUFFER
3 PREVBT EQU BUFFER-1
...
4 BUFFER RESB 4096
5 BUFEND EQU *
BUFEND *
HLFSZ &1 MAXLEN/2
PREVBT 1033
MAXLEN &1 BUFEND-
BUFFER
BUFFER 1034
MAXLEN

Assume
loc=1034
HALFSZ

122 MC9224- System Software Department of Computer Applications
ADHIPARASAKTHI ENGINEERING COLLEGE
OmSakthi
Melmaruvathur-603 319
2.4.2 Assembler Design Options Multi Pass Assembler
Fig. 2.21 (f) After Line 5
1 HALFSZ EQU MAXLEN/2
2 MAXLEN EQU BUFEND-BUFFER
3 PREVBT EQU BUFFER-1
...
4 BUFFER RESB 4096
5 BUFEND EQU *
BUFEND 2034
HLFSZ 800
PREVBT 1033
MAXLEN 1000
BUFFER 1034

Anda mungkin juga menyukai