Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - FAQ - Zum CC1-Forum - Zum CC-Pro-Forum

Communicatiob with ASM routine Kategorie: Progr. Assembler, TaskingTools, OS (von Eric - 30.07.2001 17:24)


To communicate with a assembly routine, the following code can be used:

type ASM_PAR
{
int par1;
int par2;
int par3;
int par4;
}

ASM_PAR par;

function AsmCall( int offset, ASM_PAR par )
{
/* Store pointer to parameters in R1.
Register bank starts at 0xf600 in internal ram.
So R1 is accessable via 0xf602
*/
inline vmcodes.VM_LOAD_LOCAL_INT;
inline -6;
inline vmcodes.VM_STORE_ABSOLUTE_INT;
inline 0xf602;

system.call( 3, offset );

} // AsmCall


tread main
{
int i;

par.par1 = 0x4711;
AsmCall( 0x0000, par );
i = par.par2;
}

As variables of a user defined type are passed by reference, this address can be passed on to the assembly routine.
In the assembly routine the address is available in the R1 register. In assembly the following instructions can be used
to read/ a parameter (located in segment 8):

EXTS#8, #2
MOVR2,[R1]; Read par1
MOV[R1+2], R2; Copy to par2

POP R1; Pop the faulty return address
POP R1; from the stack
RETS

Both POP instructions are needed to correctly return to the C2 code (because of a bug in the system.call() function).


    Antwort schreiben


Antworten: