mirror of
https://github.com/UberGames/ioef.git
synced 2025-01-18 23:21:37 +00:00
* Sort out the white space disaster in vm_ppc.c
This commit is contained in:
parent
60ed7a4cc4
commit
d47509b861
1 changed files with 1217 additions and 1220 deletions
|
@ -472,10 +472,10 @@ static void Emit4( char *opname, int i ) {
|
|||
static void Inst( char *opname, int opcode, int destReg, int aReg, int bReg ) {
|
||||
unsigned r;
|
||||
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("\t\t\t%p %s\tr%d,r%d,r%d\n",&buf[compiledOfs],opname,destReg,aReg,bReg);
|
||||
#endif
|
||||
#endif
|
||||
r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;
|
||||
buf[ compiledOfs ] = r;
|
||||
compiledOfs++;
|
||||
|
@ -484,10 +484,10 @@ static void Inst( char *opname, int opcode, int destReg, int aReg, int bReg ) {
|
|||
static void Inst4( char *opname, int opcode, int destReg, int aReg, int bReg, int cReg ) {
|
||||
unsigned r;
|
||||
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("\t\t\t%p %s\tr%d,r%d,r%d,r%d\n",&buf[compiledOfs],opname,destReg,aReg,bReg,cReg);
|
||||
#endif
|
||||
#endif
|
||||
r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) | ( cReg << 6 );
|
||||
buf[ compiledOfs ] = r;
|
||||
compiledOfs++;
|
||||
|
@ -499,10 +499,10 @@ static void InstImm( char *opname, int opcode, int destReg, int aReg, int immedi
|
|||
if ( immediate > 32767 || immediate < -32768 ) {
|
||||
Com_Error( ERR_FATAL, "VM_Compile: immediate value %i out of range, opcode %x,%d,%d", immediate, opcode, destReg, aReg );
|
||||
}
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("\t\t\t%p %s\tr%d,r%d,0x%x\n",&buf[compiledOfs],opname,destReg,aReg,immediate);
|
||||
#endif
|
||||
#endif
|
||||
r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );
|
||||
buf[ compiledOfs ] = r;
|
||||
compiledOfs++;
|
||||
|
@ -514,10 +514,10 @@ static void InstImmU( char *opname, int opcode, int destReg, int aReg, int immed
|
|||
if ( immediate > 0xffff || immediate < 0 ) {
|
||||
Com_Error( ERR_FATAL, "VM_Compile: immediate value %i out of range", immediate );
|
||||
}
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("\t\t\t%p %s\tr%d,r%d,0x%x\n",&buf[compiledOfs],opname,destReg,aReg,immediate);
|
||||
#endif
|
||||
#endif
|
||||
r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );
|
||||
buf[ compiledOfs ] = r;
|
||||
compiledOfs++;
|
||||
|
@ -553,7 +553,7 @@ static void spillOpStack(int depth)
|
|||
static void loadOpStack(int depth)
|
||||
{
|
||||
// Back off operand stack pointer and reload all operands.
|
||||
// InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, -(depth)*4 );
|
||||
// InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, -(depth)*4 );
|
||||
|
||||
int i;
|
||||
|
||||
|
@ -727,20 +727,20 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
case 0:
|
||||
break;
|
||||
case OP_BREAK:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08lx BREAK\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
InstImmU( "addi", PPC_ADDI, R_TOP, 0, 0 );
|
||||
InstImm( "lwz", PPC_LWZ, R_TOP, R_TOP, 0 ); // *(int *)0 to crash to debugger
|
||||
break;
|
||||
case OP_ENTER:
|
||||
opStackDepth = 0;
|
||||
v = Constant4();
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x ENTER\t%04x\n",instruction,v);
|
||||
#endif
|
||||
#endif
|
||||
opStackRegType[opStackDepth] = 0;
|
||||
mainFunction++;
|
||||
if(mainFunction == 1)
|
||||
|
@ -756,10 +756,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
break;
|
||||
case OP_CONST:
|
||||
v = Constant4();
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x CONST\t%08x\n",instruction,v);
|
||||
#endif
|
||||
#endif
|
||||
opStackLoadInstructionAddr[opStackDepth] = 0;
|
||||
if ( v < 32768 && v >= -32768 ) {
|
||||
InstImmU( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth], 0, v & 0xffff );
|
||||
|
@ -777,10 +777,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
break;
|
||||
case OP_LOCAL:
|
||||
oc1 = Constant4();
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LOCAL\t%08x\n",instruction,oc1);
|
||||
#endif
|
||||
#endif
|
||||
if (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {
|
||||
oc1 &= vm->dataMask;
|
||||
}
|
||||
|
@ -791,10 +791,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
break;
|
||||
case OP_ARG:
|
||||
v = Constant1();
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x ARG \t%08x\n",instruction,v);
|
||||
#endif
|
||||
#endif
|
||||
InstImm( "addi", PPC_ADDI, R_EA, R_STACK, v ); // location to put it
|
||||
if(opStackRegType[opStackDepth-1] == 1)
|
||||
Inst( "stwx", PPC_STWX, opStackIntRegisters[opStackDepth-1], R_EA, R_MEMBASE );
|
||||
|
@ -806,10 +806,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
|
||||
break;
|
||||
case OP_CALL:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x CALL\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assert(opStackDepth > 0);
|
||||
Inst( "mflr", PPC_MFSPR, R_SECOND, 8, 0 ); // move from link register
|
||||
|
@ -838,27 +838,27 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
Inst( "mtlr", PPC_MTSPR, R_SECOND, 8, 0 ); // move to link register
|
||||
break;
|
||||
case OP_PUSH:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x PUSH\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
opStackRegType[opStackDepth] = 1; // Garbage int value.
|
||||
opStackDepth += 1;
|
||||
break;
|
||||
case OP_POP:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x POP\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
opStackDepth -= 1;
|
||||
opStackRegType[opStackDepth] = 0; // ??
|
||||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
break;
|
||||
case OP_LEAVE:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LEAVE\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assert(opStackDepth == 1);
|
||||
assert(opStackRegType[0] != 0);
|
||||
// Save return value onto top of op stack. We also have to increment R_OPSTACK
|
||||
|
@ -884,10 +884,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
Inst( "blr", PPC_BCLR, 20, 0, 0 ); // branch unconditionally to link register
|
||||
break;
|
||||
case OP_LOAD4:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LOAD4\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
// We should try to figure out whether to use LWZX or LFSX based
|
||||
// on some kind of code analysis after subsequent passes. I think what
|
||||
// we could do is store the compiled load instruction address along with
|
||||
|
@ -900,30 +900,30 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackRegType[opStackDepth-1] = 1;
|
||||
break;
|
||||
case OP_LOAD2:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LOAD2\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
Inst( "lhzx", PPC_LHZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base
|
||||
opStackRegType[opStackDepth-1] = 1;
|
||||
break;
|
||||
case OP_LOAD1:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LOAD1\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
Inst( "lbzx", PPC_LBZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base
|
||||
opStackRegType[opStackDepth-1] = 1;
|
||||
break;
|
||||
case OP_STORE4:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x STORE4\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-2);
|
||||
if(opStackRegType[opStackDepth-1] == 1)
|
||||
Inst( "stwx", PPC_STWX, opStackIntRegisters[opStackDepth-1],
|
||||
|
@ -938,10 +938,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 2;
|
||||
break;
|
||||
case OP_STORE2:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x STORE2\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "sthx", PPC_STHX, opStackIntRegisters[opStackDepth-1],
|
||||
|
@ -953,10 +953,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 2;
|
||||
break;
|
||||
case OP_STORE1:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x STORE1\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "stbx", PPC_STBX, opStackIntRegisters[opStackDepth-1],
|
||||
|
@ -969,10 +969,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
break;
|
||||
|
||||
case OP_EQ:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x EQ\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -992,10 +992,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
Emit4("b", PPC_B | (v&0x3ffffff) );
|
||||
break;
|
||||
case OP_NE:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x NE\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1013,14 +1013,14 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 4, 2, v );
|
||||
// InstImm( "bc", PPC_BC, 4, 2, v );
|
||||
|
||||
break;
|
||||
case OP_LTI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LTI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1038,13 +1038,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 12, 0, v );
|
||||
// InstImm( "bc", PPC_BC, 12, 0, v );
|
||||
break;
|
||||
case OP_LEI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LEI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1062,13 +1062,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 4, 1, v );
|
||||
// InstImm( "bc", PPC_BC, 4, 1, v );
|
||||
break;
|
||||
case OP_GTI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x GTI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1086,13 +1086,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 12, 1, v );
|
||||
// InstImm( "bc", PPC_BC, 12, 1, v );
|
||||
break;
|
||||
case OP_GEI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x GEI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1110,13 +1110,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 4, 0, v );
|
||||
// InstImm( "bc", PPC_BC, 4, 0, v );
|
||||
break;
|
||||
case OP_LTU:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LTU\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1134,13 +1134,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 12, 0, v );
|
||||
// InstImm( "bc", PPC_BC, 12, 0, v );
|
||||
break;
|
||||
case OP_LEU:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LEU\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1158,13 +1158,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 4, 1, v );
|
||||
// InstImm( "bc", PPC_BC, 4, 1, v );
|
||||
break;
|
||||
case OP_GTU:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x GTU\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1182,13 +1182,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 12, 1, v );
|
||||
// InstImm( "bc", PPC_BC, 12, 1, v );
|
||||
break;
|
||||
case OP_GEU:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x GEU\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1206,14 +1206,14 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 4, 0, v );
|
||||
// InstImm( "bc", PPC_BC, 4, 0, v );
|
||||
break;
|
||||
|
||||
case OP_EQF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x EQF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1231,13 +1231,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 12, 2, v );
|
||||
// InstImm( "bc", PPC_BC, 12, 2, v );
|
||||
break;
|
||||
case OP_NEF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x NEF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1255,13 +1255,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 4, 2, v );
|
||||
// InstImm( "bc", PPC_BC, 4, 2, v );
|
||||
break;
|
||||
case OP_LTF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LTF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1279,13 +1279,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 12, 0, v );
|
||||
// InstImm( "bc", PPC_BC, 12, 0, v );
|
||||
break;
|
||||
case OP_LEF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LEF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1303,13 +1303,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 4, 1, v );
|
||||
// InstImm( "bc", PPC_BC, 4, 1, v );
|
||||
break;
|
||||
case OP_GTF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x GTF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1327,13 +1327,13 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 12, 1, v );
|
||||
// InstImm( "bc", PPC_BC, 12, 1, v );
|
||||
break;
|
||||
case OP_GEF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x GEF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1351,23 +1351,23 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
v = 0;
|
||||
}
|
||||
Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
|
||||
// InstImm( "bc", PPC_BC, 4, 0, v );
|
||||
// InstImm( "bc", PPC_BC, 4, 0, v );
|
||||
break;
|
||||
|
||||
case OP_NEGI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x NEGI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
InstImm( "subfic", PPC_SUBFIC, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
|
||||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
break;
|
||||
case OP_ADD:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x ADD\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "add", PPC_ADD, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
|
||||
|
@ -1376,10 +1376,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_SUB:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x SUB\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "subf", PPC_SUBF, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
|
||||
|
@ -1388,10 +1388,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_DIVI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x DIVI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "divw", PPC_DIVW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1400,10 +1400,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_DIVU:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x DIVU\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "divwu", PPC_DIVWU, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1412,10 +1412,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_MODI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x MODI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "divw", PPC_DIVW, R_EA, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1426,10 +1426,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_MODU:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x MODU\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "divwu", PPC_DIVWU, R_EA, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1441,10 +1441,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
break;
|
||||
case OP_MULI:
|
||||
case OP_MULU:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x MULI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "mullw", PPC_MULLW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
|
||||
|
@ -1453,10 +1453,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_BAND:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x BAND\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "and", PPC_AND, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1465,10 +1465,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_BOR:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x BOR\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "or", PPC_OR, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1477,10 +1477,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_BXOR:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x BXOR\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "xor", PPC_XOR, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1489,19 +1489,19 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_BCOM:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x BCOM\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
Inst( "nor", PPC_NOR, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1] );
|
||||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
break;
|
||||
case OP_LSH:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x LSH\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "slw", PPC_SLW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1510,10 +1510,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_RSHI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x RSHI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "sraw", PPC_SRAW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1522,10 +1522,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_RSHU:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x RSHU\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
Inst( "srw", PPC_SRW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
|
||||
|
@ -1535,19 +1535,19 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
break;
|
||||
|
||||
case OP_NEGF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x NEGF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
Inst( "fneg", PPC_FNEG, opStackFloatRegisters[opStackDepth-1], 0, opStackFloatRegisters[opStackDepth-1] );
|
||||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
break;
|
||||
case OP_ADDF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x ADDF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fadds", PPC_FADDS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1556,10 +1556,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_SUBF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x SUBF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fsubs", PPC_FSUBS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1568,10 +1568,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_DIVF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x DIVF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst( "fdivs", PPC_FDIVS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1580,10 +1580,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackDepth -= 1;
|
||||
break;
|
||||
case OP_MULF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x MULF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
makeFloat(opStackDepth-2);
|
||||
Inst4( "fmuls", PPC_FMULS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], 0, opStackFloatRegisters[opStackDepth-1] );
|
||||
|
@ -1593,10 +1593,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
break;
|
||||
|
||||
case OP_CVIF:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x CVIF\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
//makeInteger(opStackDepth-1);
|
||||
v = (int)&itofConvert;
|
||||
|
@ -1615,10 +1615,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
// Inst( PPC_FRSP, R_TOP, 0, R_TOP );
|
||||
break;
|
||||
case OP_CVFI:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x CVFI\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
makeFloat(opStackDepth-1);
|
||||
|
||||
InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, opStackDepth*4);
|
||||
|
@ -1637,19 +1637,19 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
break;
|
||||
case OP_SEX8:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x SEX8\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
Inst( "extsb", PPC_EXTSB, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
|
||||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
break;
|
||||
case OP_SEX16:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x SEX16\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assertInteger(opStackDepth-1);
|
||||
Inst( "extsh", PPC_EXTSH, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
|
||||
opStackLoadInstructionAddr[opStackDepth-1] = 0;
|
||||
|
@ -1657,10 +1657,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
|
||||
case OP_BLOCK_COPY:
|
||||
v = Constant4() >> 2;
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x BLOCK_COPY\t%08lx\n",instruction,v<<2);
|
||||
#endif
|
||||
#endif
|
||||
assert(opStackDepth >= 2);
|
||||
assertInteger(opStackDepth-1);
|
||||
assertInteger(opStackDepth-2);
|
||||
|
@ -1684,10 +1684,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
|
|||
break;
|
||||
|
||||
case OP_JUMP:
|
||||
#if DEBUG_VM
|
||||
#if DEBUG_VM
|
||||
if(pass == 1)
|
||||
printf("%08x JUMP\n",instruction);
|
||||
#endif
|
||||
#endif
|
||||
assert(opStackDepth == 1);
|
||||
assertInteger(opStackDepth-1);
|
||||
|
||||
|
@ -1822,86 +1822,86 @@ Put this at end of file because gcc messes up debug line numbers
|
|||
#ifdef __GNUC__
|
||||
|
||||
void AsmCall( void ) {
|
||||
asm (
|
||||
asm (
|
||||
// pop off the destination instruction
|
||||
" lwz r12,0(r4) \n" // RG_TOP, 0(RG_OPSTACK)
|
||||
" addi r4,r4,-4 \n" // RG_OPSTACK, RG_OPSTACK, -4 \n"
|
||||
" lwz r12,0(r4) \n" // RG_TOP, 0(RG_OPSTACK)
|
||||
" addi r4,r4,-4 \n" // RG_OPSTACK, RG_OPSTACK, -4 \n"
|
||||
|
||||
// see if it is a system trap
|
||||
" cmpwi r12,0 \n" // RG_TOP, 0 \n"
|
||||
" bc 12,0, systemTrap \n"
|
||||
" cmpwi r12,0 \n" // RG_TOP, 0 \n"
|
||||
" bc 12,0, systemTrap \n"
|
||||
|
||||
// calling another VM function, so lookup in instructionPointers
|
||||
" slwi r12,r12,2 \n" // RG_TOP,RG_TOP,2
|
||||
" slwi r12,r12,2 \n" // RG_TOP,RG_TOP,2
|
||||
// FIXME: range check
|
||||
" lwzx r12, r8, r12 \n" // RG_TOP, RG_INSTRUCTIONS(RG_TOP)
|
||||
" mtctr r12 \n" // RG_TOP
|
||||
);
|
||||
" lwzx r12, r8, r12 \n" // RG_TOP, RG_INSTRUCTIONS(RG_TOP)
|
||||
" mtctr r12 \n" // RG_TOP
|
||||
);
|
||||
|
||||
#if defined(MACOS_X) && defined(__OPTIMIZE__)
|
||||
// On Mac OS X, gcc doesn't push a frame when we are optimized, so trying to tear it down results in grave disorder.
|
||||
//#warning Mac OS X optimization on, not popping GCC AsmCall frame
|
||||
//#warning Mac OS X optimization on, not popping GCC AsmCall frame
|
||||
#else
|
||||
// Mac OS X Server and unoptimized compiles include a GCC AsmCall frame
|
||||
asm (
|
||||
" lwz r1,0(r1) \n" // pop off the GCC AsmCall frame
|
||||
" lmw r30,-8(r1) \n"
|
||||
);
|
||||
" lwz r1,0(r1) \n" // pop off the GCC AsmCall frame
|
||||
" lmw r30,-8(r1) \n"
|
||||
);
|
||||
#endif
|
||||
|
||||
asm (
|
||||
" bcctr 20,0 \n" // when it hits a leave, it will branch to the current link register
|
||||
asm (
|
||||
" bcctr 20,0 \n" // when it hits a leave, it will branch to the current link register
|
||||
|
||||
// calling a system trap
|
||||
"systemTrap: \n"
|
||||
"systemTrap: \n"
|
||||
// convert to positive system call number
|
||||
" subfic r12,r12,-1 \n"
|
||||
" subfic r12,r12,-1 \n"
|
||||
|
||||
// save all our registers, including the current link register
|
||||
" mflr r13 \n" // RG_SECOND // copy off our link register
|
||||
" addi r1,r1,-92 \n" // required 24 byets of linkage, 32 bytes of parameter, plus our saves
|
||||
" stw r3,56(r1) \n" // RG_STACK, -36(REAL_STACK)
|
||||
" stw r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
|
||||
" stw r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
|
||||
" stw r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
|
||||
" stw r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
|
||||
" stw r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
|
||||
" stw r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
|
||||
" stw r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
|
||||
" stw r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK) // link register
|
||||
" mflr r13 \n" // RG_SECOND // copy off our link register
|
||||
" addi r1,r1,-92 \n" // required 24 byets of linkage, 32 bytes of parameter, plus our saves
|
||||
" stw r3,56(r1) \n" // RG_STACK, -36(REAL_STACK)
|
||||
" stw r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
|
||||
" stw r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
|
||||
" stw r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
|
||||
" stw r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
|
||||
" stw r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
|
||||
" stw r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
|
||||
" stw r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
|
||||
" stw r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK) // link register
|
||||
|
||||
// save the vm stack position to allow recursive VM entry
|
||||
" addi r13,r3,-4 \n" // RG_TOP, RG_STACK, -4
|
||||
" stw r13,0(r10) \n" //RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)
|
||||
" addi r13,r3,-4 \n" // RG_TOP, RG_STACK, -4
|
||||
" stw r13,0(r10) \n" //RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)
|
||||
|
||||
// save the system call number as the 0th parameter
|
||||
" add r3,r3,r5 \n" // r3, RG_STACK, RG_MEMBASE // r3 is the first parameter to vm->systemCalls
|
||||
" stwu r12,4(r3) \n" // RG_TOP, 4(r3)
|
||||
" add r3,r3,r5 \n" // r3, RG_STACK, RG_MEMBASE // r3 is the first parameter to vm->systemCalls
|
||||
" stwu r12,4(r3) \n" // RG_TOP, 4(r3)
|
||||
|
||||
// make the system call with the address of all the VM parms as a parameter
|
||||
// vm->systemCalls( &parms )
|
||||
" lwz r12,4(r10) \n" // RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)
|
||||
" mtctr r12 \n" // RG_TOP
|
||||
" bcctrl 20,0 \n"
|
||||
" mr r12,r3 \n" // RG_TOP, r3
|
||||
" lwz r12,4(r10) \n" // RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)
|
||||
" mtctr r12 \n" // RG_TOP
|
||||
" bcctrl 20,0 \n"
|
||||
" mr r12,r3 \n" // RG_TOP, r3
|
||||
|
||||
// pop our saved registers
|
||||
" lwz r3,56(r1) \n" // RG_STACK, 0(RG_REAL_STACK)
|
||||
" lwz r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
|
||||
" lwz r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
|
||||
" lwz r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
|
||||
" lwz r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
|
||||
" lwz r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
|
||||
" lwz r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
|
||||
" lwz r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
|
||||
" lwz r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK)
|
||||
" addi r1,r1,92 \n" // RG_REAL_STACK, RG_REAL_STACK, 36
|
||||
" lwz r3,56(r1) \n" // RG_STACK, 0(RG_REAL_STACK)
|
||||
" lwz r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
|
||||
" lwz r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
|
||||
" lwz r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
|
||||
" lwz r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
|
||||
" lwz r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
|
||||
" lwz r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
|
||||
" lwz r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
|
||||
" lwz r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK)
|
||||
" addi r1,r1,92 \n" // RG_REAL_STACK, RG_REAL_STACK, 36
|
||||
|
||||
// restore the old link register
|
||||
" mtlr r13 \n" // RG_SECOND
|
||||
" mtlr r13 \n" // RG_SECOND
|
||||
|
||||
// save off the return value
|
||||
" stwu r12,4(r4) \n" // RG_TOP, 0(RG_OPSTACK)
|
||||
" stwu r12,4(r4) \n" // RG_TOP, 0(RG_OPSTACK)
|
||||
|
||||
// GCC adds its own prolog / epliog code
|
||||
);
|
||||
|
@ -1946,7 +1946,7 @@ void asm AsmCall( void ) {
|
|||
|
||||
// calling a system trap
|
||||
|
||||
systemTrap:
|
||||
systemTrap:
|
||||
|
||||
// convert to positive system call number
|
||||
|
||||
|
@ -2068,7 +2068,4 @@ systemTrap:
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue