This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Start167.a66 and STKUN initializing

In start167.a66 file, I find following assembler instruction:

MOV STKOV,#(_BOS+6*2) ; INITIALIZE STACK OVFL REGISTER

Why the 6*2?

I could understand 4*2 because of automatic push/pop of PSW, CSP and IP (when interrupting) and one extra because of non-inclusive aspect.

Can anyone give explanation or reference to a manual?

Thanks, Bjorn

Parents
  • Chris,

    Thanks for the quick response. I'm gonna shoot some more questions just to be absolutely sure i understand the concept.

    So when an interrupt is generated and 3 words are pushed to the stack: is the SP compared with STKOV for each of the 3 pushes?

    My guess is that it will only be compared by the next "explicit" push/pop instruction and not during pushing/popping for the interrupt.

    If the interrupts don't contain push/pop commands and the stack is completely full (aka SP = STKOV) and more than 2 interrupts are executed, part of your memory will be corrupted without stack overflow interrupt?

    So in this sence the 6*2 is a some kind of safety parameter?

    As a side note: Since the stack overflow interrupt is only triggered for equation of SP with STKOV before write operation, generation of an interrupt with push/pop functionality inside, and with full system stack will also not generate stack overflow interrupt? So why not broaden this equation test towards a "lesser than or equal" test (for stacks growing down)?

    Thanks in advance!

Reply
  • Chris,

    Thanks for the quick response. I'm gonna shoot some more questions just to be absolutely sure i understand the concept.

    So when an interrupt is generated and 3 words are pushed to the stack: is the SP compared with STKOV for each of the 3 pushes?

    My guess is that it will only be compared by the next "explicit" push/pop instruction and not during pushing/popping for the interrupt.

    If the interrupts don't contain push/pop commands and the stack is completely full (aka SP = STKOV) and more than 2 interrupts are executed, part of your memory will be corrupted without stack overflow interrupt?

    So in this sence the 6*2 is a some kind of safety parameter?

    As a side note: Since the stack overflow interrupt is only triggered for equation of SP with STKOV before write operation, generation of an interrupt with push/pop functionality inside, and with full system stack will also not generate stack overflow interrupt? So why not broaden this equation test towards a "lesser than or equal" test (for stacks growing down)?

    Thanks in advance!

Children
  • As an answer to my own post:

    You need to reserve space for 2 interrupt routines being the stack overflow interrupt routing and the NMI interrupt routine. The NMI interrupt routine is the only interrupt routine that can interrupt the stack overflow interrupt routine.

    Details found in C167CR user manual.

    PS: This assumes that no system stack is used (no calls made) in stack overflow and NMI interrupt implementation.

    Regards, Bjorn