In: Computer Science
Write a program segment to copy a table with five items from a memory location starting at $5000 to a memory location starting at $6000.
Algorithm –
| 
 ADDRESS  | 
 MNEMONICS  | 
 COMMENTS  | 
| 
 0400  | 
 MOV SI, 5000  | 
 SI<-5000  | 
| 
 0403  | 
 MOV DI, 00  | 
 DI<-6000  | 
| 
 0406  | 
 MOV AX, 0000  | 
 AX<-0000  | 
| 
 0409  | 
 MOV DS, AX  | 
 DS<-AX  | 
| 
 040B  | 
 MOV ES, AX  | 
 ES<-AX  | 
| 
 040D  | 
 MOV CL, [SI]  | 
 CL<-[SI]  | 
| 
 0410  | 
 MOV CH, 00  | 
 CH<-00  | 
| 
 0412  | 
 INC SI  | 
 SI<-SI+1  | 
| 
 0413  | 
 CLD  | 
 Clears the directional Flag  | 
| 
 0414  | 
 REP  | 
 repeat until CX is not equal to zero  | 
| 
 0415  | 
 MOVSB  | 
 transfer the data from source to destination memory location  | 
| 
 0416  | 
 HLT  | 
 end  | 
Explanation:-
MOV SI, 5000: load the value 5000 into offset
SI.
MOV DI, 6000: load the value 6000 into offset DI.
MOV AX, 0000: load the value 0000 into AX register.
MOV DS, AX: load the value of AX register into DS (data segment).
MOV ES, AX: load the value of AX register into ES (extra segment).
MOV CL, [SI]: load the data of offset SI into CL register.
MOV CH, 00: load value 00 into CH register.
INC SI: increment the value of SI by one.
CLD: clears the directional flag i.e. DF=0.
REP: repeat until value of CX is not equal to zero and decrement the value of CX by one at each step.
MOVSB: transfer the data from source memory location to destination memory location.
HLT: end.