Fix float parameter and return values
This commit is contained in:
parent
cf9f38d4dc
commit
a1fda2b957
|
@ -3297,7 +3297,7 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
||||||
|
|
||||||
dec->mLinkerObject->mNumTemporaries = 1;
|
dec->mLinkerObject->mNumTemporaries = 1;
|
||||||
dec->mLinkerObject->mTemporaries[0] = BC_REG_FPARAMS;
|
dec->mLinkerObject->mTemporaries[0] = BC_REG_FPARAMS;
|
||||||
dec->mLinkerObject->mTempSizes[0] = 8;
|
dec->mLinkerObject->mTempSizes[0] = BC_REG_FPARAMS_END - BC_REG_FPARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterCodeBasicBlock* entryBlock = new InterCodeBasicBlock();
|
InterCodeBasicBlock* entryBlock = new InterCodeBasicBlock();
|
||||||
|
|
|
@ -2880,22 +2880,25 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
||||||
{
|
{
|
||||||
if (ins->mSrc[1].mMemory == IM_INDIRECT)
|
if (ins->mSrc[1].mMemory == IM_INDIRECT)
|
||||||
{
|
{
|
||||||
|
union { float f; unsigned int v; } cc;
|
||||||
|
cc.f = ins->mSrc[0].mFloatConst;
|
||||||
|
|
||||||
int reg = BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp];
|
int reg = BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp];
|
||||||
int index = ins->mSrc[1].mIntConst;
|
int index = ins->mSrc[1].mIntConst;
|
||||||
|
|
||||||
CheckFrameIndex(reg, index, 4);
|
CheckFrameIndex(reg, index, 4);
|
||||||
|
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, index));
|
mIns.Push(NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, index));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, ins->mSrc[0].mIntConst & 0xff));
|
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, cc.v & 0xff));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_INDIRECT_Y, reg));
|
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_INDIRECT_Y, reg));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, index + 1));
|
mIns.Push(NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, index + 1));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins->mSrc[0].mIntConst >> 8) & 0xff));
|
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (cc.v >> 8) & 0xff));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_INDIRECT_Y, reg));
|
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_INDIRECT_Y, reg));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, index + 2));
|
mIns.Push(NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, index + 2));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins->mSrc[0].mIntConst >> 16) & 0xff));
|
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (cc.v >> 16) & 0xff));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_INDIRECT_Y, reg));
|
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_INDIRECT_Y, reg));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, index + 3));
|
mIns.Push(NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, index + 3));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins->mSrc[0].mIntConst >> 24) & 0xff));
|
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (cc.v >> 24) & 0xff));
|
||||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_INDIRECT_Y, reg));
|
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_INDIRECT_Y, reg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -807,16 +807,22 @@ Declaration* Parser::ParseDeclaration(bool variable)
|
||||||
|
|
||||||
ndec = ReverseDeclaration(ndec, bdec);
|
ndec = ReverseDeclaration(ndec, bdec);
|
||||||
|
|
||||||
|
Declaration* npdec = ndec;
|
||||||
|
|
||||||
|
if (npdec->mBase->mType == DT_TYPE_POINTER)
|
||||||
|
npdec = npdec->mBase;
|
||||||
|
|
||||||
// Make room for return value pointer on struct return
|
// Make room for return value pointer on struct return
|
||||||
if (ndec->mBase->mType == DT_TYPE_FUNCTION && ndec->mBase->mBase->mType == DT_TYPE_STRUCT)
|
if (npdec->mBase->mType == DT_TYPE_FUNCTION && npdec->mBase->mBase->mType == DT_TYPE_STRUCT)
|
||||||
{
|
{
|
||||||
Declaration* pdec = ndec->mBase->mParams;
|
Declaration* pdec = npdec->mBase->mParams;
|
||||||
while (pdec)
|
while (pdec)
|
||||||
{
|
{
|
||||||
pdec->mVarIndex += 2;
|
pdec->mVarIndex += 2;
|
||||||
pdec = pdec->mNext;
|
pdec = pdec->mNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (definingType)
|
if (definingType)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue