Well, actually I don't see a problem with using global variables for
saving/restoring the data regs, but you're right, using the stack would be an
alternative.
However, pushing them on the stack just with a movem.l in the startup routine is
impossible - my StartApplication() first pushes the return value onto the stack
before any code, a further push without a corresponding pop would corrupt it. We
could solve this with a prologue, but this is still somewhat dirty.
Anyway, there is a very simple way: In PilotMain(), I just use local variables
for saving/restoring the regs. That should be safe enough.
Cheers,
--Hans--
Aaron Ardiri wrote:
> > > have you thought about pusting these registers to the stack
> > > in InitApplication() and then popping them off the stack in
> > > QuitApplication() :)
> >
> > A good idea! I was just thinking about recompiling the startup code of the
> > prc-tools, when I read your answer... Ok, now I wrote:
> >
> > static u8 d45;
> > static Err StartApplication() {d45 = reg2; ...; return 0;}
> > static void StopApplication() {...; reg2 = d45;}
> >
> > and...it works. No overlocked chunks any more!
>
> well, i probably would have pushed it on the stack.. your using a
> global variable here.. have you tried resetting the device? i
> bet it'll crash.. you cannot have globals always..
>
> use a 'pushm ' statment
>
> :)
>
> > In StartApplication d45 becomes 0x0004008E00000000. Thus, D4 seems to hold
> > somewhat very important.
>
> yes, as john replied (you probably haven't got it yet), d4 is used to
> hold some data.
>
> > > you can use a3 and a4 :) heh
> >
> > Well, aren't a5 and a7 a better choice? ;-)
>
> heh.. a7 for sure..
>
> > Thank you very much for your help.
>
> no problems.. however, i would rethink what you have done now and
> do something like this:
>
> InitApp:
>
> // save d4 register - need it later
> asm("movem.l %%d4, -(%%sp)" : : );
>
> QuitApp:
>
> // restore d4 register - need it now
> asm("movem.l (%%sp)+, %%d4" : : );
>
> of course, make sure you dont mess the stack up in your app
>
> // az
> [EMAIL PROTECTED]
> http://www.ardiri.com/ <--- free games!
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/