programb66 - Step V Transfer the data block byte by byte to...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Appendix B  Explanation : Consider that a block of data of N bytes is present at source location. Now this block of N bytes is to be moved from source location to a destination location. Let the number of bytes N = 10. We will have to initialize this as count in the CX register. We know that source address is in the SI register and destination address is in the DI register. Clear the direction flag. Using the string instruction move the data from source location to the destination location. It is assumed that data is moved within the same segment. Hence the DS and ES are initialized to the same segment value.  Algorithm : Step I : Initialise the data in the source memory and destination memory. Step II : Initialise SI and DI with source and destination address. Step III : Initialise CX register with the count. Step IV : Initialise the direction flag to zero.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Step V : Transfer the data block byte by byte to destination. Step VI : Decrement CX. Step VII : Check for count in CX, if not zero goto step V else goto step VIII. Step VIII : Stop. Flowchart : Refer flowchart 66. Program : .model small .data src_blk db 01, 02, 03, 04, 05, 06, 07, 08, 09, 0AH dest_blk db 10 dup(?) count dw 0AH .code mov ax, @data ; initialize data & ; extra segment mov ds, ax mov es, ax mov si, offset src_blk ; si to point to source block mov di, offset dest_blk ; di to point to destination block mov cx, count ; initialize counter Flowchart 66 cld ; df=0 again : rep movsb ; transfer contents mov di, offset dest_blk ; di to point to destination block mov bh, 0Ah ; initialize counter up: mov bl, [di] ; store result in bl end Result : 01 H, 02 H, 03 H, 04 H, 05 H, 06 H, 07 H, 08 H, 09 H, 0A H....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online