🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #27433

Re: interrupt handling with Megamax C

#27433
From: Peter Taliancich
Date: Tue, 30 Jun 1987 17:40
114 lines
2738 bytes
Hello,

	The problem you are having with the Megamax inline asm{} is that you are
attempting to use a '$' for hex when in the compiler hex is '0x'.  Below is
a listing that should help you on your way with using the interrupt routine
with Megamax C.

<<-- Cut Here -->>

#include <osbind.h>


#define MyApp	0  /*  my application  		   */
#define Control	7  /*  divide by 200 prescale  */
#define Data	0  /*  Countdown from	       */
#define Off		0
#define NULL	0L


extern  dispatcher();	/* labels in in-line assembly must be declared. */
extern  saveA4();
extern  set_timer();
extern  unset_timer();


long ticks;			/* local tick counter.					*/


/*
	This routine is called by the interrupt handler to increment the 
	local tick counter.
*/
ticker()
{
	ticks++;
}


main()
{
	set_timer();		/* turn on timer */

	/*
		Keep on ticking...
	*/
	while(ticks < 500)
		printf("ticks == %ld\n", ticks);

	unset_timer();		/* turn off timer */
}




/* 
	This is the interrupt dispatcher routine.
*/
asm {
saveA4:
			dc.l	0			/* reserve space for saving the A4 register */

dispatcher:
			move.l	A4, -(A7)   /* save registers used in interrupt routine */
			move.l	saveA4, A4

			jsr		ticker		/* our function								*/

			move.l	(A7)+, A4   /* restore register state 					*/
			bclr.b	#5,0xfffa0f /* Tell MFP the interrupt has been serviced	*/
			rte		 			/* return from exception					*/
}


/*
	This function is callled by the main() function to set up the
	application the 68901.
*/
set_timer()
{
	register	char	*globals;


	/*
		Save the Globals register A4 so that it can be restored during
		the timer interrupt.
	*/
	asm {
			lea		saveA4, globals
			move.l	A4, (globals)
	}

	/*
		Tell the timer chip to call the dispatcher routine for the interrupt.
	*/
	Xbtimer(MyApp, Control, Data, dispatcher);
}


/*
	Turn off the timer and reset the terminate vector.
*/
unset_timer()
{
	/*
		Turn off the application timer.
	*/
	Xbtimer(MyApp, Off, Off, NULL);
}
-- 
peter@megamax

uucp:	{texsun,killer,infotel}!pollux!megamax!peter
voice:	(214) 987-4931
Technical Details
Message-ID: <826@megamax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!ut-ngp!infotel!pollux!megamax!peter
References: <102@dalcsug.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!ut-ngp!infotel!pollux!megamax!peter
From: peter@megamax.UUCP (Peter Taliancich)
Newsgroups: comp.sys.atari.st
Subject: Re: interrupt handling with Megamax C
Message-ID: <826@megamax.UUCP>
Date: Tue, 30-Jun-87 13:40:43 EDT
Article-I.D.: megamax.826
Posted: Tue Jun 30 13:40:43 1987
Date-Received: Sat, 4-Jul-87 08:16:45 EDT
References: <102@dalcsug.UUCP>
Reply-To: peter@megamax.UUCP (Peter Taliancich)
Organization: Megamax, Inc; Dallas, TX
Lines: 114
Keywords: Megamax C