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 –
- Assign value 500 in SI and 600 in DI
- Assign the value 0000 H to AX
- Move the content of AX in DS
- Move the content of AX in ES
- Assign the value 0004 H to CX
- Clear the directional flag
- Repeat until CX=0, Move string block
- 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 –
- MOV SI, 500 assigns 500 to SI
- MOV DI, 600 assigns 600 to DI
- MOV AX, 00 assign 0000 to AX register
- MOV DS, AX moves the content of AX to DS segment
- MOV ES, AX moves the content of AX to ES segment
- MOV CX, 0004 assign 0000 to CX register
- CLD clear the directional flag
- REP repeat until CX=0
- MOVSB move string block
- HLT stops the execution of the program.
Recommended Posts:
- 8086 program to transfer a block of bytes by using string instruction
- Program execution transfer instructions in 8086 microprocessor
- Data transfer instructions in 8086 microprocessor
- String manipulation instructions in 8086 microprocessor
- 8085 program to exchange a block of bytes in memory
- Data transfer instructions in 8085 microprocessor
- Arithmetic instructions in 8086 microprocessor
- Logical instructions in 8086 microprocessor
- Process control instructions in 8086 microprocessor
- 8086 program to reverse a string
- 8086 program to print a String
- 8086 program to search a number in a string
- 8086 program to check whether a string is palindrome or not
- 8085 program to multiply two 8 bit numbers using logical instructions
- Assembly program to transfer the status of switches
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.



