Hardware Reference
In-Depth Information
1. The length of data field associated with symbol.
2. The relocation bits. (Does the symbol change value if the program is
loaded at a different address than the assembler assumed?)
3. Whether or not the symbol is to be accessible outside the procedure.
Symbol
Value
Other information
MARIA
100
ROBERTA
111
MARILYN
125
STEPHANY
129
Figure 7-7. A symbol table for the program of Fig. 7-6.
The opcode table contains at least one entry for each symbolic opcode
(mnemonic) in the assembly language. Figure 7-8 shows part of an opcode table.
Each entry contains the symbolic opcode, two operands, the opcode's numerical
value, the instruction length, and a type number that separates the opcodes into
groups depending on the number and kind of operands.
First
operand
Second
operand
Hex
opcode
Instruction
length
Instruction
class
Opcode
AAA
37
1
6
ADD
EAX
immed32
05
5
4
ADD
reg
reg
01
2
19
AND
EAX
immed32
25
5
4
AND
reg
reg
21
2
19
Figure 7-8. A few excerpts from the opcode table for an x86 assembler.
As an example, consider the opcode ADD .Ifan ADD instruction contains EAX
as the first operand and a 32-bit constant ( immed32 ) as the second one, then op-
code 0x05 is used and the instruction length is 5 bytes. (Constants that can be
expressed in 8 or 16 bits use different opcodes, not shown.) If ADD is used with
two registers as operands, the instruction is 2 bytes, with opcode 0x01. The (arbi-
trary) instruction class 19 would be given to all opcode-operand combinations that
follow the same rules and should be processed the same way as ADD with two reg-
ister operands. The instruction class effectively designates a procedure within the
assembler that is called to process all instructions of a given type.
Some assemblers allow programmers to write instructions using immediate ad-
dressing even though no corresponding target language instruction exists. Such
''pseudoimmediate'' instructions are handled as follows. The assembler allocates
 
Search WWH ::




Custom Search