🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #686

software "exceptions"

#686
From: Frank J. Edwards
Date: Tue, 01 Aug 1989 20:07
71 lines
2531 bytes
I've been trying to use the Amiga's signalling system to cause an
"exception" (thats CBM's term, not Motorola's).  The idea is not
to have to perform a Wait() for the CLOSEWINDOW gadget or to
poll the tc_SigRecvd member of the Task Control Block...

Perhaps someone can shed some light on why my exception handler
doesn't work.  The code that I *was* going to use was much more
ambitious than this.  In trying to make something work, I've gotten
it simplified down to what you see here:

Compiled under Manx 3.6a with
 % cc setup.c
 % ln test.o setup.o -o test -lc
 % test
 <Visit from the "Task Held" requester follows...>
--------------------------------------------------------------------

long flag;

#asm
_except:
	moveq.l	#99,d1		; this is to let me know it worked!
	move.l	d1,_flag
	rts
#endasm

setup_excp(port)
struct MsgPort *port;
{
	extern void except_hndlr(), (*old_handler)();
	struct Task *FindTask(), *task;

	sig = 1L << port->mp_SigBit;
	task = FindTask(0L);

	/*
	 *  old_handler is used at termination to put back
	 *  the address that used to be there...
	 */
	old_handler = (void (*)()) task->tc_ExceptCode;
	SetExcept(sig, sig);
	(void (*)()) task->tc_ExceptCode = except_hndlr;

	/*
	 *  Now whenever I receive a message on "port",
	 *  my exception handler should be called...
	 *
	 *  The Signal() call *forces* me to get a signal.
	 *  [Although testing seems to indicate that there
	 *  may be a bug in the Manx stub for Signal() since
	 *  the tc_SigRecvd variable doesn't change!]
	 */
	Signal( task, sig );

	Delay( 50L );
	printf("flag = %ld\n", flag);
	return( 0 );
}
--------------------------------------------------------------------

Well, if you see the problem please let me know!  I'm tear'in my
hair out try to find it (and I can't afford to lose much more :-)

Thanks net.folks!

--
#include <std/disclaimer.h>	/* My employer isn't even involved! */

Frank J. Edwards		ComputerKnowledge Corporation
2677 Arjay Court		12740 Hillcrest Rd, Suite 212
Palm Harbor, FL  34684-4505	Dallas, TX  75230      (800) 385-9700
Technical Details
Message-ID: <143@ckctpa.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!pdn!boake2!

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!pdn!boake2!
From: crash@ckctpa.UUCP (Frank J. Edwards)
Newsgroups: comp.sys.amiga.tech
Subject: software "exceptions"
Summary: HELP! Why doesn't this code work?
Message-ID: <143@ckctpa.UUCP>
Date: 1 Aug 89 20:07:00 GMT
Followup-To: comp.sys.amiga.tech
Organization: ComputerKnowledge Corp, Clearwater FL
Lines: 71