Hi there,
Has anyone out there successfully created themselves a new stack on the
fly?
Here's what I'm trying to do:
1. assembly function (declared inline) to setup A7 and return its
present value.
asm DWord Teenee::SetA7(DWord inNewA7)
{
move.l sp, d0
move.l (sp), sp
}
2. Code that allocates a bit of heap for my new stack and then performs
the setting and resetting of stack:
CharPtr theNewStackP = static_cast<CharPtr>(::MemPtrNew(1024));
ReturnErrIfZero_(theNewStackP, dmErrMemError);
MemPtrFreeSentry theNewStackPSentry(theNewStackP);
DWord theAppStack = SetA7(static_cast<DWord>(theNewStackP + 512));
theAppStack += 4;
SetA7(theAppStack);
The last SetA7 successfully restores the sp to what it was prior to the
first SetA7. However things go very wonky when theNewStackP is
deallocated. The memory manager reports that the heap is invalid.
I am especially confused given that only the PC, A7 and D3 (theAppStack)
appear to be effected.
Any ideas?
--
Christopher Hunt
Class Action Pty. Ltd.
Are you a time zone traveler that owns a Palm(tm) connected organizer?
Check out http://www.classactionpl.com/TimeTraveler/index.htm