Page 1 of 1
Disabling interrupts
Posted: 09 Apr 2020 17:37
by exxos
Can anyone shed any light on this code which disables interrupts. Really I want to know if this works fine for TOS104 and TOS206 on a 68000 CPU.
Code: Select all
sys_sleep:
lea sys_state(pc),a0
ori.w #$0700,sr
move.l $70.w,(a0)+
move.l $114.w,(a0)+
lea new_vbi(pc),a1
move.l a1,$70.w
lea new_tc(pc),a1
move.l a1,timerc.w
andi.w #$f3ff,sr
rts
Re: Disabling interrupts
Posted: 09 Apr 2020 18:01
by thorsten.otto
Its cleaner to save the old value of SR, and restore it at the end, rather than just doing andi $f3ff,sr. Depending on where you call your code, interrupts might have already been disabled before, or the mask being set to a different value than 3, and then you would unintentionally enabling them.
Other than that, it looks ok to me.
Re: Disabling interrupts
Posted: 09 Apr 2020 20:04
by exxos
thorsten.otto wrote: 09 Apr 2020 18:01
Its cleaner to save the old value of SR, and restore it at the end, rather than just doing andi $f3ff,sr. Depending on where you call your code, interrupts might have already been disabled before, or the mask being set to a different value than 3, and then you would unintentionally enabling them.
Other than that, it looks ok to me.
Cool thanks.
I never thought calling the code twice could enable them again..
Re: Disabling interrupts
Posted: 15 Apr 2020 14:36
by exxos
thorsten.otto wrote: 09 Apr 2020 18:01
Its cleaner to save the old value of SR, and restore it at the end, rather than just doing andi $f3ff,sr. Depending on where you call your code, interrupts might have already been disabled before, or the mask being set to a different value than 3, and then you would unintentionally enabling them.
Can you explain how to enable and disable the interrupts like that code does ? When I poke in STOS I get back $E03662.. I have no idea what that number is for or what bits to change ?
Re: Disabling interrupts
Posted: 15 Apr 2020 15:37
by thorsten.otto
Code: Select all
sys_sleep:
lea sys_state(pc),a0
move.w sr,d0 <-- save old value
ori.w #$0700,sr
move.l $70.w,(a0)+
move.l $114.w,(a0)+
lea new_vbi(pc),a1
move.l a1,$70.w
lea new_tc(pc),a1
move.l a1,timerc.w
move.w d0,sr <-- restore old interrupt mask
rts
That's all i suggested to change.
Re: Disabling interrupts
Posted: 15 Apr 2020 15:39
by exxos
thorsten.otto wrote: 15 Apr 2020 15:37
That's all i suggested to change.
Yeah, though I didn't program that ASM code, so no idea what its really doing. I need to be able to do this in HISOFT BASIC.
Re: Disabling interrupts
Posted: 15 Apr 2020 15:46
by thorsten.otto
I don't know hisoft basic, but i would be surprised if you have access to the SR register there. And the interrupt routines that are installed there must be written in asm, anyway, since they must return with rte, and must not change any registers.