More byte and long preparations

This commit is contained in:
drmortalwombat 2021-09-14 21:38:24 +02:00
parent e2e20581a6
commit 37828f2baf
10 changed files with 311 additions and 95 deletions

View File

@ -1,6 +1,7 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
int fib(int a) int fib(int a)
{ {

View File

@ -284,6 +284,19 @@ P1:
#pragma bytecode(BC_NATIVE, inp_native) #pragma bytecode(BC_NATIVE, inp_native)
__asm inp_const_8
{
lda (ip), y
tax
iny
lda (ip), y
sta $00, x
iny
jmp startup.exec
}
#pragma bytecode(BC_CONST_8, inp_const_8)
__asm inp_const_p8 __asm inp_const_p8
{ {
lda (ip), y lda (ip), y
@ -352,6 +365,32 @@ __asm inp_const_32
#pragma bytecode(BC_CONST_32, inp_const_32) #pragma bytecode(BC_CONST_32, inp_const_32)
__asm inp_load_reg_8
{
lda (ip), y
tax
iny
lda $00, x
sta accu
lda #0
sta accu + 1
jmp startup.exec
}
#pragma bytecode(BC_LOAD_REG_8, inp_load_reg_8)
__asm inp_store_reg_8
{
lda (ip), y
tax
iny
lda accu
sta $00, x
jmp startup.exec
}
#pragma bytecode(BC_STORE_REG_8, inp_store_reg_8)
__asm inp_load_reg_16 __asm inp_load_reg_16
{ {
lda (ip), y lda (ip), y
@ -445,6 +484,37 @@ __asm inp_addr_reg
#pragma bytecode(BC_ADDR_REG, inp_addr_reg) #pragma bytecode(BC_ADDR_REG, inp_addr_reg)
__asm inp_load_abs_8
{
lda (ip), y
sta addr
iny
lda (ip), y
sta addr + 1
iny
lda (ip), y
tax
sty tmpy
ldy #0
L0:
lda (addr), y
sta $00, x
ldy tmpy
iny
jmp startup.exec
inp_load_addr_8:
lda (ip), y
tax
iny
lda (ip), y
sty tmpy
tay
jmp L0
}
#pragma bytecode(BC_LOAD_ABS_8, inp_load_abs_8)
#pragma bytecode(BC_LOAD_ADDR_8, inp_load_abs_8.inp_load_addr_8)
__asm inp_load_abs_u8 __asm inp_load_abs_u8
{ {
lda (ip), y lda (ip), y
@ -762,6 +832,23 @@ __asm inp_load_local_32
#pragma bytecode(BC_LOAD_LOCAL_32, inp_load_local_32) #pragma bytecode(BC_LOAD_LOCAL_32, inp_load_local_32)
__asm inp_load_local_8
{
lda (ip), y
tax
iny
lda (ip), y
iny
sty tmpy
tay
lda (fp), y
sta $00, x
ldy tmpy
jmp startup.exec
}
#pragma bytecode(BC_LOAD_LOCAL_8, inp_load_local_8)
__asm inp_load_local_u8 __asm inp_load_local_u8
{ {
lda (ip), y lda (ip), y

View File

@ -19,17 +19,21 @@ enum ByteCode
BC_NOP, BC_NOP,
BC_EXIT, BC_EXIT,
BC_CONST_8,
BC_CONST_P8, BC_CONST_P8,
BC_CONST_N8, BC_CONST_N8,
BC_CONST_16, BC_CONST_16,
BC_CONST_32, BC_CONST_32,
BC_LOAD_REG_8,
BC_STORE_REG_8,
BC_LOAD_REG_16, BC_LOAD_REG_16,
BC_STORE_REG_16, BC_STORE_REG_16,
BC_ADDR_REG, BC_ADDR_REG,
BC_LOAD_REG_32, BC_LOAD_REG_32,
BC_STORE_REG_32, BC_STORE_REG_32,
BC_LOAD_ABS_8,
BC_LOAD_ABS_U8, BC_LOAD_ABS_U8,
BC_LOAD_ABS_I8, BC_LOAD_ABS_I8,
BC_LOAD_ABS_16, BC_LOAD_ABS_16,
@ -41,6 +45,7 @@ enum ByteCode
BC_LEA_ABS, BC_LEA_ABS,
BC_LOAD_LOCAL_8,
BC_LOAD_LOCAL_U8, BC_LOAD_LOCAL_U8,
BC_LOAD_LOCAL_I8, BC_LOAD_LOCAL_I8,
BC_LOAD_LOCAL_16, BC_LOAD_LOCAL_16,
@ -56,6 +61,7 @@ enum ByteCode
BC_STORE_FRAME_16, BC_STORE_FRAME_16,
BC_STORE_FRAME_32, BC_STORE_FRAME_32,
BC_LOAD_ADDR_8,
BC_LOAD_ADDR_U8, BC_LOAD_ADDR_U8,
BC_LOAD_ADDR_I8, BC_LOAD_ADDR_I8,
BC_LOAD_ADDR_16, BC_LOAD_ADDR_16,

View File

@ -1,6 +1,17 @@
#include "ByteCodeGenerator.h" #include "ByteCodeGenerator.h"
#include "Assembler.h" #include "Assembler.h"
static ByteCode StoreTypedTmpCodes[] = {
BC_NOP,
BC_STORE_REG_8,
BC_STORE_REG_8,
BC_STORE_REG_16,
BC_STORE_REG_32,
BC_STORE_REG_32,
BC_STORE_REG_16
};
static ByteCode InvertBranchCondition(ByteCode code) static ByteCode InvertBranchCondition(ByteCode code)
{ {
switch (code) switch (code)
@ -67,13 +78,13 @@ bool ByteCodeInstruction::LoadsRegister(uint32 reg) const
{ {
if (mRegister == reg) if (mRegister == reg)
{ {
if (mCode >= BC_LOAD_ABS_U8 && mCode <= BC_LOAD_ABS_32) if (mCode >= BC_LOAD_ABS_8 && mCode <= BC_LOAD_ABS_32)
return true; return true;
if (mCode >= BC_LOAD_LOCAL_U8 && mCode <= BC_LOAD_LOCAL_32) if (mCode >= BC_LOAD_LOCAL_8 && mCode <= BC_LOAD_LOCAL_32)
return true; return true;
if (mCode >= BC_LOAD_ADDR_U8 && mCode <= BC_LOAD_ADDR_32) if (mCode >= BC_LOAD_ADDR_8 && mCode <= BC_LOAD_ADDR_32)
return true; return true;
if (mCode >= BC_CONST_P8 && mCode <= BC_CONST_32) if (mCode >= BC_CONST_8 && mCode <= BC_CONST_32)
return true; return true;
if (mCode == BC_LEA_ABS || mCode == BC_LEA_LOCAL) if (mCode == BC_LEA_ABS || mCode == BC_LEA_LOCAL)
return true; return true;
@ -115,15 +126,15 @@ bool ByteCodeInstruction::ChangesRegister(uint32 reg) const
{ {
if (mRegister == reg) if (mRegister == reg)
{ {
if (mCode == BC_STORE_REG_16 || mCode == BC_STORE_REG_32) if (mCode == BC_STORE_REG_8 || mCode == BC_STORE_REG_16 || mCode == BC_STORE_REG_32)
return true; return true;
if (mCode >= BC_LOAD_ABS_U8 && mCode <= BC_LOAD_ABS_32) if (mCode >= BC_LOAD_ABS_8 && mCode <= BC_LOAD_ABS_32)
return true; return true;
if (mCode >= BC_LOAD_LOCAL_U8 && mCode <= BC_LOAD_LOCAL_32) if (mCode >= BC_LOAD_LOCAL_8 && mCode <= BC_LOAD_LOCAL_32)
return true; return true;
if (mCode >= BC_LOAD_ADDR_U8 && mCode <= BC_LOAD_ADDR_32) if (mCode >= BC_LOAD_ADDR_8 && mCode <= BC_LOAD_ADDR_32)
return true; return true;
if (mCode >= BC_CONST_P8 && mCode <= BC_CONST_32) if (mCode >= BC_CONST_8 && mCode <= BC_CONST_32)
return true; return true;
if (mCode == BC_LEA_ABS || mCode == BC_LEA_LOCAL) if (mCode == BC_LEA_ABS || mCode == BC_LEA_LOCAL)
return true; return true;
@ -135,7 +146,7 @@ bool ByteCodeInstruction::ChangesRegister(uint32 reg) const
if (reg == BC_REG_ACCU) if (reg == BC_REG_ACCU)
{ {
if (mCode == BC_LOAD_REG_16 || mCode == BC_LOAD_REG_32) if (mCode == BC_LOAD_REG_8 || mCode == BC_LOAD_REG_16 || mCode == BC_LOAD_REG_32)
return true; return true;
if (mCode >= BC_BINOP_ADDR_16 && mCode <= BC_BINOP_SHRR_I16) if (mCode >= BC_BINOP_ADDR_16 && mCode <= BC_BINOP_SHRR_I16)
return true; return true;
@ -159,7 +170,7 @@ bool ByteCodeInstruction::ChangesRegister(uint32 reg) const
{ {
if (mCode == BC_ADDR_REG) if (mCode == BC_ADDR_REG)
return true; return true;
if (mCode >= BC_LOAD_ABS_U8 && mCode <= BC_STORE_ABS_32) if (mCode >= BC_LOAD_ABS_8 && mCode <= BC_STORE_ABS_32)
return true; return true;
if (mCode == BC_JSR || mCode == BC_CALL) if (mCode == BC_JSR || mCode == BC_CALL)
return true; return true;
@ -178,6 +189,9 @@ void ByteCodeInstruction::Assemble(ByteCodeGenerator* generator, ByteCodeBasicBl
block->PutCode(generator, mCode); block->PutCode(generator, mCode);
break; break;
case BC_CONST_8:
block->PutCode(generator, BC_CONST_8); block->PutByte(mRegister); block->PutByte(uint8(mValue));
break;
case BC_CONST_P8: case BC_CONST_P8:
case BC_CONST_N8: case BC_CONST_N8:
case BC_CONST_16: case BC_CONST_16:
@ -213,7 +227,8 @@ void ByteCodeInstruction::Assemble(ByteCodeGenerator* generator, ByteCodeBasicBl
block->PutCode(generator, BC_CONST_32); block->PutByte(mRegister); block->PutDWord(uint32(mValue)); block->PutCode(generator, BC_CONST_32); block->PutByte(mRegister); block->PutDWord(uint32(mValue));
break; break;
case BC_LOAD_REG_8:
case BC_STORE_REG_8:
case BC_LOAD_REG_16: case BC_LOAD_REG_16:
case BC_STORE_REG_16: case BC_STORE_REG_16:
case BC_LOAD_REG_32: case BC_LOAD_REG_32:
@ -223,6 +238,7 @@ void ByteCodeInstruction::Assemble(ByteCodeGenerator* generator, ByteCodeBasicBl
block->PutByte(mRegister); block->PutByte(mRegister);
break; break;
case BC_LOAD_ABS_8:
case BC_LOAD_ABS_U8: case BC_LOAD_ABS_U8:
case BC_LOAD_ABS_I8: case BC_LOAD_ABS_I8:
case BC_LOAD_ABS_16: case BC_LOAD_ABS_16:
@ -269,6 +285,7 @@ void ByteCodeInstruction::Assemble(ByteCodeGenerator* generator, ByteCodeBasicBl
block->PutWord(uint16(mValue)); block->PutWord(uint16(mValue));
break; break;
case BC_LOAD_LOCAL_8:
case BC_LOAD_LOCAL_U8: case BC_LOAD_LOCAL_U8:
case BC_LOAD_LOCAL_I8: case BC_LOAD_LOCAL_I8:
case BC_LOAD_LOCAL_16: case BC_LOAD_LOCAL_16:
@ -430,6 +447,7 @@ void ByteCodeInstruction::Assemble(ByteCodeGenerator* generator, ByteCodeBasicBl
block->PutWord(0); block->PutWord(0);
} break; } break;
case BC_LOAD_ADDR_8:
case BC_LOAD_ADDR_U8: case BC_LOAD_ADDR_U8:
case BC_LOAD_ADDR_I8: case BC_LOAD_ADDR_I8:
case BC_LOAD_ADDR_16: case BC_LOAD_ADDR_16:
@ -614,6 +632,13 @@ void ByteCodeBasicBlock::LoadConstant(InterCodeProcedure* proc, const InterInstr
mIns.Push(bins); mIns.Push(bins);
} }
} }
else if (ins.mTType == IT_BOOL || ins.mTType == IT_INT8)
{
ByteCodeInstruction bins(BC_CONST_8);
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
bins.mValue = ins.mIntValue;
mIns.Push(bins);
}
else else
{ {
ByteCodeInstruction bins(BC_CONST_16); ByteCodeInstruction bins(BC_CONST_16);
@ -1376,7 +1401,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
{ {
if (ins.mMemory == IM_GLOBAL) if (ins.mMemory == IM_GLOBAL)
{ {
ByteCodeInstruction bins(BC_LOAD_ABS_U8); ByteCodeInstruction bins((ins.mTType == IT_BOOL || ins.mTType == IT_INT8) ? BC_LOAD_ABS_8 : BC_LOAD_ABS_U8);
bins.mRelocate = true; bins.mRelocate = true;
bins.mVIndex = ins.mVarIndex; bins.mVIndex = ins.mVarIndex;
bins.mValue = ins.mSIntConst[0]; bins.mValue = ins.mSIntConst[0];
@ -1385,7 +1410,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
} }
else if (ins.mMemory == IM_ABSOLUTE) else if (ins.mMemory == IM_ABSOLUTE)
{ {
ByteCodeInstruction bins(BC_LOAD_ABS_U8); ByteCodeInstruction bins((ins.mTType == IT_BOOL || ins.mTType == IT_INT8) ? BC_LOAD_ABS_8 : BC_LOAD_ABS_U8);
bins.mValue = ins.mSIntConst[0]; bins.mValue = ins.mSIntConst[0];
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp]; bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
mIns.Push(bins); mIns.Push(bins);
@ -1400,7 +1425,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
if (index <= 255) if (index <= 255)
{ {
ByteCodeInstruction bins(BC_LOAD_LOCAL_U8); ByteCodeInstruction bins((ins.mTType == IT_BOOL || ins.mTType == IT_INT8) ? BC_LOAD_LOCAL_8 : BC_LOAD_LOCAL_U8);
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp]; bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
bins.mValue = index; bins.mValue = index;
mIns.Push(bins); mIns.Push(bins);
@ -1411,7 +1436,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
lins.mRegister = BC_REG_ADDR; lins.mRegister = BC_REG_ADDR;
lins.mValue = index; lins.mValue = index;
mIns.Push(lins); mIns.Push(lins);
ByteCodeInstruction bins(BC_LOAD_ADDR_U8); ByteCodeInstruction bins((ins.mTType == IT_BOOL || ins.mTType == IT_INT8) ? BC_LOAD_LOCAL_8 : BC_LOAD_ADDR_U8);
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp]; bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
bins.mValue = 0; bins.mValue = 0;
mIns.Push(bins); mIns.Push(bins);
@ -1476,7 +1501,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
if (ins.mOperandSize == 1) if (ins.mOperandSize == 1)
{ {
ByteCodeInstruction bins(BC_LOAD_ADDR_U8); ByteCodeInstruction bins((ins.mTType == IT_BOOL || ins.mTType == IT_INT8) ? BC_LOAD_ADDR_8 : BC_LOAD_ADDR_U8);
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp]; bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
bins.mValue = ins.mSIntConst[0]; bins.mValue = ins.mSIntConst[0];
mIns.Push(bins); mIns.Push(bins);
@ -1534,7 +1559,6 @@ void ByteCodeBasicBlock::LoadEffectiveAddress(InterCodeProcedure* proc, const In
mIns.Push(sins); mIns.Push(sins);
} }
} }
void ByteCodeBasicBlock::CallFunction(InterCodeProcedure* proc, const InterInstruction& ins) void ByteCodeBasicBlock::CallFunction(InterCodeProcedure* proc, const InterInstruction& ins)
{ {
if (ins.mSTemp[0] < 0) if (ins.mSTemp[0] < 0)
@ -1560,19 +1584,10 @@ void ByteCodeBasicBlock::CallFunction(InterCodeProcedure* proc, const InterInstr
if (ins.mTTemp >= 0) if (ins.mTTemp >= 0)
{ {
if (ins.mTType == IT_FLOAT) ByteCodeInstruction bins(StoreTypedTmpCodes[ins.mTType]);
{
ByteCodeInstruction bins(BC_STORE_REG_32);
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp]; bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
mIns.Push(bins); mIns.Push(bins);
} }
else
{
ByteCodeInstruction bins(BC_STORE_REG_16);
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
mIns.Push(bins);
}
}
} }
void ByteCodeBasicBlock::CallAssembler(InterCodeProcedure* proc, const InterInstruction& ins) void ByteCodeBasicBlock::CallAssembler(InterCodeProcedure* proc, const InterInstruction& ins)
@ -1589,19 +1604,10 @@ void ByteCodeBasicBlock::CallAssembler(InterCodeProcedure* proc, const InterInst
if (ins.mTTemp >= 0) if (ins.mTTemp >= 0)
{ {
if (ins.mTType == IT_FLOAT) ByteCodeInstruction bins(StoreTypedTmpCodes[ins.mTType]);
{
ByteCodeInstruction bins(BC_STORE_REG_32);
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp]; bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
mIns.Push(bins); mIns.Push(bins);
} }
else
{
ByteCodeInstruction bins(BC_STORE_REG_16);
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
mIns.Push(bins);
}
}
} }
ByteCode ByteCodeBasicBlock::RelationalOperator(InterCodeProcedure* proc, const InterInstruction& ins) ByteCode ByteCodeBasicBlock::RelationalOperator(InterCodeProcedure* proc, const InterInstruction& ins)
@ -1851,7 +1857,7 @@ void ByteCodeBasicBlock::NumericConversion(InterCodeProcedure* proc, const Inter
} }
else else
{ {
ByteCodeInstruction lins(BC_LOAD_REG_16); ByteCodeInstruction lins(BC_LOAD_REG_8);
lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mSTemp[0]]; lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mSTemp[0]];
lins.mRegisterFinal = ins.mSFinal[0]; lins.mRegisterFinal = ins.mSFinal[0];
mIns.Push(lins); mIns.Push(lins);
@ -1877,16 +1883,11 @@ void ByteCodeBasicBlock::NumericConversion(InterCodeProcedure* proc, const Inter
} }
else else
{ {
ByteCodeInstruction lins(BC_LOAD_REG_16); ByteCodeInstruction lins(BC_LOAD_REG_8);
lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mSTemp[0]]; lins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mSTemp[0]];
lins.mRegisterFinal = ins.mSFinal[0]; lins.mRegisterFinal = ins.mSFinal[0];
mIns.Push(lins); mIns.Push(lins);
ByteCodeInstruction cins(BC_BINOP_ANDI_16);
cins.mRegister = BC_REG_ACCU;
cins.mValue = 0x00ff;
mIns.Push(cins);
ByteCodeInstruction sins(BC_STORE_REG_16); ByteCodeInstruction sins(BC_STORE_REG_16);
sins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp]; sins.mRegister = BC_REG_TMP + proc->mTempOffset[ins.mTTemp];
mIns.Push(sins); mIns.Push(sins);
@ -2347,6 +2348,22 @@ void ByteCodeBasicBlock::Compile(InterCodeProcedure* iproc, ByteCodeProcedure* p
case IC_LOAD_TEMPORARY: case IC_LOAD_TEMPORARY:
{ {
if (ins.mSTemp[0] != ins.mTTemp) if (ins.mSTemp[0] != ins.mTTemp)
{
switch (ins.mTType)
{
case IT_BOOL:
case IT_INT8:
{
ByteCodeInstruction lins(BC_LOAD_REG_8);
lins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]];
lins.mRegisterFinal = ins.mSFinal[0];
mIns.Push(lins);
ByteCodeInstruction sins(BC_STORE_REG_8);
sins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mTTemp];
mIns.Push(sins);
} break;
case IT_INT16:
case IT_POINTER:
{ {
ByteCodeInstruction lins(BC_LOAD_REG_16); ByteCodeInstruction lins(BC_LOAD_REG_16);
lins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]]; lins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]];
@ -2355,6 +2372,20 @@ void ByteCodeBasicBlock::Compile(InterCodeProcedure* iproc, ByteCodeProcedure* p
ByteCodeInstruction sins(BC_STORE_REG_16); ByteCodeInstruction sins(BC_STORE_REG_16);
sins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mTTemp]; sins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mTTemp];
mIns.Push(sins); mIns.Push(sins);
} break;
case IT_INT32:
case IT_FLOAT:
{
ByteCodeInstruction lins(BC_LOAD_REG_32);
lins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]];
lins.mRegisterFinal = ins.mSFinal[0];
mIns.Push(lins);
ByteCodeInstruction sins(BC_STORE_REG_32);
sins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mTTemp];
mIns.Push(sins);
} break;
}
} }
} break; } break;
case IC_BINARY_OPERATOR: case IC_BINARY_OPERATOR:
@ -2406,7 +2437,7 @@ void ByteCodeBasicBlock::Compile(InterCodeProcedure* iproc, ByteCodeProcedure* p
ByteCode code = RelationalOperator(iproc, ins); ByteCode code = RelationalOperator(iproc, ins);
ByteCodeInstruction bins(ByteCode(code - BC_BRANCHS_EQ + BC_SET_EQ)); ByteCodeInstruction bins(ByteCode(code - BC_BRANCHS_EQ + BC_SET_EQ));
mIns.Push(bins); mIns.Push(bins);
ByteCodeInstruction sins(BC_STORE_REG_16); ByteCodeInstruction sins(StoreTypedTmpCodes[ins.mTType]);
sins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mTTemp]; sins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mTTemp];
mIns.Push(sins); mIns.Push(sins);
} }
@ -2424,7 +2455,7 @@ void ByteCodeBasicBlock::Compile(InterCodeProcedure* iproc, ByteCodeProcedure* p
} }
else else
{ {
ByteCodeInstruction lins(BC_LOAD_REG_16); ByteCodeInstruction lins(InterTypeSize[ins.mSType[0]] == 1 ? BC_LOAD_REG_8 : BC_LOAD_REG_16);
lins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]]; lins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]];
lins.mRegisterFinal = ins.mSFinal[0]; lins.mRegisterFinal = ins.mSFinal[0];
mIns.Push(lins); mIns.Push(lins);
@ -2460,7 +2491,7 @@ void ByteCodeBasicBlock::Compile(InterCodeProcedure* iproc, ByteCodeProcedure* p
} }
else else
{ {
ByteCodeInstruction lins(BC_LOAD_REG_16); ByteCodeInstruction lins(InterTypeSize[ins.mSType[0]] == 1 ? BC_LOAD_REG_8 : BC_LOAD_REG_16);
lins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]]; lins.mRegister = BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]];
lins.mRegisterFinal = ins.mSFinal[0]; lins.mRegisterFinal = ins.mSFinal[0];
mIns.Push(lins); mIns.Push(lins);
@ -3060,7 +3091,10 @@ void ByteCodeProcedure::Disassemble(FILE * file, ByteCodeGenerator * generator,
fprintf(file, "%s:\n", proc->mIdent->mString); fprintf(file, "%s:\n", proc->mIdent->mString);
char tbuffer[10]; char tbuffer[10];
#if 0
for (int i = 0; i < proc->mTemporaries.Size(); i++)
printf("T%d = $%.2x\n", i, BC_REG_TMP + proc->mTempOffset[i]);
#endif
int i = 0; int i = 0;
while (i < mProgSize) while (i < mProgSize)
{ {
@ -3078,6 +3112,10 @@ void ByteCodeProcedure::Disassemble(FILE * file, ByteCodeGenerator * generator,
fprintf(file, "EXIT"); fprintf(file, "EXIT");
break; break;
case BC_CONST_8:
fprintf(file, "MOVB\t%s, #%d", TempName(generator->mMemory[mProgStart + i], tbuffer, proc), generator->mMemory[mProgStart + i + 1]);
i += 2;
break;
case BC_CONST_P8: case BC_CONST_P8:
fprintf(file, "MOV\t%s, #%d", TempName(generator->mMemory[mProgStart + i], tbuffer, proc), generator->mMemory[mProgStart + i + 1]); fprintf(file, "MOV\t%s, #%d", TempName(generator->mMemory[mProgStart + i], tbuffer, proc), generator->mMemory[mProgStart + i + 1]);
i += 2; i += 2;
@ -3095,6 +3133,14 @@ void ByteCodeProcedure::Disassemble(FILE * file, ByteCodeGenerator * generator,
i += 5; i += 5;
break; break;
case BC_LOAD_REG_8:
fprintf(file, "MOVB\tACCU, %s", TempName(generator->mMemory[mProgStart + i], tbuffer, proc));
i += 1;
break;
case BC_STORE_REG_8:
fprintf(file, "MOVB\t%s, ACCU", TempName(generator->mMemory[mProgStart + i], tbuffer, proc));
i += 1;
break;
case BC_LOAD_REG_16: case BC_LOAD_REG_16:
fprintf(file, "MOV\tACCU, %s", TempName(generator->mMemory[mProgStart + i], tbuffer, proc)); fprintf(file, "MOV\tACCU, %s", TempName(generator->mMemory[mProgStart + i], tbuffer, proc));
i += 1; i += 1;
@ -3116,6 +3162,10 @@ void ByteCodeProcedure::Disassemble(FILE * file, ByteCodeGenerator * generator,
i += 1; i += 1;
break; break;
case BC_LOAD_ABS_8:
fprintf(file, "MOVUB\t%s, $%04x", TempName(generator->mMemory[mProgStart + i + 2], tbuffer, proc), uint16(generator->mMemory[mProgStart + i + 0] + 256 * generator->mMemory[mProgStart + i + 1]));
i += 3;
break;
case BC_LOAD_ABS_U8: case BC_LOAD_ABS_U8:
fprintf(file, "MOVUB\t%s, $%04x", TempName(generator->mMemory[mProgStart + i + 2], tbuffer, proc), uint16(generator->mMemory[mProgStart + i + 0] + 256 * generator->mMemory[mProgStart + i + 1])); fprintf(file, "MOVUB\t%s, $%04x", TempName(generator->mMemory[mProgStart + i + 2], tbuffer, proc), uint16(generator->mMemory[mProgStart + i + 0] + 256 * generator->mMemory[mProgStart + i + 1]));
i += 3; i += 3;
@ -3151,6 +3201,10 @@ void ByteCodeProcedure::Disassemble(FILE * file, ByteCodeGenerator * generator,
i += 3; i += 3;
break; break;
case BC_LOAD_LOCAL_8:
fprintf(file, "MOVB\t%s, %d(FP)", TempName(generator->mMemory[mProgStart + i + 0], tbuffer, proc), generator->mMemory[mProgStart + i + 1]);
i += 2;
break;
case BC_LOAD_LOCAL_U8: case BC_LOAD_LOCAL_U8:
fprintf(file, "MOVUB\t%s, %d(FP)", TempName(generator->mMemory[mProgStart + i + 0], tbuffer, proc), generator->mMemory[mProgStart + i + 1]); fprintf(file, "MOVUB\t%s, %d(FP)", TempName(generator->mMemory[mProgStart + i + 0], tbuffer, proc), generator->mMemory[mProgStart + i + 1]);
i += 2; i += 2;
@ -3477,6 +3531,10 @@ void ByteCodeProcedure::Disassemble(FILE * file, ByteCodeGenerator * generator,
i += 2; i += 2;
break; break;
case BC_LOAD_ADDR_8:
fprintf(file, "MOVB\t%s, (ADDR + %d)", TempName(generator->mMemory[mProgStart + i + 0], tbuffer, proc), generator->mMemory[mProgStart + i + 1]);
i += 2;
break;
case BC_LOAD_ADDR_U8: case BC_LOAD_ADDR_U8:
fprintf(file, "MOVUB\t%s, (ADDR + %d)", TempName(generator->mMemory[mProgStart + i + 0], tbuffer, proc), generator->mMemory[mProgStart + i + 1]); fprintf(file, "MOVUB\t%s, (ADDR + %d)", TempName(generator->mMemory[mProgStart + i + 0], tbuffer, proc), generator->mMemory[mProgStart + i + 1]);
i += 2; i += 2;

View File

@ -8,17 +8,21 @@ enum ByteCode
BC_NOP, BC_NOP,
BC_EXIT, BC_EXIT,
BC_CONST_8,
BC_CONST_P8, BC_CONST_P8,
BC_CONST_N8, BC_CONST_N8,
BC_CONST_16, BC_CONST_16,
BC_CONST_32, BC_CONST_32,
BC_LOAD_REG_8,
BC_STORE_REG_8,
BC_LOAD_REG_16, BC_LOAD_REG_16,
BC_STORE_REG_16, BC_STORE_REG_16,
BC_ADDR_REG, BC_ADDR_REG,
BC_LOAD_REG_32, BC_LOAD_REG_32,
BC_STORE_REG_32, BC_STORE_REG_32,
BC_LOAD_ABS_8,
BC_LOAD_ABS_U8, BC_LOAD_ABS_U8,
BC_LOAD_ABS_I8, BC_LOAD_ABS_I8,
BC_LOAD_ABS_16, BC_LOAD_ABS_16,
@ -30,6 +34,7 @@ enum ByteCode
BC_LEA_ABS, BC_LEA_ABS,
BC_LOAD_LOCAL_8,
BC_LOAD_LOCAL_U8, BC_LOAD_LOCAL_U8,
BC_LOAD_LOCAL_I8, BC_LOAD_LOCAL_I8,
BC_LOAD_LOCAL_16, BC_LOAD_LOCAL_16,
@ -45,6 +50,7 @@ enum ByteCode
BC_STORE_FRAME_16, BC_STORE_FRAME_16,
BC_STORE_FRAME_32, BC_STORE_FRAME_32,
BC_LOAD_ADDR_8,
BC_LOAD_ADDR_U8, BC_LOAD_ADDR_U8,
BC_LOAD_ADDR_I8, BC_LOAD_ADDR_I8,
BC_LOAD_ADDR_16, BC_LOAD_ADDR_16,

View File

@ -582,15 +582,26 @@ int Emulator::Emulate(int startIP)
int accu = mMemory[BC_REG_ACCU] + 256 * mMemory[BC_REG_ACCU + 1]; int accu = mMemory[BC_REG_ACCU] + 256 * mMemory[BC_REG_ACCU + 1];
int ptr = mMemory[BC_REG_ADDR] + 256 * mMemory[BC_REG_ADDR + 1]; int ptr = mMemory[BC_REG_ADDR] + 256 * mMemory[BC_REG_ADDR + 1];
int sp = mMemory[BC_REG_STACK] + 256 * mMemory[BC_REG_STACK + 1]; int sp = mMemory[BC_REG_STACK] + 256 * mMemory[BC_REG_STACK + 1];
printf("%04x (A:%04x P:%04x S:%04x) %04x %04x %04x %04x %04x %04x %04x %04x\n", addr, accu, ptr, sp, printf("%04x (A:%04x P:%04x S:%04x) %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x\n", addr, accu, ptr, sp,
mMemory[BC_REG_TMP + 0] + 256 * mMemory[BC_REG_TMP + 1], mMemory[BC_REG_TMP + 0] + 256 * mMemory[BC_REG_TMP + 1],
mMemory[BC_REG_TMP + 2] + 256 * mMemory[BC_REG_TMP + 3], mMemory[BC_REG_TMP + 2] + 256 * mMemory[BC_REG_TMP + 3],
mMemory[BC_REG_TMP + 4] + 256 * mMemory[BC_REG_TMP + 5], mMemory[BC_REG_TMP + 4] + 256 * mMemory[BC_REG_TMP + 5],
mMemory[BC_REG_TMP + 6] + 256 * mMemory[BC_REG_TMP + 7], mMemory[BC_REG_TMP + 6] + 256 * mMemory[BC_REG_TMP + 7],
mMemory[BC_REG_TMP + 8] + 256 * mMemory[BC_REG_TMP + 9], mMemory[BC_REG_TMP + 8] + 256 * mMemory[BC_REG_TMP + 9],
mMemory[BC_REG_TMP + 10] + 256 * mMemory[BC_REG_TMP + 11], mMemory[BC_REG_TMP + 10] + 256 * mMemory[BC_REG_TMP + 11],
mMemory[BC_REG_TMP + 12] + 256 * mMemory[BC_REG_TMP + 13], mMemory[BC_REG_TMP + 12] + 256 * mMemory[BC_REG_TMP + 13],
mMemory[BC_REG_TMP + 14] + 256 * mMemory[BC_REG_TMP + 15] mMemory[BC_REG_TMP + 14] + 256 * mMemory[BC_REG_TMP + 15],
mMemory[BC_REG_TMP + 16] + 256 * mMemory[BC_REG_TMP + 17],
mMemory[BC_REG_TMP + 18] + 256 * mMemory[BC_REG_TMP + 19],
mMemory[BC_REG_TMP + 20] + 256 * mMemory[BC_REG_TMP + 21],
mMemory[BC_REG_TMP + 22] + 256 * mMemory[BC_REG_TMP + 23],
mMemory[BC_REG_TMP + 24] + 256 * mMemory[BC_REG_TMP + 25],
mMemory[BC_REG_TMP + 26] + 256 * mMemory[BC_REG_TMP + 27],
mMemory[BC_REG_TMP + 28] + 256 * mMemory[BC_REG_TMP + 29],
mMemory[BC_REG_TMP + 30] + 256 * mMemory[BC_REG_TMP + 31]
); );
} }

View File

@ -5,6 +5,16 @@
#include <math.h> #include <math.h>
#include <crtdbg.h> #include <crtdbg.h>
int InterTypeSize[] = {
0,
1,
1,
2,
4,
4,
2
};
ValueSet::ValueSet(void) ValueSet::ValueSet(void)
{ {
mSize = 32; mSize = 32;
@ -1447,36 +1457,44 @@ void InterInstruction::CollectSimpleLocals(FastNumberSet& complexLocals, FastNum
{ {
case IC_LOAD: case IC_LOAD:
if (mMemory == IM_LOCAL && mSTemp[0] < 0) if (mMemory == IM_LOCAL && mSTemp[0] < 0)
{
if (localTypes[mVarIndex] == IT_NONE || localTypes[mVarIndex] == mTType)
{ {
localTypes[mVarIndex] = mTType; localTypes[mVarIndex] = mTType;
if (mOperandSize == 2)
simpleLocals += mVarIndex; simpleLocals += mVarIndex;
}
else else
complexLocals += mVarIndex; complexLocals += mVarIndex;
} }
else if (mMemory == IM_PARAM && mSTemp[0] < 0) else if (mMemory == IM_PARAM && mSTemp[0] < 0)
{
if (paramTypes[mVarIndex] == IT_NONE || paramTypes[mVarIndex] == mTType)
{ {
paramTypes[mVarIndex] = mTType; paramTypes[mVarIndex] = mTType;
if (mOperandSize == 2)
simpleParams += mVarIndex; simpleParams += mVarIndex;
}
else else
complexParams += mVarIndex; complexParams += mVarIndex;
} }
break; break;
case IC_STORE: case IC_STORE:
if (mMemory == IM_LOCAL && mSTemp[1] < 0) if (mMemory == IM_LOCAL && mSTemp[1] < 0)
{
if (localTypes[mVarIndex] == IT_NONE || localTypes[mVarIndex] == mSType[0])
{ {
localTypes[mVarIndex] = mSType[0]; localTypes[mVarIndex] = mSType[0];
if (mOperandSize == 2)
simpleLocals += mVarIndex; simpleLocals += mVarIndex;
}
else else
complexLocals += mVarIndex; complexLocals += mVarIndex;
} }
else if (mMemory == IM_PARAM && mSTemp[1] < 0) else if (mMemory == IM_PARAM && mSTemp[1] < 0)
{ {
paramTypes[mVarIndex] = mSType[0]; if (paramTypes[mVarIndex] == IT_NONE || paramTypes[mVarIndex] == mSType[0])
if (mOperandSize == 2) {
localTypes[mVarIndex] = mSType[0];
simpleParams += mVarIndex; simpleParams += mVarIndex;
}
else else
complexParams += mVarIndex; complexParams += mVarIndex;
} }
@ -1518,6 +1536,7 @@ void InterInstruction::SimpleLocalToTemp(int vindex, int temp)
{ {
mCode = IC_CONSTANT; mCode = IC_CONSTANT;
mIntValue = mSIntConst[0]; mIntValue = mSIntConst[0];
mFloatValue = mSFloatConst[0];
} }
else else
{ {
@ -3846,7 +3865,7 @@ void InterCodeProcedure::ReduceTemporaries(void)
for (j = numFixedTemporaries; j < numTemps; j++) for (j = numFixedTemporaries; j < numTemps; j++)
{ {
if (mRenameTable[j] >= 0 && (collisionSet[i][j] || !TypeCompatible(mTemporaries[j], mTemporaries[i]))) if (mRenameTable[j] >= 0 && (collisionSet[i][j] || InterTypeSize[mTemporaries[j]] != InterTypeSize[mTemporaries[i]]))
{ {
usedTemps += mRenameTable[j]; usedTemps += mRenameTable[j];
} }
@ -3890,7 +3909,7 @@ void InterCodeProcedure::ReduceTemporaries(void)
for (int i = 0; i < mTemporaries.Size(); i++) for (int i = 0; i < mTemporaries.Size(); i++)
{ {
int size = mTemporaries[i] == IT_FLOAT ? 4 : 2; int size = InterTypeSize[mTemporaries[i]];
if (callerSavedTemps + size <= 16 && !callerSaved[i]) if (callerSavedTemps + size <= 16 && !callerSaved[i])
{ {

View File

@ -45,6 +45,8 @@ enum InterType
IT_POINTER IT_POINTER
}; };
extern int InterTypeSize[];
enum InterMemory enum InterMemory
{ {
IM_NONE, IM_NONE,

View File

@ -824,6 +824,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
if (!vr.mType->IsIntegerType()) if (!vr.mType->IsIntegerType())
mErrors->Error(exp->mLocation, "Index operand is not integral number"); mErrors->Error(exp->mLocation, "Index operand is not integral number");
vr = CoerceType(proc, block, vr, TheSignedIntTypeDeclaration);
InterInstruction cins; InterInstruction cins;
cins.mCode = IC_CONSTANT; cins.mCode = IC_CONSTANT;
cins.mIntValue = vl.mType->mBase->mSize; cins.mIntValue = vl.mType->mBase->mSize;
@ -1442,6 +1444,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
mErrors->Error(texp->mLocation, "Cannot assign incompatible types"); mErrors->Error(texp->mLocation, "Cannot assign incompatible types");
vr = CoerceType(proc, block, vr, pdec->mBase); vr = CoerceType(proc, block, vr, pdec->mBase);
} }
else if (vr.mType->IsIntegerType() && vr.mType->mSize < 2)
{
vr = CoerceType(proc, block, vr, TheSignedIntTypeDeclaration);
}
InterInstruction wins; InterInstruction wins;
wins.mCode = IC_STORE; wins.mCode = IC_STORE;
@ -2274,7 +2280,7 @@ void InterCodeGenerator::TranslateLogic(Declaration* procType, InterCodeProcedur
InterInstruction ins; InterInstruction ins;
ins.mCode = IC_BRANCH; ins.mCode = IC_BRANCH;
ins.mSType[0] = IT_BOOL; ins.mSType[0] = InterTypeOf(vr.mType);
ins.mSTemp[0] = vr.mTemp; ins.mSTemp[0] = vr.mTemp;
block->Append(ins); block->Append(ins);

View File

@ -1373,9 +1373,12 @@ void NativeCodeBasicBlock::LoadConstantToReg(InterCodeProcedure * proc, const In
{ {
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, ins.mIntValue & 0xff)); mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, ins.mIntValue & 0xff));
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg)); mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg));
if (InterTypeSize[ins.mTType] > 1)
{
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins.mIntValue >> 8) & 0xff)); mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins.mIntValue >> 8) & 0xff));
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg + 1)); mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg + 1));
} }
}
} }
@ -2214,10 +2217,14 @@ void NativeCodeBasicBlock::LoadValueToReg(InterCodeProcedure* proc, const InterI
mIns.Push(*ainsl); mIns.Push(*ainsl);
} }
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg)); mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg));
if (InterTypeSize[ins.mTType] > 1)
{
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, 0)); mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, 0));
if (ainsh) mIns.Push(*ainsh); if (ainsh) mIns.Push(*ainsh);
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg + 1)); mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg + 1));
} }
}
else if (ins.mOperandSize == 2) else if (ins.mOperandSize == 2)
{ {
if (ins.mMemory == IM_GLOBAL) if (ins.mMemory == IM_GLOBAL)
@ -2297,10 +2304,13 @@ void NativeCodeBasicBlock::LoadValueToReg(InterCodeProcedure* proc, const InterI
mIns.Push(*ainsl); mIns.Push(*ainsl);
} }
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg)); mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg));
if (InterTypeSize[ins.mTType] > 1)
{
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, 0)); mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, 0));
if (ainsh) mIns.Push(*ainsh); if (ainsh) mIns.Push(*ainsh);
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg + 1)); mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg + 1));
} }
}
else if (ins.mOperandSize == 2) else if (ins.mOperandSize == 2)
{ {
int src = BC_REG_TMP + proc->mTempOffset[ins.mSTemp[0]]; int src = BC_REG_TMP + proc->mTempOffset[ins.mSTemp[0]];
@ -2315,6 +2325,9 @@ void NativeCodeBasicBlock::LoadValueToReg(InterCodeProcedure* proc, const InterI
mIns.Push(NativeCodeInstruction(ASMIT_SEC, ASMIM_IMPLIED)); mIns.Push(NativeCodeInstruction(ASMIT_SEC, ASMIM_IMPLIED));
mIns.Push(*ainsl); mIns.Push(*ainsl);
} }
if (InterTypeSize[ins.mTType] > 1)
{
if (reg == src) if (reg == src)
mIns.Push(NativeCodeInstruction(ASMIT_TAX, ASMIM_IMPLIED)); mIns.Push(NativeCodeInstruction(ASMIT_TAX, ASMIM_IMPLIED));
else else
@ -2327,6 +2340,9 @@ void NativeCodeBasicBlock::LoadValueToReg(InterCodeProcedure* proc, const InterI
if (reg == src) if (reg == src)
mIns.Push(NativeCodeInstruction(ASMIT_STX, ASMIM_ZERO_PAGE, reg)); mIns.Push(NativeCodeInstruction(ASMIT_STX, ASMIM_ZERO_PAGE, reg));
} }
else
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg));
}
} }
} }
} }
@ -4758,8 +4774,11 @@ void NativeCodeProcedure::CompileInterBlock(InterCodeProcedure* iproc, InterCode
fblock->Close(rblock, nullptr, ASMIT_JMP); fblock->Close(rblock, nullptr, ASMIT_JMP);
rblock->mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_TMP + iproc->mTempOffset[ins.mTTemp])); rblock->mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_TMP + iproc->mTempOffset[ins.mTTemp]));
if (InterTypeSize[ins.mTType] > 1)
{
rblock->mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, 0)); rblock->mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, 0));
rblock->mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_TMP + iproc->mTempOffset[ins.mTTemp] + 1)); rblock->mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_TMP + iproc->mTempOffset[ins.mTTemp] + 1));
}
block = rblock; block = rblock;
} }
@ -4835,6 +4854,7 @@ void NativeCodeProcedure::CompileInterBlock(InterCodeProcedure* iproc, InterCode
else else
{ {
block->mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]])); block->mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]]));
if (InterTypeSize[ins.mSType[0]] > 1)
block->mIns.Push(NativeCodeInstruction(ASMIT_ORA, ASMIM_ZERO_PAGE, BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]] + 1)); block->mIns.Push(NativeCodeInstruction(ASMIT_ORA, ASMIM_ZERO_PAGE, BC_REG_TMP + iproc->mTempOffset[ins.mSTemp[0]] + 1));
block->Close(CompileBlock(iproc, iblock->mTrueJump), CompileBlock(iproc, iblock->mFalseJump), ASMIT_BNE); block->Close(CompileBlock(iproc, iblock->mTrueJump), CompileBlock(iproc, iblock->mFalseJump), ASMIT_BNE);