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?
I really appreciate the help don’t get me wrong. I’m just not sure where to exactly start. I’ll try something with that simulator when I get home. Is there any hints that you can give me of where I might start with my code? Or maybe which lines are incorrect. I think I’m more confused with the actual table part.
It's really very simple:
You start with a pencil and a piece of paper, and the Instruction Set Manual.
Squared paper is probably best - so you can have columns for register values, data values, etc.
On the paper, write down the starting conditions for the registers & data you use (remember - these could be "undefined")
Write down the first instruction of your program; refer to the Instruction Set Manual to see what that instruction does.
Write down how that instruction changes the registers & data.
Rinse and repeat for each instruction in sequence.
As you have a loop, some instructions will get repeated...
You really should do this manually before using the simulator - you will learn more that way.
Your teacher should be able to demonstrate this to you.