Page 1 of 1

Disabling Interrupts

Posted: Tue Apr 16, 2019 3:26 am
by gray
First, let me thank you for your patience answering my barrage of questions. Highly appreciated!

Here's the next... How "atomic" is SYSTEM.PUT as regards interference by interrupts? In particular:

Code: Select all

(* irqICER, irqISER, irqSCBit: the ICER, ISER and bit (a SET) corresponding to the interrupt *)
 PROCEDURE* PutByte*(b: BYTE);
  BEGIN
    SYSTEM.PUT(irqICER, irqSCBit);
    txnext := (txin + 1) MOD TxBufSize;
    ASSERT(txnext # txout, Error.BufferOverflow);
    txBuf[txin] := b;
    txin := txnext;
    SYSTEM.PUT(irqISER, irqSCBit)
  END PutByte;
Is the first line a safe way to disable the interrupt?

Re: Disabling Interrupts

Posted: Tue Apr 16, 2019 12:43 pm
by cfbsoftware
The code generated by SYSTEM.PUT(irqICER, irqSCBit) is:

Code: Select all

mov      r10, irqICER
mov      r9,  irqSCBit
str      r9,  [r10]
or, depending on the value of irqICER, it could be:

Code: Select all

ldr      r10, [pc+offset]  <Const:0>
mov      r9,  irqSCBit
str      r9,  [r10]
...
<Const:0>   irqICER
As far as I know that is about as optimal as it could be with the Thumb-2 instruction set.