Information Technology Reference
In-Depth Information
TABLE 3.6 The Opcode Table for the Assembly of our Simple Processor
Opcode value
(binary)
Instruction length
(bytes)
Opcode
Operand
Instruction type
STOP
0000
2
Control
LD
Mem-adr
0001
2
Memory-reference
ST
Mem-adr
0010
2
Memory-reference
MOVAC
0011
2
Register-reference
MOV
0100
2
Register-reference
ADD
0101
2
Register-reference
SUB
0110
2
Register-reference
AND
0111
2
Register-reference
NOT
1000
2
Register-reference
BRA
Mem-adr
1001
2
Control
BZ
Mem-adr
1010
2
Control
table for the simple processor described in Section 3.1. As an example, we explain
the information associated with the opcode LD. It has one operand, which is a
memory address and its binary value is 0001. The instruction length of LD is
2 bytes and its type is memory-reference.
The entries of the pseudo instruction table are the pseudo instructions symbols.
Each entry refers the assembler to a procedure that processes the pseudo instruction
when encountered in the program. For example, if END is encountered, the trans-
lation process is terminated.
In order to keep track of the instruction locations, the assembler maintains a vari-
able called instruction location counter (ILC). The ILC contains the value of
memory location assigned to the instruction or operand being processed. The ILC
is initialized to 0 and is incremented after processing each instruction. The ILC is
incremented by the length of the instruction being processed, or the number of
bytes allocated as a result of a data allocation pseudo instruction.
Figures 3.4 and 3.5 show simplified flowcharts of pass one and pass two in a two-
pass assembler. Remember that the main function of pass one is to build the symbol
table while pass two's main function is to generate the object code.
3.4.3. Linker and Loader
The linker is the entity that can combine object modules that may have resulted from
assembling multiple assembly modules separately. The loader is the operating
system utility that reads the executable into memory and start execution.
In summary, after assembly modules are translated into object modules, the func-
tions of the linker and loader prepare the program for execution. These functions
include combining object modules together, resolving addresses unknown at assem-
bly time, allocating storage, and finally executing the program.
Search WWH ::




Custom Search