Tuesday, April 28, 2020

Enable and disable interrupts on 1802.

Relies on a trick where X is set to P so that after a RET x is pointing to the byte beyond the RET and this is the pretend T that is usually on the stack at the end of a internet service routine.

   0000                 START ORG 0
   0000   7b            seq
   0001   f8 03          ldi $03 ;careful, we have some nops up there.
   0003   b2            phi 2 ;R2 is stack pointer
   0004   f8 45          ldi $45
   0006   a2            plo 2 ;R2=stack pointer now points to $00ff
   0007   e2            sex 2 ;X now pnts to R2, the stack pointer. 00ff
   0008                 loop0
   0008   f8 2d          ldi $2d ;want output this byte on channel 1
   000a   73            stxd
   000b   12            inc 2
                        ;here P=0 and X=2
   000c                 enableinterrupts
   000c   e0            sex 0 ;P=0 currently. Now X is too.
   000d   70            ret ;goes and gets T from stack, but stackptr is now R0
   000e   20            DB $20 ;ret will use this. Now P=0,X=2. Interrupts enabled
   000f                 disableinterrupts
   000f   e0            sex 0 ;P=0 currently.Now X is too.
   0010   71            dis ;
   0011   20            DB $20 ;dis will use this.Now P=0,X=2 and interrupts disabled
   0012                 loop1
   0012   61            out 1
   0013   30 12          br loop1
   0345                  ORG $345
   0345   11 22 33 0f    DB $11,$22,$33,$0f,$55
   0349   55           
   03fb                  ORG $3fb
   03fb   c4            nop
   03fc   c4            nop
   03fd   c4            nop
   03fe   c4            nop
   03ff   c4            nop
                       
   0400                  END
0000  START         000f  disableinterrupts    000c  enableinterrupts    0008  loop0   



0012  loop1       

No comments:

Post a Comment

Pi Pico and other Boards

 Got a new Pi Pico and it looks very promising. Want to use Oled display with it.