Attempt to correct INC/DEC access

This commit is contained in:
JoshuaMK 2022-01-26 01:03:02 -06:00
parent c0cf50c6f7
commit 820b98b4a9
4 changed files with 22 additions and 2 deletions

View file

@ -189,7 +189,7 @@ namespace arookas {
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol) { public override void Compile(sunCompiler compiler, sunStorableSymbol symbol) {
symbol.CompileInc(compiler); symbol.CompileInc(compiler);
symbol.CompileSet(compiler); symbol.CompilePop(compiler);
} }
} }
@ -199,7 +199,7 @@ namespace arookas {
public override void Compile(sunCompiler compiler, sunStorableSymbol symbol) { public override void Compile(sunCompiler compiler, sunStorableSymbol symbol) {
symbol.CompileDec(compiler); symbol.CompileDec(compiler);
symbol.CompileSet(compiler); symbol.CompilePop(compiler);
} }
} }
} }

View file

@ -184,6 +184,7 @@ namespace arookas {
TraceInstruction("inc {0} {1}", display, index); TraceInstruction("inc {0} {1}", display, index);
#endif #endif
mText.Writer.Write8(0x06); mText.Writer.Write8(0x06);
mText.Writer.Write8(0x04);
mText.Writer.WriteS32(display); mText.Writer.WriteS32(display);
mText.Writer.WriteS32(index); mText.Writer.WriteS32(index);
} }
@ -192,6 +193,7 @@ namespace arookas {
TraceInstruction("dec {0} {1}", display, index); TraceInstruction("dec {0} {1}", display, index);
#endif #endif
mText.Writer.Write8(0x07); mText.Writer.Write8(0x07);
mText.Writer.Write8(0x04);
mText.Writer.WriteS32(display); mText.Writer.WriteS32(display);
mText.Writer.WriteS32(index); mText.Writer.WriteS32(index);
} }

View file

@ -90,6 +90,20 @@ namespace arookas {
} }
} }
class sunVariablePopSite : sunSymbolRelocation<sunVariableSymbol> {
public sunVariablePopSite(sunBinary binary, sunVariableSymbol symbol)
: base(binary, symbol) {
mBinary.WritePOP();
}
public override void Relocate() {
mBinary.Keep();
mBinary.Goto(mPoint);
mBinary.WritePOP();
mBinary.Back();
}
}
class sunVariableIncSite : sunSymbolRelocation<sunVariableSymbol> { class sunVariableIncSite : sunSymbolRelocation<sunVariableSymbol> {
public sunVariableIncSite(sunBinary binary, sunVariableSymbol symbol) public sunVariableIncSite(sunBinary binary, sunVariableSymbol symbol)
: base(binary, symbol) { : base(binary, symbol) {

View file

@ -255,6 +255,7 @@ namespace arookas {
} }
public abstract void CompileGet(sunCompiler compiler); public abstract void CompileGet(sunCompiler compiler);
public abstract void CompileSet(sunCompiler compiler); public abstract void CompileSet(sunCompiler compiler);
public abstract void CompilePop(sunCompiler compiler);
public virtual void CompileInc(sunCompiler compiler) { public virtual void CompileInc(sunCompiler compiler) {
CompileGet(compiler); CompileGet(compiler);
compiler.Binary.WriteINT(1); compiler.Binary.WriteINT(1);
@ -305,6 +306,9 @@ namespace arookas {
public override void CompileDec(sunCompiler compiler) { public override void CompileDec(sunCompiler compiler) {
OpenRelocation(new sunVariableDecSite(compiler.Binary, this)); OpenRelocation(new sunVariableDecSite(compiler.Binary, this));
} }
public override void CompilePop(sunCompiler compiler) {
OpenRelocation(new sunVariablePopSite(compiler.Binary, this));
}
} }
class sunConstantSymbol : sunStorableSymbol { class sunConstantSymbol : sunStorableSymbol {