Loading ...
Sorry, an error occurred while loading the content.

Re: [cosmacelf] Re: disabling/enabling interrupts

Expand Messages
  • Lee Hart
    ... If you have a register to dedicate to the interrupt handler s stack, that s a clean way to do it. But you can also use the main stack, as long as you make
    Message 1 of 44 , Feb 7, 2013
    • 0 Attachment
      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 running
      > with interrupts.

      If you have a register to dedicate to the interrupt handler's stack,
      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*
      address).
      - when increasing the stack pointer, write to the low byte first,
      then to the high byte (so again, it momentarily jumps to a
      *lower* address).

      --
      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
    • bill rowe
      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
      Message 44 of 44 , Feb 19, 2013
      • 0 Attachment
        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


        To: cosmacelf@yahoogroups.com
        From: ted_rossin@...
        Date: Tue, 19 Feb 2013 19:25:40 +0000
        Subject: [cosmacelf] Re: disabling/enabling interrupts

         
        I 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 cosmacelf@yahoogroups.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.
        >


      Your message has been successfully submitted and would be delivered to recipients shortly.