| _ _ S A V E A 4 ( )
| | | | | SOURCE: qdev_macros.txt 1.16 (12/09/2014) English
AMIGA - PUBLIC
----------------------------------------------------------------------------
NAME
__SAVEA4() - Saves the contents of a CPU register A4 in
the variable given.
SYNOPSIS
__SAVEA4(val);
__SAVEA4([LONG]);
FUNCTION
This macro allows to store the contents of A4 m68xxx CPU
register in a variable for later use. This macro is only
active when binary model requested in 'gcc' is '-resident'
or '-resident32' and the define '-Dresident' was passed.
INPUTS
val - Var.(not its address!) that will keep the contents
of the register.
RETURNS
No output.
BASES
None.
NOTES
Use this macro when compiling so called pure executables
when the parent proc. spawns some children and they need
to access parent's globals(prior to A4!).
The macro will be a stub when binary model is just reloc
so it can stay in the code independently of the setting.
SEE ALSO
__LOADA4()
EXAMPLE
#include <proto/exec.h>
#include <exec/execbase.h>
#include <proto/dos.h>
#include <proto/alib.h>
#include <qdev.h>
struct mystruct
{
LONG ms_a4;
LONG ms_sync;
void *ms_tc;
};
void subtask(void)
{
struct ExecBase *SysBase = (*((struct ExecBase **) 4));
struct mystruct *ms;
Wait(SIGBREAKF_CTRL_C);
if ((ms = SysBase->ThisTask->tc_UserData))
{
__LOADA4(ms->ms_a4);
/*
* Can now use all the bases parent did initilize.
*/
...
Forbid();
ms->ms_sync--;
Signal(ms->ms_tc, SIGBREAKF_CTRL_C);
}
RemTask(SysBase->ThisTask);
}
int main(void)
{
struct Task *tc;
struct mystruct ms;
__SAVEA4(ms.ms_a4);
ms.ms_sync = 0;
ms.ms_tc = SysBase->ThisTask;
if ((tc = CreateTask("subtask", 0, subtask, 4096)))
{
ms.ms_sync++;
tc->tc_UserData = &ms;
Signal(tc, SIGBREAKF_CTRL_C);
}
/*
* Wait for the 'subtask()'s to be complete. This is
* the best way when spawning multiple children.
*/
while (ms.ms_sync)
{
Wait(SIGBREAKF_CTRL_C);
}
return 0;
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |