Re: [cosmacelf] Re: disabling/enabling interrupts
- On 2/7/2013 12:24 PM, bill rowe wrote:
> right. I'm going to switch to another register for my sp if i'm runningIf you have a register to dedicate to the interrupt handler's stack,
> with interrupts.
that's a clean way to do it.
But you can also use the main stack, as long as you make sure the stack
pointer always points to available stack space even while the high and
low bytes are being changed. If your stack grows down (lower addresses
as bytes are pushed onto it), then
- when decreasing the stack pointer, write to the high byte first,
then to the low byte (so it momentarily jumps to a *lower*
- when increasing the stack pointer, write to the low byte first,
then to the high byte (so again, it momentarily jumps to a
For every complex problem, there is a solution that is simple, obvious,
and wrong. -- H.L. Mencken
Lee A. Hart, http://www.sunrise-ev.com/LeesEVs.htm
- Ted: I've ended up using the technique of adjusting the high byte of the stack register before the low byte when subtracting and the reverse on adding. I think it's bullet-proof.By the way, I note from yoour examples that you were actually able to run interrupt service routines written in C. Nice work. I continue to be impressed with how well tailored to the 1802 environment your compler is.bill
Date: Tue, 19 Feb 2013 19:25:40 +0000
Subject: [cosmacelf] Re: disabling/enabling interruptsI ran into the same problem with my C compiler. I used a separate stack pointer register. This is a must if using the 1861 as you can't disable interrupts or you might miss a display update and delay it and cause screen tearing. When I tried to have my main code deal with this it caused code bloat (not that I didn't already have major problems here).
--- In email@example.com, "bill_rowe@..." wrote:
> The C compiler currently uses the live 1802 stack for variable storage. At the beginning of each C function it subtracts a good-sized number from sp to reserve space and adds it back at the end to free it. If this got interrupted it would end badly.
> I was going to bracket the sp manipulations with enable/disable interrupts but dis/ret seems pretty disruptive. Is there another solution? I need something like:
> glo sp
> smi 17
> plo sp
> ghi sp
> smc 0
> phi sp
> the subtracted number could be pretty big so a decrement loop probably wouldn't work.
> My alternative is to use another register as a frame pointer but i don't want to do that right now.