Delay: ( this is a label.. This constitutes the beginning of the routine... You can "Call" a label or you can "jmp" a label.. If you "Call" a routine you MUST return "ret"..
If you "jmp" a label you MUST jmp back... There are a few types of "Call" and "jmp" commands.. Long.. lcall and ljmp there is absolute... acall and ajmp... You can also have a short jmp sjmp.... all these depend on how far you are calling and jumping..
mov R1.#010h... Move direct command.. place 0x10h ( 16 decimal ) into Resister R1.. mov R2,#010h... Move direct command.. place 0x10h ( 16 decimal ) into Resister R2..
dznz R2,Dy2... Decrease R2 by one and only jump to labe1 Dy2 if the register R2 is not zero dznz R1,Dy1... Decrease R1 by one and only jump to labe1 Dy1 if the register R1 is not zero
If both registers are zero the last command ret returns to the calling routine..
It's been quite some time you're away from your thread.
Here, let me try to explain the above program with a picture attached. In a stadium, there are 2 gates "A" & "B". Mr. "R1" is the gatekeeper of gate "A" & Mr. "R2" is the gatekeeper of Gate "B". You are a runner.
When you enter Gate "A", Mr R1 hands you a letter and asks you to report to Mr R2 at gate "B". When you're at gate "B" Mr R2 read the letter and give you 16 apples. You have to go round the track colored in red and on each round drop one apple into a basket.
After you've run the track 16 times and finished dropping 16 apples, you go to Mr R1 through Gate "B" and get another letter with same contents from Mr R1.
This will repeat 16 times as Mr R1 only has 16 letters. So you dropped a total of 16x16 = 256 apples onto the basket. After that you exit through Gate "A" and complete the job.
That is roughly what the program is doing and it acomplished nothing except wasting time. If you want to delay more time you can either increase the number of apples on the track or increase the number of letters. Or you can add jobs to do while you're runing on the track like this:
I think electro has given up... He has a new thread on AAC , I think my teaching skills are rubbish.... Anyway, you seem to have grasped the syntax fairly well... I'm glad John is helping as well.... If you need to move onto C, just let me know..
Hi Ian, I'm don't. I am still see the thread to find something new everyday.. for my understanding..... you are too ahead of me and I'm too behind you to catch up what you were said in the previous comments....
Explain to me what you think you need to see.... I now assume I have to step it down a little... We need to go through the commands one by one..
Do you know how the basic MPU model works... ALU, Register addressing, moving / loading? Or do you only want to know assembler and the programming model up?
The tutorial and instruction sets are good for beginner in 8051 who have prior experience in mcu. It is good for reference when programming the 8051. There are too little example codes to explain how each instruction work.
Hi ikelectro,
I suggest you also read the MCS51 Family Users Guide by Intel. It is a 144 page file and has great details on the 8051. I also learn by reading the past threads on 8051 in this forum. There are so many posts I have not finished reading them yet.
If I find any books that has a lot of examples on how each instruction works, I'll list them here for your reference. I have one book I borrowed from my friend on 8051 with examples on the proteus but it was written in Chinese, so I won't recommend it to you. But it has examples in ASM and C so I think it is a very good book for me.
Hi Ian, thanks for your reply. As you know I have started a new thread on other forum. I wish to continue both. Hope you don't mind.
Do you know how the basic MPU model works... ALU, Register addressing, moving / loading? Or do you only want to know assembler and the programming model up?