Data Movement Instructions A Course in Microprocessor Electrical

  • Slides: 18
Download presentation
Data Movement Instructions A Course in Microprocessor Electrical Engineering Department University 17 Agustus 1945

Data Movement Instructions A Course in Microprocessor Electrical Engineering Department University 17 Agustus 1945 Jakarta

Load-Effective Address 4 There are several LEA instructions in p – Table 4. 9

Load-Effective Address 4 There are several LEA instructions in p – Table 4. 9 lists the LEA instructions 4 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) 4 LDS, LES, LFS, LGS, LSS – The LDS, LES, LFS,

Load-Effective Address (cont’d) 4 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, addressed by DI in the data segment, into the BX and DS registers • Study Example 4. 4

String Data Transfers 4 There are 5 string data transfer instructions: LODS, STOS, MOVS,

String Data Transfers 4 There are 5 string data transfer instructions: LODS, STOS, MOVS, INS, and OUTS 4 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) 4 DI and SI – The DI offset address accesses

String Data Transfers (cont’d) 4 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 4 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

String Data Transfers (cont’d) – Fig. 4. 16 shows the effect of executing the LODSW instruction if the D flag=0, SI=1000 H, and DS=1000 H 4 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

String Data Transfers (cont’d) – In example 4. 5 STOSW instruction is used to clear the video text display 4 MOVS – MOVS instruction transfers data (either byte, word or doubleword) from one memory location 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) 4 INS – The INS (input string) instruction transfers data

String Data Transfers (cont’d) 4 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 4 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