From: Matthias T. <mt...@we...> - 2013-02-16 17:57:56
|
Hi, > "-int" (int-off.asm) counterpart is "int_restore" (int-restore.asm). So, > why is this "int_restore" header commented out, i.e., not available to > the high level? uhm. yes. These words are one of very first ones, that fell out of scope later on. > Candidly, as "+int" (int-on.asm) is a simple SEI instruction (Set Global > Interrupt Flag) one would expect "-int" to be a simple CLI (Clear Global > Interrupt Flag) but this is not the case... > > May I suggest: > > +int → SEI > -int → CLI Thats fine. > int_suspend → ( -- SREG ) CLI > int_restore → ( SREG -- ) These words are not really needed. \ get the I flag as a forth flag : int? SREG c@ SREG_I and 0> ; \ to be used in pairs within the same colon definition \ can be nested : critical[ int? r> swap >r >r \ keep the current state -int \ turn interrupts off drop \ currently the content of SREG. ; : ]critical r> r> if +int then >r \ will crash if not matched ; \ test case. foo prints bar-1 baz0 qux-1 : bar ." bar" int? . ; : baz ." baz" int? . ; : qux ." qux" int? . ; : foo bar critical[ \ nothing will disturb us here baz ]critical \ now interrupts or other things may happen again qux ; |