Professional Documents
Culture Documents
System Software ch2 Slides
System Software ch2 Slides
Assemblers
http://www.intel.com/multi-core/demos.htm
Source
Program
Assembler
Object
Code
Linker
Executable
Code
Loader
Outline
Two-pass
One-pass
Multi-pass
2
RDREC, WRREC
Save link (L) register first before nested jump
8
Translation functions
10
11
12
A forward reference
10
1000 FIRST STL
RETADR
141033
A reference to a label (RETADR) that is defined later in
the program
Most assemblers make two passes over the source
program
Forward reference
STCH
BUFFER, X
8
opcode
(54)16
1
x
1 (001)2
15
address
m
549039
(039)16
14
Forward reference
Label
OP Code
Operand
1000
FIRST
STL
RETADR
1003
1012
1033
CLOOP
JSUB
RESW
RDREC
CLOOP
RETADR
15
16
17
Figure 2.3
1E(H)=30(D)=16(D)+14(D)
18
Assemblers Functions
STL to 14
RETADR to 1033
19
Pass 2
LDA00, STL14,
COPY1000, FIRST1000
22
COPY
FIRST
CLOOP
ENDFIL
EOF
THREE
ZERO
RETADR
LENGTH
BUFFER
RDREC
1000
1000
1003
1015
1024
102D
1030
1033
1036
1039
2039
23
24
Pass 1
25
26
Pass 2
27
else
if (found symbol==RSUB||
found symbol== ||
found symbol==)
store 0 as operand address
else
store 0 as operand address
set error flag
assemble the object code inst.
28
Indirect addressing
Immediate operands
Extended format
30
31
32
SIC/XE
PC-relative/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
COMPR
larger memory multi-programming (program
allocation)
33
Register translation
Address translation
PC-relative: -2048~2047
Base-relative: 0~4095
Register-register instructions
10
0000
FIRST STL
RETADR
17202D
36
37
38
+OP, e=1
n=1, i=1,
OPcode+3,
@m, n=1, i=0, OPcode+2,
#C, n=0, i=1, OPcode+1,
xbpe
2: PC-relative
4: base-relative
8: index (m,X)
1: extended
Extended
Simple
Indirect
Immediate
39
0017
CLOOP
3F2FEC
160
104E
STCH
BUFFER, X
57C003
Extended instruction
15
4B101036
Immediate instruction
55
133
0006
0020
103C
LDA
+LDT
#3
#4096
010003
75101000
41
42
1 M
2-7 Starting location of the address field to be modified,
relative to the beginning of the program.
8-9 Length of the address field to be modified, in half
bytes.
M^000007^05
43
ENDFIL
LDA
=CEOF
032010
215
001A
1062
WLOOP
TD
=X05
E32011
44
45
RDREC
46
WRREC
47
2.3.1 Literals
=, #
Immediate addressing, the operand value is assembled as
part of the machine instruction, no memory reference.
With a literal, the assembler generates the specified value
as a constant at some other memory location. The address
of this generated constant is used as the TA for the
machine instruction, using PC-relative or base-relative
addressing with memory reference.
Literal pools
49
RDREC
50
WRREC
51
2.3.1 Literals
52
2.3.1 Literals
53
2.3.1 Literals
54
EQU
EQU
EQU
R1
R2
R3
56
ORG is used
http://home.educities.edu.tw/wanker742126/index.html
SYMBOL is 6-byte, VALUE is 3-byte, and FLAGS is 2-byte.
57
SYMBOL
VALUE
FLAGS
EQU
EQU
EQU
FLAGS
2
STAB +0
STAB +6
STAB +9
58
VALUE
FLAGS
3
2
1100
STAB
6
1
2
STAB+1100
59
EQU ALPHA
RESW 1
Need 2 passes
60
ALPHA
RESB
RESB
RESB
ORG
RESW
1
1
1
1
Forward reference
ALPHA
BETA
DELTA
EQU BETA
EQU DELTA
RESW 1
Need 3 passes
61
2.3.3 Expressions
2.3.3 Expressions
107 1000
MAXLEN EQU
BUFEND-BUFFER
Both BUFEND and BUFFER are relative terms.
The expression represents absolute value: the difference
between the two addresses.
Loc =1000 (Hex)
The value that is associated with the symbol that
appears in the source statement.
BUFEND+BUFFER, 100-BUFFER, 3*BUFFER represent
neither absolute values nor locations.
63
Program blocks
Control sections
Main
66
RDREC
67
WRREC
68
Address End
0000 0065
0066 0070
0071 1070
Length
0066 (0~0065)
000B (0~000A)
1000 (0~0FFF)
69
70
71
72
73
Figure 2.13
Figure 2.14
Default 1
Default 2
CDATA 2
Default 3
CDATA 3
75
76
Control section
77
78
79
80
81
4B100000
57900000
190
0003
0017
0028
MAXLEN
WORD
BUFEND-BUFFER
83
84
85
The loader will add to this data area with the address of
BUFEND and subtract from it the address of BUFFER.
(COPY and RDREC for MAXLEN)
Line 190 and 107, in 107, the symbols BUFEND and
BUFFER are defined in the same section.
The assembler must remember in which control section
a symbol is defined.
The assembler allows the same symbol to be used in
different control sections, lines 107 and 190.
87
Modification record
M
Starting address of the field to be modified, relative to
the beginning of the control section (Hex).
Length of the field to be modified, in half-bytes.
Modification flag (+ or -).
External symbol.
M^000004^05+RDREC
M^000028^06+BUFEND
M^000028^06-BUFFER
89
90
Most assemblers
91
92
93
94
95
96
97
98
100
ENDFIL
RDREC
EXIT
WRREC
101
102
LDA
ALPHA
BETA
DELTA
#0
EQU
EQU
RESW
Pass1
1000
BETA ????
DELTA ????
1
1003
2
1000
????
1003
1003
3
1000
1003
1003
1003
Need 3 passes!
103
104
105
106
107
108