To transfer a block of data from one memory location to another


5. To transfer a block of data from one memory location to another :

mov r2,#0ah ;Load r2 with immediate data 05h
mov dptr,#9000h ;Load 9000h into dptr register
mov r0,#0a0h ;Load r0 with immediate data 0a0h
mov r1,#00h ;Load r1 with immediate data 00h
mov a,#0h ; Load a with immediate data 00h
up:movx a,@dptr ;move data from external memory to a
push dph ;push dph on the stack
push dpl ;push dpl on the stack
mov dph,r0 ;move data from r0 to dph
mov dpl,r1 ;move data from r1 t dpl
movx @dptr,a ;move data from a to external memory location
pop dpl ;pop dpl from the stack
pop dph ;pop dph from the stack
inc dptr ;increment dptr
inc r1 ;increment r1
dec r2 ;decrement r2
cjne r2,#00,up ;compare r2 with 0, if not equal, jump to label up
here:sjmp here
end
Output:
I block:9000h: 01 02 03 04 05
II block:a000h:01 02 03 04 05( after block transfer)


Web Statistics