Re: [hatari-devel] Changes to STOP/LPSTOP instruction

[ Thread Index | Date Index | More Archives ]

Le 09/11/2017 à 11:26, Toni Wilen a écrit :
Wouldn't that stack the new SR without the S bit set in the exception
frame, although the instruction itself was executed in supervisor mode,
and thus return to user mode, if the handler executes an RTE? That would
really be strange.

Yes, that is exactly what happens! (real 68000 confirmed, it is 68000
undocumented feature)

@Thorsten : here're some real values I measured on my 68000 STF

SR=2700 STOP 555 SR_NEW=2515 SR_STACK=0515 PC_STACK=STOP+4 SR=2700 STOP 777 SR_NEW=2717 SR_STACK=0717 PC_STACK=STOP+4

SR=700        STOP 555        SR_NEW=2700     SR_STACK=0700   PC_STACK=STOP
SR=700        STOP 777        SR_NEW=2700     SR_STACK=0700   PC_STACK=STOP
SR=7ff        STOP 777        SR_NEW=271F     SR_STACK=071F   PC_STACK=STOP

The test is to set a privilege violation exception handler (addr $20) and to save SR_NEW (value of SR at the start the privilege exception handler) as well as the stacked values

We can see that when S=0 before the STOP, we have a "normal" priv exception with expected values from the doc ; but when S=1 before the STOP but S=0 in the STOP value then the stacked value is the one with the S=0 bit, which means that after a RTE in the priv handler you will be in user mode, so you might have the feeling that STOP worked and ended on the correct interrupt condition, but in fact it was just the priv exception that triggered "immediately". Weird behaviour :)

Mail converted by MHonArc 2.6.19+