Thursday, September 9, 2010

Statement: Take 10 bytes of data from RAM location 45H to 54 H. Add 05H to each of them & save the result data in RAM location 79H down to 70H

ORG 0000H
MOV R0,#10
MOV R1,#45H
MOV R2,#79H
BACK:
MOV A,@R1
ADD A,#05H
MOV @R2,A
INR R1
DCR R2
DJNZ R0,BACK
END


Explanation:-

First of all we have stored data 10 (decimal) in register R0.
Then we have stored 45H in register R1 and 79H in register R2

'BACK' loop:-

This loop starts with instruction MOV A,@R1
Here @R1 is used therefore the 8051 will load the accumulator with the value from Internal RAM which is specified by the data of  R1.Which means that the data of R1 is currently 45H. So accumulator will contain the data which is stored at memory location 45H. (Indirect Addressing)

After that whatever the data is copied accumulator will be added by 05H.

Then the data of the accumulator will be copied in the memory location which is specified by the data of register R2.

Data of R1 is incremented by 1. (as we want to go from 45 H to 54 H)
Data of R2 is decremented by 1.(as we want to go from 79 H to 70 H)
R0 is decremented by 1. (and it jumps to BACK if the value of register R0 is not zero.)

END stands for 'stop'.

1 comment:

  1. nice blog...........
    contect me if you want to create great blog or website like www.wpthemezone.co.cc www.moviemall.co.cc

    contet me : sam.marvania@gmail.com

    ReplyDelete