Disabling interrupts

News,announcements,programming,fixes,game patches & discussions.

Moderator: troed

Post Reply
User avatar
exxos
Site Admin
Site Admin
Posts: 23488
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Disabling interrupts

Post 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
https://www.exxosforum.co.uk/atari/ All my hardware guides - mods - games - STOS
https://www.exxosforum.co.uk/atari/store2/ - All my hardware mods for sale - Please help support by making a purchase.
viewtopic.php?f=17&t=1585 Have you done the Mandatory Fixes ?
Just because a lot of people agree on something, doesn't make it a fact. ~exxos ~
People should find solutions to problems, not find problems with solutions.
User avatar
thorsten.otto
Posts: 148
Joined: Mon Nov 04, 2019 2:20 am

Re: Disabling interrupts

Post 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.
User avatar
exxos
Site Admin
Site Admin
Posts: 23488
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: Disabling interrupts

Post by exxos »

thorsten.otto wrote: Thu Apr 09, 2020 6:01 pm 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..
https://www.exxosforum.co.uk/atari/ All my hardware guides - mods - games - STOS
https://www.exxosforum.co.uk/atari/store2/ - All my hardware mods for sale - Please help support by making a purchase.
viewtopic.php?f=17&t=1585 Have you done the Mandatory Fixes ?
Just because a lot of people agree on something, doesn't make it a fact. ~exxos ~
People should find solutions to problems, not find problems with solutions.
User avatar
exxos
Site Admin
Site Admin
Posts: 23488
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: Disabling interrupts

Post by exxos »

thorsten.otto wrote: Thu Apr 09, 2020 6:01 pm 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 ?
https://www.exxosforum.co.uk/atari/ All my hardware guides - mods - games - STOS
https://www.exxosforum.co.uk/atari/store2/ - All my hardware mods for sale - Please help support by making a purchase.
viewtopic.php?f=17&t=1585 Have you done the Mandatory Fixes ?
Just because a lot of people agree on something, doesn't make it a fact. ~exxos ~
People should find solutions to problems, not find problems with solutions.
User avatar
thorsten.otto
Posts: 148
Joined: Mon Nov 04, 2019 2:20 am

Re: Disabling interrupts

Post 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.
User avatar
exxos
Site Admin
Site Admin
Posts: 23488
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: Disabling interrupts

Post by exxos »

thorsten.otto wrote: Wed Apr 15, 2020 3:37 pm 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.
https://www.exxosforum.co.uk/atari/ All my hardware guides - mods - games - STOS
https://www.exxosforum.co.uk/atari/store2/ - All my hardware mods for sale - Please help support by making a purchase.
viewtopic.php?f=17&t=1585 Have you done the Mandatory Fixes ?
Just because a lot of people agree on something, doesn't make it a fact. ~exxos ~
People should find solutions to problems, not find problems with solutions.
User avatar
thorsten.otto
Posts: 148
Joined: Mon Nov 04, 2019 2:20 am

Re: Disabling interrupts

Post 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.
Post Reply

Return to “SOFTWARE PROGRAMMING & DISCUSSION”