Reputation: 957
this is part of my final exam. I was provided with the following code and was asked about its behaviour. In the code we can clearly see that there is no branching out (ie. call
or an interrupt), and according to my knowledge this means that the Program Stack is empty. Yet at the end of the code there is a goto $
which directs the compiler(?) to whatever is atop of the (empty) stack.
Could anyone tell me what behaviour to expect in cases like these in general and how would it behave in the code below in particular. Taking in account we are working on a PIC16F877.
Thank you.
Upvotes: 0
Views: 163
Reputation: 13690
I don't know how you make the relation from $
to the stack.
The $
is used to refer the current address. You can write:
any_label: jmp any_label
or skip the label and use $
jmp $
Since $
is the current address, both Assembler Statements create the same code. It is used to stop the execution of the program running in an endless Loop.
The CPU doesn't stop and cycles at the same address and consumes power. Some CPUs migh have a power saving mode what might be better in this Situation.
Upvotes: 2