1 / 24

Lecture 6

Lecture 6. Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU. Agenda. String Data Transfer Instructions The Direction Flag LODS Instructions STOS Instructions MOVS Instructions INS and OUTS Instructions More Examples. String Data Transfers. Five Instructions

janae
Download Presentation

Lecture 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 6 Presented By Dr. ShazzadHosain Asst. Prof. EECS, NSU

  2. Agenda • String Data Transfer Instructions • The Direction Flag • LODS Instructions • STOS Instructions • MOVS Instructions • INS and OUTS Instructions • More Examples

  3. String Data Transfers • Five Instructions • LODS, STOS, MOVS, INS and OUTS • Each instruction allows data transfer either a single byte, word or double word

  4. The Direction Flag, DF • DF = 0, auto-increment mode of SI, DI • DF = 1, auto-decrement mode of SI, DI • CLD instruction clears the D flag (D = 0) • STD instruction sets the D flag (D = 1) • SI (Source Index) points to DS (Data Segment) i.e. DS:[SI] • DI (Destination Index) points to ES (Extra Segment) i.e. ES:[DI]

  5. LODS Instructions • LODS instructions loads AL, AX or EAX with data indexed by SI register • LODSB – load string byte Table 4-10: from Brey’s book

  6. Example STRING1 DB ‘ABC’ MOV AX, @DATA MOV DS, AX LEA SI, STRING1 CLD LODSB LODSB

  7. STOS Instructions • STOS instructions stores data form AL, AX or EAX to memory indexed by DI register • STOSB – store string byte Table 4-11: from Brey’s book

  8. Example STRING1 DB ‘HELLO’ MOV AX, @DATA MOV ES, AX LEA DI, STRING1 CLD MOV AL, ‘A’ STOSB STOSB

  9. REP (Repeat Prefix)) • REP is used to execute string instructions repeatedly by CX times. • REP automatically decrements CX by 1 • REP works for any string instructions except LODS instruction

  10. Example : Clear the video text display 1 2 3 80 **** a b c 1 2 * * * 25 Video display 5 4 3 2 1 0 c b a 20H 20H 20H 07H 07H 07H Example 4-5: From Brey’s Book B800H Text memory

  11. MOVS Instructions • MOVSB – move string byte from one memory location to other Table 4-13 : From Brey’s Book

  12. Example .DATA STRING1 DB ‘HELLO’ STRING1 DB 5 DUP (?) MOV AX, @DATA MOV DS, AX MOV ES, AX LEA SI, STRING1 LEA DI, STRING2 CLD MOVSB MOVSB

  13. Example: Scroll Up One Line 1 2 3 80 **** 1 2 * * * 25 Video display * * SI 160 * * 5 4 3 2 1 0 Example 4-6: From Brey’s Book DI B800H Text memory

  14. INS Instructions • INSB – Input String Byte, from I/O device to memory location Table 4-14: From Brey’s Book

  15. Example • Read 50 bytes of data from an I/O device whose address in 03ACH and store the data in LISTS array Example 4-7: From Brey’s Book

  16. OUTS Instructions • OUTSB – Output String Byte, from string memory location to I/O device Table 4-15: From Brey’s Book

  17. Example • Transfer data form memory array (ARRAY) to an I/O device at I/O address 3ACH Example 4-8: From Brey’s Book

  18. Agenda • String Data Transfer Instructions • The Direction Flag • LODS Instructions • STOS Instructions • MOVS Instructions • INS and OUTS Instructions • More Examples

  19. Concatenate Two Input StringsThen Display Display message 1 Read first string Display message 2 Read second string Concatenate the two strings Display the result Input String 1: Hello Input String 2: World! Concatenated String: Hello World!

  20. Display message 1 Read first string Display message 2 Read second string Concatenate the two strings Display the result Display message 1 Read first string

  21. Display message 1 Read first string Display message 2 Read second string Concatenate the two strings Display the result Display message 2 Read second string

  22. Display message 1 Read first string Display message 2 Read second string Concatenate the two strings Display the result Concatenate the two strings Display the result

  23. Mid Term, Fall 2010October 30, SaturdayAt 9:00 AM to 10:30NAC 311

  24. References • Ch 11, Assembly Language Programming – by CharlsMarut • Section 4-4, Intel Microprocessors – by Brey

More Related