Figure 2-18(a) shows an instruction that uses the relative based indexed addressing mode to add a memory location with a register. From D=0 it is seen that the sum is put in the memory location and W=1 indicates a 16-bit addition. The effective address is found by adding the contents of BX and DI to the 16-bit displacement, which is 2345. If (BX) = 0892 and (DI) = 59A3, then

EA = 0892 + 59A3 + 2345 = 857A

Figure 2-18(b) shows a similar instruction except that the source operand is immediate. In this instruction S=1 and W=1, which indicate that the 8-bit immediate operand is sign extended to FF97 before it is added. An equivalent instruction could be constructed of 6 bytes by letting S:W = 01 and by including a 16-bit immediate operand containing 97FF.

Figure 2-18 Two examples of the ADD instruction using the relative based indexed addressing mode.

(a) Register to memory addition
(b) Immediate to memory addition

The long and short forms of an instruction for adding an immediate operand to the AX register are given in Fig. 2-19. Because S:W = 01 there are 2 bytes of data in the instruction. In the long form AX is explicitly designated by the R/M field and in the short form AX is implied by the op code. Short forms will be discusses more thoroughly in Sec. 3-12.

Figure 2-19 Two forms for adding an immediate operand to the AX register.

(a) Long form
(b) Short form

Figure 2-20 Sequence of instructions in memory.

AddressContents
0020002First instruction
00201CF
0020201Second instruction
0020391
0020445
0020523
0020683Third instruction
0020781
0020845
0020923
0020A97
0020B05Fourth instruction
0020C23
0020D01
0020E

Table of Contents | Next page | Previous page

This is page 20.