Instruction Set and Assembly Language Programming 161
The advantage of this method of locating a data is that if the same table has to be used multiple times
to access multiple entries, then the index register need to be loaded only once. In 8051, instruction set
MOVC A, @A+DPTR
may be taken as an example of indexed addressing mode.
Figure 6.8 illustrates an example of indexed addressing mode, assuming R
n
to be an index register
of the processor. In this case, the offset of the target address is indicated as 7, which is added with the
content of R
n
to get the target address of the data to be copied in R1.
6.5 INSTRUCTION FORMATS AND FIELDS
As we have already discussed, the nal form of executable instruction would be in machine language
with Boolean representation of all instructions. This representation of instruction is known as opcode
for the processor. These opcodes may need only one byte or multiple bytes of space to generate a com-
plete description of the instruction ( Figure 6.9 ). To put it in another way, every opcode must inform the
processor clearly and explicitly what to do. The format of these opcodes varies with the instruction type.
For example, an instruction may not need any operand (instructions like: RETURN or RET). This type
of instruction may occupy only one byte [Figure 6.9 (a)]. On the other hand, an instruction with immedi-
ate addressing mode may need two bytes, the rst one may contain the opcode itself and the destination
register’s identi cation and the second one might be the immediate data byte to be loaded within that
register (Figure 6.9 (d)). Schematically, a few variations of opcode formats are presented through Figure
6.9 . Note that the exact format is dependent upon the processor and its instruction set.
In Figure 6.9 (b) the instruction and a register’s code are included within one byte. Any one register
oriented operation, like: increment the register content by one , may adopt this format. Figure 6.9 (c) indi-
cates another widely adopted format, mostly used to copy a data byte from one register to another. In this
case both source register as well as destination register’s name are included within the instruction format.
In direct addressing mode of data loading to a register, the process may use the format shown
in Figure 6.9 (e). In this case, a complete 16-bit address forms the part of the instruction format,
consuming its second and third bytes. The rst byte accommodates the instruction along with
the indication of the destination register. Note that the order of the MSB and LSB of the address
Figure 6.9 Schematic of a few formats of instructions
may interchange, depending upon the processor. In some processors, MSB comes rst (in the sec-
ond byte of instruction) followed by LSB. In some other processor, the LSB might be placed rst
followed by MSB.
M06_GHOS1557_01_SE_C06.indd 161M06_GHOS1557_01_SE_C06.indd 161 4/29/11 5:09 PM4/29/11 5:09 PM