dcole@guru.pub.uu.oz.au (Dave Cole) (02/17/91)
I have been trying to get an input handler working without much success. I can make the handler discard all mouse events, but as soon as I try to pass a message from the handler to the mainline via PutMsg() I get a guru (00000003 - Odd address). I have no idea where the odd address is coming from. In the mainline I initialise a message port and an array of messages to be used by the handler for passing Input Events to the mainline. All of this data is stored in a structure which is passed via the ADDHANDLER input device command. The code does not guru if I comment out the PutMsg() statement in the handler function. I have based my code on the example in the RKM, but they do not pass messages from their handler, they use signals. The doco says that you can call PutMsg() from your handler. What can I be doing wrong. Any suggestion would be appreciated. All of the examples I have seen create a Timer which feeds into the Input Device. I have assumed that you only do this if you require a time-out, and have not put one in my code. Thanks in advance - Dave.
jimm@amiga.UUCP (Jim Mackraz) (02/18/91)
In article <54kHX1w163w@guru.pub.uu.oz.au> dcole@guru.pub.uu.oz.au (Dave Cole) writes:
)I have been trying to get an input handler working without much success.
)I can make the handler discard all mouse events, but as soon as I try to
)pass a message from the handler to the mainline via PutMsg() I get a
)guru (00000003 - Odd address). I have no idea where the odd address is
)coming from.
Input handlers are called by the input.device, so if you're using
small code and small data it's common to get a crash like this.
With small data and maybe sometimes small code, the compiler assumes
that register A4 remains as set up by your program's initialization.
The value found in A4 by your input handler will be something different,
whatever the input.device happened to be using.
So whenever your program is called from the outside world, you have
to set up A4 if you use small data. With Lattice/SAS, you
can use the __saveds function attribute for the handler's entry
routine. For Manx, you used to be able to call geta4().
Assuming you refer to the target message port of PutMsg() by using
a global variable, then failing to set up A4 would definitely
screw you if you use small data. If you use no other globals, then
commenting out the PutMsg() may well make you live.
Another possibility is if your compiler doesn't believe in the
same register preservation rules that are decreed in
the Amiga RKM. Older versions of Manx (new ones too?) had a different
scheme, and your entry point of your handler has to explicitly
save and restore these registers, in assembler.
If you have this small data all taken care of, then maybe the port
isn't set up (if you didn't call CreatePort, perhaps you forgot the
NewList() ). Maybe you can PutMsg() one from the main task as
a warm up, to eliminate the input handler voodoo from the equation.
jimm
--
--- opinions expressed herein are my own. ---
"... Because they can."
- profound punchline to joke about dogs