Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: patrik on April 17, 2003, 02:13:58 PM
-
I am a beginner in AmigaOS system programming. I am writing a device and have a question about how interrupt-routines actually work in the AmigaOS.
As I understand you could write something like this to make an Interrupt structure ready for use:
struct Interrupt dummyINT;
UBYTE dummyINTData;
void DummyINTCode(void)
{
doblabla();
}
void main(void)
{
dummyINT.is_Data = &dummyINTData;
dummyINT.is_Code = DummyINTCode;
}
My question is: Are you supposed to access the is_Data segment from the is_Code routine in any special way?
Would really need some explanation on how this stuff actually works.
/Patrik
-
The code is called with the is_Data pointer in register a0, so your compiler must support something like "register __a0".
Also the interrupt does not run as part of your program's task, so if you use the small data model you have to initialize the base register prior to access any global variable. This is can usualy be told to the compile by the __saveds attribute.
In addition, if you write an interrupt server, your routine must signal if other servers should be called or not by setting the zero flag. Might be a bit tricky to do that in C.
So the correct declaration of your interrupt code is:
__saveds BOOL DummyINTCode(register __a1 struct mydata *data);
This is Dice C syntax, your compiler may be different.
You should really read the according sections in the RKRM manuals before you start experimenting.
Bye,
Thomas
-
Hi
Are you still interested in this?
Yesterday evening I dug my documentation (RKRM) for you. I was thinking about sending it to you, but I have packed it ad got 2,7MB archive, so I didn't know if you want it in your mailbox...
Thomas answer is quite good, but.
To be precise data pointer is in A1, not A0.
Yes, you have to use compiler with special support, or write some code in assembly.
I think that much better solution is to use data pointer and omit any globals. Remember that inside interrupt function you are very limited (you cannot allocate/free memory and it means all fuctions that may do it inside them). '__saveds' is also SASC keyword.
The interrupts are devided to be 'servers' and 'handlers'. Some are predefined to be used as 'handlers', other as 'servers'. You must be carefull not to install 'server' as 'handler' and vice-versa'.
Zero flag is important only with 'servers'. It shoud be done with 'return 0', as it should load D0 with 0. But yes, it might be tricky.
This is quite complicated and the good documentation is A MUST.
Good luck
-
I am definately still interested and would be very glad if you sent documentation to my mailbox :).
I am using SASC and it seems to be possible to access registers exactly like Thomas said.
The problems as always with C arises when you have to force it into doing something exacly in a certain way - as in this case. Is it possible that I would save myself a lot of cursing and swearing by writing the interrupt-routine in assembler right away? ;)
/Patrik
-
The complete documentation for Amiga interrupts
is contained in the book:
"Guru's Guide To The Commodore Amiga"
"Meditation #1 - Interrupts"
by Carl Sassenrath
published by Sassenrath Research in 1988
I'm not sure interrupts are a good place
for a beginner to start, but that's just
my opinion.
-
Do you know if it is possible to get hold of that book nowadays?
Those interrupts wont not kill me ;), though my amiga have to be prepared to hear some bad words and cursings ;). Have done a lot of programming on several kinds platforms - everything from small microcontrollers to big unix-boxes so I am not new to programming.
/Patrik
-
Get the Amiga-Dev CD.