190 likes | 382 Views
Data Movement Instructions. A Course in Microprocessor Electrical Engineering Department University of Indonesia. Load-Effective Address. There are several LEA instructions in p Table 4.9 lists the LEA instructions LEA
E N D
Data Movement Instructions A Course in Microprocessor Electrical Engineering Department University of Indonesia
Load-Effective Address • There are several LEA instructions in p • Table 4.9 lists the LEA instructions • LEA • The LEA instruction loads a 16- or 32- bit register with the offset address of the data specified by the operand • E.g., LEA AX,NUMB • Compare: LEA BX,[DI] & MOV BX,[DI] • Understand Example 4.3
Load-Effective Address (cont’d) • LDS, LES, LFS, LGS, LSS • The LDS, LES, LFS, LGS, LSS instructions load any 16- or 32-bit register with an offset address and load the DS, ES, FS, GS, or SS segment register with a segment address • Fig. 4.15 illustrates an example LDS, BX,[DI] instruction • this instruction transfers the 32-bit number, address-ed by DI in the data segment, into the BX and DS registers • Study Example 4.4
String Data Transfers • There are 5 string data transfer instructions: LODS, STOS, MOVS, INS, and OUTS • The Direction Flag • The direction flag (D) -located in the flag register- selects the auto-increment (D=O) or the auto-decrement (D=1) operation for the DI and SI registers during string operations • The CLD instruction clears the D flag (D=0), and the STD instruction sets it (D=1)
String Data Transfers (cont’d) • DI and SI • The DI offset address accesses data in the extra segment for all string instructions that use it • The SI offset address accesses data, by default, in the data segment • LODS • The LODS instruction loads AL, AX, or EAX with data stored at the data segment offset address indexed by the SI register (Table 4.10)
String Data Transfers (cont’d) • Fig.4.16 shows the effect of executing the LODSW instruction if the D flag=0, SI=1000H, and DS=1000H • STOS • The STOS instruction stores AL, AX, or EAX at the extra segment memory location addressed by the DI register • Table 4.11 lists all forms of STOS instructions • The STOSB (stores a byte), STOSW (stores a word) and STOSD (stores a doubleword)
String Data Transfers (cont’d) • In example 4.5 STOSW instruction is used to clear the video text display • MOVS • MOVS instruction transfers data (either byte, word or doubleword) from one memory loca-tion to another (Table 4.13) • MOVS transfers data from the data segment location addressed by SI to the extra segment location addressed by DI • Example 4.6 lists a short program that uses MOVS
String Data Transfers (cont’d) • INS • The INS (input string) instruction transfers data from an I/O device into extra segment memory location addressed by the DI register • The I/O address is contained in the DX register • See Table 4.14 and Study example 4.7 • OUTS • The OUTS (output string) transfers data from the data segment location addressed by SI to an I/O device (addressed by DX) -- Table 4.15 & Example 4.8