Lecture 6
Lecture 6
INSTRUCTIONS
LECTURE OUTLINE
4-3 LOAD-EFFECTIVE ADDRESS
4–4 STRING DATA TRANSFERS
4–5 MISCELLANEOUS DATA TRANSFER INSTRUCTIONS
4–3 LOAD-EFFECTIVE ADDRESS
LEA
loads a 16- or 32-bit register with the offset address of the data
specified by the operand.
By comparing LEA with MOV, we observe that LEA BX,[DI] loads the
offset address specified by [DI] (contents of DI) into the BX register; MOV
BX,[DI] loads the data stored at the memory location addressed by [DI] into
register BX.
Earlier examples presented by using the OFFSET directive.
OFFSET directive performs the same function as an LEA instruction if the
operand is a displacement.
For example, the MOV BX,OFFSET LIST performs the same function as LEA
BX,LIST. Both instructions load the offset address of memory location LIST
into the BX register.
But why is the LEA instruction available if the OFFSET
directive accomplishes the same task?
- First, OFFSET only functions with simple operands such as
LIST. It may not be used for an operand such as [DI], LIST [SI],
and so on.
The OFFSET directive is more efficient than the LEA
instruction for simple operands. It takes the microprocessor
longer to execute the LEA BX,LIST instruction than the MOV
BX,OFFSET LIST.
Microprocessor requires two clocks to execute the LEA
BX,LIST instruction and only one clock to execute MOV
BX,OFFSET LIST. The reason that the MOV BX,OFFSET
LIST instruction executes faster.
- the assembler calculates the offset address of LIST, whereas the
microprocessor calculate the address for the LEA instruction.
LDS, LES, LFS, LGS, AND LSS
load any 16-bit or 32-bit register with an offset address, and the DS, ES,
FS, GS, or SS segment register with a segment address.
These instructions use any of the memory-addressing modes to access a
32-bit or 48-bit section of memory that contains both the segment and
offset address.
- The 32-bit section of memory contains a 16- bit offset and segment
address, while the 48-bit section contains a 32-bit offset and a
segment
address.
Figure 4–17 illustrates an example LDS BX,[DI] instruction. This instruction
transfers the 32-bit number, addressed by DI in the data segment, into the
BX and DS registers.
FIGURE 4–17 THE LDS BX,[DI] INSTRUCTION LOADS REGISTER BX FROM ADDRESSES
11000H AND 11001H AND REGISTER DS FROM LOCATIONS 11002H AND 11003H. THIS
INSTRUCTION IS SHOWN AT THE POINT JUST BEFORE DS CHANGES TO 3000H AND BX
CHANGES TO 127AH.
This instruction transfers the 32-bit number, addressed by DI in the data
segment, into the BX and DS registers.
The LDS, LES, LFS, LGS, and LSS instructions obtain a new far address
from memory.
- offset address appears first, followed by the segment address.
TABLE 4–10 LOAD-EFFECTIVE ADDRESS INSTRUCTIONS.
4–4 STRING DATA TRANSFERS
- CLD instruction selects the auto-increment mode and STD selects the
auto-decrement mode
DI AND SI
During execution of a string instruction, memory accesses occur
through either or both of the DI and SI registers.