Exp 02 Moving An Array of Data
Exp 02 Moving An Array of Data
23EC2106R
PROCESSORS AND CONTROLLERS
Lab Experiment - 2
Aim
● To Develop an Assembly Language Program (ALP) to move a 16-bytes long string data
from the starting offset location of 0200H to starting offset location of 0300H in the
segment 7000H.
Theory:
• Write a paragraph about segment address and offset addresses in 8086
microprocessor.
Exp 2: MOVING ARRAY OF DATA USING 8086
Input Data:
• The 16 bytes of data stored in offset location 0200H of segment
location 7000H is
01H, 11H, 21H, 31H,
41H, 51H, 61H, 71H,
81H, 91H, A1H, B1H,
C1H, D1H, E1H, F1H
Exp 2: MOVING ARRAY OF DATA USING 8086
Program Table: (a)
Address Program Comment
0100:0000 MOV AX, 7000H Move the value 7000H into AX register (loading segment address)
0100:0003 MOV DS, AX Move the contents of AX into DS register (data segment register)
0100:0005 MOV CL, 10H Load CL register with the size of the string (10H or decimal 16)
0100:0007 MOV SI, 0200H loading the source data offset address into SI register
0100:000A MOV DI, 0300H loading the destination offset address into DI register
0100:000D BACK: MOV AL, [SI] Move the data from source address into AL register
0100:000F MOV [DI], AL Move the contents of AL register into destination address
0100:0011 INC SI Increase SI contents by 1
0100:0012 INC DI Increase DI contents by 1
0100:0013 DEC CL decrease CL contents by 1
0100:0015 JNZ BACK Jump to BACK if ZF=0 (Keep moving all 16 bytes of data until CL=0)
0100:0017 HLT Halt (stop) the processor.
Exp 2: MOVING ARRAY OF DATA USING 8086
Program Table: (b)
Address Program Comment
0100:0000 MOV AX, 7000H Move the value 7000H into AX register (loading segment address)
0100:0003 MOV DS, AX Move the contents of AX into DS register (data segment register)
0100:0005 MOV CL, 10H Load CL register with the size of the string (10H or decimal 16)
0100:0007 MOV SI, 0200H loading the source data offset address into SI register
0100:000A MOV DI, 0300H loading the destination offset address into DI register
0100:000D BACK: MOV AL, [SI] Move the data from source address into AL register
0100:000F MOV [DI], AL Move the contents of AL register into destination address
0100:0011 INC SI Increase SI contents by 1
0100:0012 INC DI Increase DI contents by 1
0100:0013 LOOP BACK Repeat the loop until CL=0 (Keep moving all 16 bytes of data)
0100:0015 HLT Halt (stop) the processor.
Exp 2: MOVING ARRAY OF DATA USING 8086
Program Table: (c)
Address Program Comment
0100:0000 MOV AX, 7000H Move the value 7000H into AX register (loading segment address)
0100:0003 MOV DS, AX Move the contents of AX into DS register (data segment register)
0100:0005 MOV ES, AX Move the contents of AX into ES register (extra segment register)
0100:0007 MOV CL, 10H Load CL register with the size of the string (10H or decimal 16)
0100:0009 MOV SI, 0200H loading the source data offset address into SI register
0100:000C MOV DI, 0300H loading the destination offset address into DI register
0100:000F CLD Clear direction flag DF =0 (auto incrementing address access)
0100:0010 REP MOVSB Repeatedly move the string of 16 bytes until CL=0
0100:0012 HLT Halt (stop) the processor.
Exp 2: MOVING ARRAY OF DATA USING 8086
Input Data: Output Data:
Observation Values:
Memory Data Memory Data
Location Byte Location Byte
0200H 01 0300H 01
0201H 11 0301H 11
. .
. .
. .
020FH F1 030FH F1
x X X X 0 0 1 - 0 1 X 0 X 1 X 0
Exp 2: MOVING ARRAY OF DATA USING 8086
Result:
N L PRASAD