//bl ArgsStubR3 // fuck ! VC++ inline assembler doesn't know how to do this !
bl _DummyMoveIpToLinkRegister // fake it :/
ArgsStubR3:
mflr r7
#if 0
// pff fucker ! inline assembler doesn't understand this

although it works in the .asm version
addi r5, r5, ArgSetupUpToR3 - ArgsStubR3
#else
addi r5, r5, 20 // manual counting: 5 instructions, 4 bytes each
#endif
add r7, r7, r5
mtctr r7
bctr
ArgSetupUpToR3: // parameter push r3-r10
lwz r10, 0x38(r3)
lwz r9, 0x30(r3)
lwz r8, 0x28(r3)
lwz r7, 0x20(r3)
lwz r6, 0x18(r3)
lwz r5, 0x10(r3)
lwz r4, 0x08(r3)
lwz r3, 0x00(r3)
SkipArgs:
mtctr r0
bctrl // call entryPoint
cmplwi r14, 0 // if we have a return adress
beq SkipRetValStore
#if 1
rlwinm r4, r15, 2, 30, 31 // (r15 <<< 2) & 1 --> (0x40000000 <<< 2) & 1 -> 0x00000001 & 1
#elif 0 // wtf ? assembler doesn't recognize the 'andis' opcode? Oo
andis r4, r15, 0x4000 // check the fp flag in the return value code [ NOTE : microcoded instruction ]
#else // emulate 'andis'
xor r4, r4, r4
addis r4, r4, 0x4000
and r15, r15, r4 // [ NOTE : microcoded instruction ]
#endif
cmplwi r4, 1
bne RetValInt
stfs fr1, 0x0(r14) // save the floating-point return value
b SkipRetValStore
RetValInt: // integer return value, returned in r3
cmplwi r4, 0
bne SkipRetValStore
// TODO: for 64-bit return values, check if 'r15' contains 4 or 8. if == 8, use 'std', else 'stw'
// std r3, 0x0(r14) // save the return value
stw r3, 0x0(r14)
SkipRetValStore:
ld r2, 0x28(r1) // restore TOC pointer
ld r0, 0xA0(r1)
ld r14, 0x78(r1)
ld r15, 0x70(r1)
addi r1, r1, 0x90
mtspr lr, r0
BailOut:
blr