Hi,
I am currently learning how to write a classic Mac application for a little non-sense project of mine. The resulting app will be for both PowerPC and 68k using System 7.
Having read "Programming Starter Kit for Macintosh", which is a great book by the way, I have a good part of my app working. I am coding in plain C using CodeWarrior 6.
However, I am trying to write a TimeManager task that executes in a fixed interval. The PPC part is working good, but my problem is when I try to set the A5 world for the 68k code, as I have to access global variables in my task. I have defined a structure containing the TMTask information and a reference to the old A5 world:
typedef struct
{
TMTask tmTask;
long tmWakeUp;
long tmReserved;
long tmRefCon;
} TMInfo;
I have found the one example where the PPC part looks like this. it is working, because the TimeManager places the address of the TMTaskInfo passed to the InsXTime() function in the A1 register. What I don't understand is that, if I'm not mistaken, the pascal calling convention states that function parameters are passed on the stack, not in registers.
#if __POWERPC__
pascal void MyTaskRoutine(TMTaskPtr a1)
{
TMTaskInfo *recPtr = (TMTaskInfo*)a1;
// do stuff
PrimeTime((QElemPtr)&recPtr->tmTask, 1000);
}
#endif
In the same example there is a simple part for 68k written in assembler without using an A5 reference, but I can't get it to work with my own code.
The translated the Pascal Inside Macintosh examples, but I am getting a "missing ':' error" in the line where I call GetTMInfo():
asm TMInfo * GetTMInfo(void)
{
move.l a1, d0
rts
}
pascal void MyTaskRoutine(void)
{
TMInfo *recPtr;
long oldA5;
recPtr = GetTMInfo();
oldA5 = SetA5(recPtr->tmRefCon);
// do stuff
SetA5(oldA5);
PrimeTime((QElemPtr)&recPtr->tmTask, 1000);
}
I am sure I am missing a simple thing, but I can't seem to figure it out. I'd appreciate every hint!
Regards, Florian
I am currently learning how to write a classic Mac application for a little non-sense project of mine. The resulting app will be for both PowerPC and 68k using System 7.
Having read "Programming Starter Kit for Macintosh", which is a great book by the way, I have a good part of my app working. I am coding in plain C using CodeWarrior 6.
However, I am trying to write a TimeManager task that executes in a fixed interval. The PPC part is working good, but my problem is when I try to set the A5 world for the 68k code, as I have to access global variables in my task. I have defined a structure containing the TMTask information and a reference to the old A5 world:
typedef struct
{
TMTask tmTask;
long tmWakeUp;
long tmReserved;
long tmRefCon;
} TMInfo;
I have found the one example where the PPC part looks like this. it is working, because the TimeManager places the address of the TMTaskInfo passed to the InsXTime() function in the A1 register. What I don't understand is that, if I'm not mistaken, the pascal calling convention states that function parameters are passed on the stack, not in registers.
#if __POWERPC__
pascal void MyTaskRoutine(TMTaskPtr a1)
{
TMTaskInfo *recPtr = (TMTaskInfo*)a1;
// do stuff
PrimeTime((QElemPtr)&recPtr->tmTask, 1000);
}
#endif
In the same example there is a simple part for 68k written in assembler without using an A5 reference, but I can't get it to work with my own code.
The translated the Pascal Inside Macintosh examples, but I am getting a "missing ':' error" in the line where I call GetTMInfo():
asm TMInfo * GetTMInfo(void)
{
move.l a1, d0
rts
}
pascal void MyTaskRoutine(void)
{
TMInfo *recPtr;
long oldA5;
recPtr = GetTMInfo();
oldA5 = SetA5(recPtr->tmRefCon);
// do stuff
SetA5(oldA5);
PrimeTime((QElemPtr)&recPtr->tmTask, 1000);
}
I am sure I am missing a simple thing, but I can't seem to figure it out. I'd appreciate every hint!
Regards, Florian
Last edited by a moderator: