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
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.
Address | Contents | |||
---|---|---|---|---|
00200 | 02 | First instruction | ||
00201 | CF | |||
00202 | 01 | Second instruction | ||
00203 | 91 | |||
00204 | 45 | |||
00205 | 23 | |||
00206 | 83 | Third instruction | ||
00207 | 81 | |||
00208 | 45 | |||
00209 | 23 | |||
0020A | 97 | |||
0020B | 05 | Fourth instruction | ||
0020C | 23 | |||
0020D | 01 | |||
0020E |
This is page 20.