Skip to content
Related Articles

Related Articles

Improve Article

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

  • Last Updated : 22 May, 2018

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 ADDRESSMNEMONICSCOMMENTS
0400MOV SI, 500SI <- 500
0403MOV DI, 600DI <- 600
0406MOV AX, 0000AX <- 0000
0409MOV DS, AXDS <- AX
040BMOV ES, AXES <- AX
040DMOV CX, 0004CX <- 0004
0410CLDCLEAR DIRECTIONAL FLAG
0411REPREPEAT UNTIL CX=0
0412MOVSBMOVE THE BLOCK
0413HLTEND 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.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :