Discussion Forum

Start167.a66 and STKUN initializing

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Bjorn Aelvoet
Posted
13-Feb-2009 15:15 GMT
Toolset
C166
New! 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

Read-Only
Author
Chris Wunderlich
Posted
16-Feb-2009 02:22 GMT
Toolset
C166
New! RE: Start167.a66 and STKUN initializing

From the users manual

Set the stack overflow pointer (STKOV) to the limit of the defined internal stack area plus six words (for the reserved space to store two interrupt entries).

Read-Only
Author
Bjorn Aelvoet
Posted
16-Feb-2009 07:36 GMT
Toolset
C166
New! RE: Start167.a66 and STKUN initializing

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!

Read-Only
Author
Bjorn Aelvoet
Posted
16-Feb-2009 10:57 GMT
Toolset
C166
New! RE: Start167.a66 and STKUN initializing

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

Next Thread | Thread List | Previous Thread Start a Thread | Settings