8086 program to transfer a block of 4 bytes by using string instructions

Problem – Write a program to transfer a block of 4 bytes, starting address is 0500 and transfer the block at address 0600 by using string instructions.

Example –



Assumptions – Assume that there are 4 blocks in memory addresses 0500, 0501, 0502, 0503.

Algorithm –

  1. Assign value 500 in SI and 600 in DI
  2. Assign the value 0000 H to AX
  3. Move the content of AX in DS
  4. Move the content of AX in ES
  5. Assign the value 0004 H to CX
  6. Clear the directional flag
  7. Repeat until CX=0, Move string block
  8. Halt of the program

Program –

MEMORY ADDRESS MNEMONICS COMMENTS
0400 MOV SI, 500 SI <- 500
0403 MOV DI, 600 DI <- 600
0406 MOV AX, 0000 AX <- 0000
0409 MOV DS, AX DS <- AX
040B MOV ES, AX ES <- AX
040D MOV CX, 0004 CX <- 0004
0410 CLD CLEAR DIRECTIONAL FLAG
0411 REP REPEAT UNTIL CX=0
0412 MOVSB MOVE THE BLOCK
0413 HLT END OF THE PROGRAM

Explanation –

  1. MOV SI, 500 assigns 500 to SI
  2. MOV DI, 600 assigns 600 to DI
  3. MOV AX, 00 assign 0000 to AX register
  4. MOV DS, AX moves the content of AX to DS segment
  5. MOV ES, AX moves the content of AX to ES segment
  6. MOV CX, 0004 assign 0000 to CX register
  7. CLD clear the directional flag
  8. REP repeat until CX=0
  9. MOVSB move string block
  10. HLT stops the execution of the program.


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.