On Fri, 13 Feb 2026 10:23:03 +0000
[email protected] wrote:

> On 2026-02-08 15:38, Martin Nicholas via Amforth-devel wrote:
> > SNIPPED  
> 
> Hi Martin,
> 
> Thank you. Added to the list.
> 
> A preliminary check of the archives shows that the way interrupts
> were handled by the VM changed between releases 6.4 and 6.5
> 
> In 6.4 there is
> brts DO_INTERRUPT
> 
> In 6.5 there is
> cp isrflag, zerol
> brne DO_INTERRUPT
> 
> The release notes for 6.5 [1] state that there was a bug in the 
> interrupt handling on the avr8. Erich discovered and fixed the bug,
> and so may be able to help. Current avr8 documentation references the
> T flag but does not reference isrflag, so this is something that will
> need to be updated.
> 
> The file avr8//drivers/generic-isr.asm shows considerable related 
> changes between the releases but I need more time to study it.
> 
> Best wishes,
> Tristan
> 
> [1] https://sourceforge.net/p/amforth/mailman/message/35814877/
> 

I think the change 6.4 -> 6.5 abandoned the T-flag as the pending
indicator, using the value in isrflag instead.
Is this Erich's fix? I don't know.
IMHO the best (fastest) solution is to use them both.

Certainly 6.9 has bugs in: /avr8/words/int-[on|off].asm and others, so
there are still problems lurking.

Should I explain the problem more? Here's the code for RP! from 6.9:
PFA_RP_STORE:
in temp2, SREG  ; (A)
; (B)
cli             : (C)
out SPL, tosl
out SPH, tosh
out SREG, temp2 ; (D)
; (E)
loadtos
jmp_ DO_NEXT

The I-flag is preserved at (A). Interrupts are disabled at (C),
restored again at (D).

If interrupts are disabled throughout, all is fine - no need to worry.
If interrupts are enabled and no interrupts occur throughout - again no
problem.

What if, however, interrupts are enabled and an interrupt occurs at
point (B)? At point (D), interrupts are re-enabled, using the state
from (A). This is a problem. A second interrupt at (E) or later will
overwrite the interrupt request, set at (B) with another - a pending
interrupt will be missed.

Similar problems arise wherever the I-flag is read/written/preserved.
In particular, -INT cannot be guaranteed actually to disable interrupts.
These things may also be problematic in other architectures where
"Interrupts the Forth way" is used - I've not looked.

Tristan - I'll email you some code, since attachments are not allowed
here.

-- 
Regards,

Martin Nicholas.

E-mail: [email protected] (Address will be valid throughout 2026).


_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to