Question: Write a program to copy 10 bytes of data at ROM address 500H to RAM starting at location 40H. Start with creating a look-up table at a convenient location
ORG 500H TABLE: DB 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
ORG 40H START: MOV DPTR, #TABLE ;SOURCE POINTER MOV R1, #40H ;DESTINATION POINTER MOV R3, #10 ;COUNTER
BACK: MOVC A, @A+DPTR ;GET A BYTE FROM THE SOURCE MOV @R1, A INC R1 INC DPTR DJNZ R3, BACK ;Does this 10 times END
This is what I have but I have no idea if it is right or working correctly. Can anyone help me out?
That code sample is so small and simple that you can easily take a piece of paper and a pencil and just simulate that code. Just write down the current register contents and the program counter and do the (few) steps. If you are unsure, review in the manual what the instructions actually do.
Then you see and learn what happens.
The only thing i will say is you DO have a bug.
It wont copy what you think.
FIX IT!
View all questions in Keil forum