Professional Documents
Culture Documents
Hypothetical machine
Processor architecture
Main
memory
Size=64KB
Memory Address
=2 Bytes
Simplified
Instructional
Computer
(SIC)
Accumulator,
Registers X, L
Byte
Address:
2 bytes
4000
4003
4006
4009
4012
Word length
Byte
Byte
Main Memory
Byte
Byte
Byte
3 Bytes
Instruction set
of SIC
Instruction format
Instruction
START
LDA
STA
RESW
WORD
END
Operand
1003
FIVE
ALPHA
1
/*symbolic variable*/
5
/*symbolic constant, Literal */
FIRST
Psuedo Opcode OR
Assembler Directives
START
RESW
WORD,
END
LABEL
TEST
FIRST
ALPHA
FIVE
Instruction
START
LDA
STA
RESW
WORD
END
Operand
1003
FIVE
ALPHA
1
5
FIRST
Object code
001012
0C1009
******
000005
ALPHA
INCR
ONE
BETA
WORD
RESW
RESW
RESW
1
1
1
1
Assembler
Assembly language
code
Assembler
Object code
LABEL
TEST
FIRST
ALPHA
FIVE
Instruction
START
LDA
STA
RESW
WORD
END
Operand
1003
FIVE
ALPHA
1
5
FIRST
Object code
001012
0C1009
******
000005
Op code
Length
(bytes)
ADD m
18
LDA m
00
Address (LOC
value)
FIRST
1003
ALPHA
1009
FIVE
1012
Instructi
on
Op code
Length
(bytes)
ADD m
18
00
LDA m
Data Structures
LABEL
Address (LOC
value)
FIRST
1003
ALPHA
Data Structures
FIVE
1009
1012
Symbol Table
Used to store values (addresses) assigned to
labels
Includes the name and value for each label
Flags to indicate error conditions, e.g. duplicate
definition of labels
May contain other info like type or length about
the data area or instruction labeled
Data Structures
LOCCTR
Used to help in the assignment of addresses
Initialized to the beginning address specified in
the START statement
After each source statement is processed, the
length of the assembled instruction or data area
to be generated is added
Gives the address of a label
LABEL
TEST
FIRST
ALPHA
FIVE
Instruction
START
LDA
STA
RESW
WORD
END
Operand
1003
FIVE
ALPHA
1
5
FIRST
Object code
001012
0C1009
******
000005
Header record:
Col. 1
Col. 2-7
Col. 8-13
Col. 14-19
H
Program name
Starting address of object program (hexadecimal)
Length of object program in bytes (hexadecimal)
Text record:
Col. 1
Col. 2-7
Col. 8-9
Col. 10 69
T
Starting address for object code in this record (hexadecimal)
Length of object code in this record in bytes (hexadecimal)
Object code, represented in hexadecimal. (69-10+1)/6=10 instructions
End record:
Col. 1
Col. 2-7
E
Address of first executable instruction in object program (hexadecimal)
Loc
PASS -1
begin
read first input line
if OPCODE = 'START' then
begin
save #[OPERAND] as starting address
initialized LOCCTR to starting address
write line to intermediate file
read next input line
end {if START}
else
initialized LOCCTR to 0
1000 COPY
1000 FIRST
1003 CLOOP
1006
1009
100C
1000F
1012
1015 ENDFIL
1018
101B
101E
1021
1024
1027
102A EOF
102D THREE
1030 ZERO
1033 RETADR
1036 LENGTH
1039 BUFFER
.
.
.
2039 RDREC
.
.
.
2061 WRREC
.
.
Source Statement
START
STL
JSUB
LDA
COMP
JEQ
JSUB
J
LDA
STA
LDA
STA
JSUB
LDL
RSUB
WORD
RESW
RESW
RESB
1000
RETADR
RDREC
LENGTH
ZERO
ENDFIL
WRREC
CLOOP
EOF
BUFFER
THREE
LENGTH
WRREC
RETADR
BYTE
3
WORD
1
1
4096
ZERO
ZERO
END
FIRST
1000 COPY
1000 FIRST
1003 CLOOP
1006
1009
100C
1000F
1012
1015 ENDFIL
1018
101B
101E
1021
1024
1027
102A EOF
102D THREE
1030 ZERO
1033 RETADR
1036 LENGTH
1039 BUFFER
.
.
.
2039 RDREC
.
.
.
2061 WRREC
.
.
START
STL
JSUB
LDA
COMP
JEQ
JSUB
J
LDA
STA
LDA
STA
JSUB
LDL
RSUB
WORD
RESW
RESW
RESB
1000
RETADR
RDREC
LENGTH
ZERO
ENDFIL
WRREC
CLOOP
EOF
BUFFER
THREE
LENGTH
WRREC
RETADR
BYTE
3
WORD
1
1
4096
ZERO
ZERO
END
FIRST
PASS -2
begin
read first input file {from intermediate file}
if OPCODE = 'START' then
begin
write listing line
read next input line
end {if START}
write header record to object program
initialized first Text record
Loc
1000 COPY
1000 FIRST
1003 CLOOP
1006
1009
100C
1000F
1012
1015 ENDFIL
1018
101B
101E
1021
1024
1027
102A EOF
102D THREE
1030 ZERO
1033 RETADR
1036 LENGTH
1039 BUFFER
.
.
.
2039 RDREC
.
.
.
2061 WRREC
.
.
Source Statement
START
STL
JSUB
LDA
COMP
JEQ
JSUB
J
LDA
STA
LDA
STA
JSUB
LDL
RSUB
WORD
RESW
RESW
RESB
1000
RETADR
RDREC
LENGTH
ZERO
ENDFIL
WRREC
CLOOP
EOF
BUFFER
THREE
LENGTH
WRREC
RETADR
BYTE
3
WORD
1
1
4096
Object Code
ZERO
041030
ZERO
END
FIRST
041030
1000 COPY
1000 FIRST
1003 CLOOP
1006
1009
100C
1000F
1012
1015 ENDFIL
1018
101B
101E
1021
1024
1027
102A EOF
102D THREE
1030 ZERO
1033 RETADR
1036 LENGTH
1039 BUFFER
.
.
.
2039 RDREC
.
.
.
2061 WRREC
.
.
START
STL
JSUB
LDA
COMP
JEQ
JSUB
J
LDA
STA
LDA
STA
JSUB
LDL
RSUB
WORD
RESW
RESW
RESB
1000
RETADR
RDREC
LENGTH
ZERO
ENDFIL
WRREC
CLOOP
EOF
BUFFER
THREE
LENGTH
WRREC
RETADR
BYTE
3
WORD
1
1
4096
ZERO
041030
ZERO
END
FIRST
041030
1000 COPY
1000 FIRST
1003 CLOOP
1006
1009
100C
1000F
1012
1015 ENDFIL
1018
101B
101E
1021
1024
1027
102A EOF
102D THREE
1030 ZERO
1033 RETADR
1036 LENGTH
1039 BUFFER
.
.
.
2039 RDREC
.
.
.
2061 WRREC
.
.
START
STL
JSUB
LDA
COMP
JEQ
JSUB
J
LDA
STA
LDA
STA
JSUB
LDL
RSUB
WORD
RESW
RESW
RESB
1000
RETADR
RDREC
LENGTH
ZERO
ENDFIL
WRREC
CLOOP
EOF
BUFFER
THREE
LENGTH
WRREC
RETADR
BYTE
3
WORD
1
1
4096
ZERO
041030
ZERO
END
FIRST
041030
Header record:
Col. 1
Col. 2-7
Col. 8-13
Col. 14-19
H
Program name
Starting address of object program (hexadecimal)
Length of object program in bytes (hexadecimal)
Text record:
Col. 1
Col. 2-7
Col. 8-9
Col. 10 69
T
Starting address for object code in this record (hexadecimal)
Length of object code in this record in bytes (hexadecimal)
Object code, represented in hexadecimal. (69-10+1)/6=10 instructions
End record:
Col. 1
Col. 2-7
E
Address of first executable instruction in object program (hexadecimal)