??? 04/15/07 18:27 Read: times |
#137297 - Not R6 and R7 Responding to: ???'s previous message |
Mike Stegmaier said:
doesn't RET pop the last two values off of the stack to form the new program coulter address?
Yes it does. I know I may be ridiculous with a few ajmp's but I'm just pointing out that it is important to terminate your code when it reaches the end. That's the point. Your program should not terminate... ever... You can continue your flow with an infinite loop. But that does not "end the execution" (sometimes referred to as "terminating") your program. Yes, I am nitpicking, but quite often confusion and misunderstanding is the result of incorrect use of terminology. (Not saying it doesn't happen to me). Here is a quote about RET from: http://www.win.tue.nl/~aeb/comp...html#51ret RET is used to return from a subroutine previously called by LCALL or ACALL. Program execution continues at the address that is calculated by popping the topmost 2 bytes off the stack. The most-significant-byte is popped off the stack first, followed by the least-significant-byte. which means that R7 and R6 form the address. According to the quote, the Program counter will equal address R7:R6 if the stack pointer is at 7h and RET is executed before a call. No, that would be R8 and R9. The manual states that the stack is by default initialised to 07H. It also states that prior to pushing to the stack, the stack pointer is incremented. That makes the first location R8, and the next location R9 Result is low adres byte in R8 and high byte in R9. But all of this is invalid as soon as your stack pointer is initalized to another startvalue. Or you had a prior call to subroutine or another (lower priority) interrupt, or a push instruction. In which case the statement referring to the stack pointer is true, but referring to R8 and R9 would be wrong. Just a matter of cautiousness in answering a question, and trying to provide an answer that is as generic as possible. IMHO thats better for beginners. Refering to specific R8 and R9 might confuse them. regards |
Topic | Author | Date |
RxD to LCD problems | 01/01/70 00:00 | |
Serial ISR | 01/01/70 00:00 | |
work needed. | 01/01/70 00:00 | |
you need to control flow | 01/01/70 00:00 | |
confused | 01/01/70 00:00 | |
this is what I mean | 01/01/70 00:00 | |
OK | 01/01/70 00:00 | |
yes | 01/01/70 00:00 | |
Non-useful Serial ISR | 01/01/70 00:00 | |
AND it's stuck | 01/01/70 00:00 | |
thanks | 01/01/70 00:00 | |
I was going for optimization. | 01/01/70 00:00 | |
It's functioning | 01/01/70 00:00 | |
now stay consistent | 01/01/70 00:00 | |
Terminating code? | 01/01/70 00:00 | |
. | 01/01/70 00:00 | |
correct terminology | 01/01/70 00:00 | |
Missing the point | 01/01/70 00:00 | |
i get it now | 01/01/70 00:00 | |
Most, but not all | 01/01/70 00:00 | |
why on earth | 01/01/70 00:00 | |
if it\'s almost correct, it\'s still wrong :-) | 01/01/70 00:00 | |
ok | 01/01/70 00:00 | |
Not R6 and R7 | 01/01/70 00:00 | |
well it happend again | 01/01/70 00:00 | |
Q.E.D. | 01/01/70 00:00 | |
One further comment is needed | 01/01/70 00:00 | |
Hey | 01/01/70 00:00 | |
Dangerous recommendation | 01/01/70 00:00 | |
good point | 01/01/70 00:00 | |
they all do![]() | 01/01/70 00:00 | |
it 'trust' the same as 'experiment'? | 01/01/70 00:00 | |
more issues | 01/01/70 00:00 | |
Joe, please read this | 01/01/70 00:00 |