diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/Procedure.java b/src/main/java/dk/camelot64/kickc/model/symbols/Procedure.java index 259f17701..1398823b8 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/Procedure.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/Procedure.java @@ -2,6 +2,7 @@ package dk.camelot64.kickc.model.symbols; import dk.camelot64.kickc.model.Comment; import dk.camelot64.kickc.model.Program; +import dk.camelot64.kickc.model.statements.StatementSource; import dk.camelot64.kickc.model.types.SymbolType; import dk.camelot64.kickc.model.types.SymbolTypeProcedure; import dk.camelot64.kickc.model.values.ProcedureRef; @@ -38,6 +39,8 @@ public class Procedure extends Scope { private final List constructorRefs; /** Is this procedure declared as a constructor procedure. */ private boolean isConstructor; + /** The source of the procedure definition. */ + private StatementSource definitionSource; /** The names of all legal intrinsic procedures. */ final public static List INTRINSIC_PROCEDURES = Arrays.asList( @@ -93,6 +96,14 @@ public class Procedure extends Scope { this.isConstructor = false; } + public StatementSource getDefinitionSource() { + return definitionSource; + } + + public void setDefinitionSource(StatementSource definitionSource) { + this.definitionSource = definitionSource; + } + public CallingConvention getCallingConvention() { return callingConvention; } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java index 18757cf90..121a95c7a 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java @@ -405,12 +405,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor { if(Operators.ADDRESS_OF.equals(programExpression.getOperator())) { RValue rValue = ((ProgramExpressionUnary) programExpression).getOperand(); - if(rValue instanceof SymbolVariableRef) { - Symbol toSymbol = getScope().getSymbol((SymbolVariableRef) rValue); - if(toSymbol instanceof Variable) { - final Variable variable = (Variable) toSymbol; - final String stmtStr = currentStmt.toString(getProgram(), false); - updateAddressOfVariable(variable, stmtStr); - } - } + updateAddressOfValue(rValue, currentStmt); } }); ProgramValueIterator.execute(getProgram(), (programValue, currentStmt, stmtIt, currentBlock) -> { if(programValue.get() instanceof ConstantSymbolPointer) { // Values containing constant pointers Value value = ((ConstantSymbolPointer) programValue.get()).getToSymbol(); - if(value instanceof SymbolVariableRef) { - Symbol toSymbol = getScope().getSymbol((SymbolVariableRef) value); - if(toSymbol instanceof Variable) { - final Variable variable = (Variable) toSymbol; - if(!variable.isNoModify() && !variable.isVolatile()) { - final String stmtStr = currentStmt == null ? toSymbol.toString(getProgram()) : currentStmt.toString(getProgram(), false); - updateAddressOfVariable(variable, stmtStr); - } - } - } + updateAddressOfValue(value, currentStmt); } }); return false; } - private void updateAddressOfVariable(Variable variable, String stmtStr) { - if(variable.getArraySpec()!=null) - return; + /** + * Modify variable/procedure affected by address-of + * + * @param value The value affected by address-of + * @param currentStmt The current statement + */ + private void updateAddressOfValue(Value value, Statement currentStmt) { + if(value instanceof SymbolRef) { + Symbol toSymbol = getScope().getSymbol((SymbolRef) value); + final String stmtStr = currentStmt == null ? toSymbol.toString(getProgram()) : currentStmt.toString(getProgram(), false); + if(toSymbol instanceof Variable) { + final Variable variable = (Variable) toSymbol; + if(!variable.isNoModify() && !variable.isVolatile()) { + if(variable.getArraySpec() != null) + return; - if(variable.getType() instanceof SymbolTypeStruct) { - variable.setKind(Variable.Kind.LOAD_STORE); - SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify()); - variable.setType(typeQualified); - getLog().append("Setting struct to load/store in variable affected by address-of " + stmtStr); - //getLog().append("Setting struct to load/store in variable affected by address-of: " + variable.toString() + " in " + stmtStr); - } else { - variable.setKind(Variable.Kind.LOAD_STORE); - SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify()); - variable.setType(typeQualified); - getLog().append("Setting inferred volatile on symbol affected by address-of " + stmtStr); - //getLog().append("Setting inferred volatile on symbol affected by address-of: " + variable.toString() + " in " + stmtStr); + if(variable.getType() instanceof SymbolTypeStruct) { + variable.setKind(Variable.Kind.LOAD_STORE); + SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify()); + variable.setType(typeQualified); + getLog().append("Setting struct to load/store in variable affected by address-of " + stmtStr); + //getLog().append("Setting struct to load/store in variable affected by address-of: " + variable.toString() + " in " + stmtStr); + } else { + variable.setKind(Variable.Kind.LOAD_STORE); + SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify()); + variable.setType(typeQualified); + getLog().append("Setting inferred volatile on symbol affected by address-of " + stmtStr); + //getLog().append("Setting inferred volatile on symbol affected by address-of: " + variable.toString() + " in " + stmtStr); + } + } + } else if(toSymbol instanceof Procedure) { + if(((Procedure) toSymbol).getParameters().size() > 0) { + ((Procedure) toSymbol).setCallingConvention(Procedure.CallingConvention.STACK_CALL); + getLog().append("Setting inferred __stackcall on procedure affected by address-of " + toSymbol.toString(getProgram()) + " caused by statement " + stmtStr); + ; + } + } } } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1CallStackVarPrepare.java b/src/main/java/dk/camelot64/kickc/passes/Pass1CallStackVarPrepare.java index 279aae34a..38f41aa01 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1CallStackVarPrepare.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1CallStackVarPrepare.java @@ -1,14 +1,21 @@ package dk.camelot64.kickc.passes; +import dk.camelot64.kickc.model.Comment; +import dk.camelot64.kickc.model.ControlFlowBlock; import dk.camelot64.kickc.model.Program; +import dk.camelot64.kickc.model.statements.StatementAssignment; import dk.camelot64.kickc.model.symbols.Procedure; import dk.camelot64.kickc.model.symbols.Variable; import dk.camelot64.kickc.model.types.SymbolType; +import dk.camelot64.kickc.model.values.LValue; +import dk.camelot64.kickc.model.values.ParamValue; import dk.camelot64.kickc.model.values.VariableRef; +import java.util.ArrayList; +import java.util.Collections; import java.util.Set; -/** Handle calling conventions {@link Procedure.CallingConvention#STACK_CALL} {@link Procedure.CallingConvention#VAR_CALL} by converting to call-prepare, call-execute, call-finalize */ +/** Handle calling conventions {@link Procedure.CallingConvention#STACK_CALL} by converting parameters, return values and modified variables to load/store and by adding parameter assignemtn statements to procedures*/ public class Pass1CallStackVarPrepare extends Pass2SsaOptimization { public Pass1CallStackVarPrepare(Program program) { @@ -47,6 +54,20 @@ public class Pass1CallStackVarPrepare extends Pass2SsaOptimization { } } + // Add parameter assignments at start of procedure in STACK_CALL procedures + for(Procedure procedure : getScope().getAllProcedures(true)) { + if(Procedure.CallingConvention.STACK_CALL.equals(procedure.getCallingConvention())) { + final ControlFlowBlock procedureBlock = getGraph().getBlock(procedure.getLabel().getRef()); + final ArrayList params = new ArrayList<>(procedure.getParameters()); + Collections.reverse(params); + for(Variable param : params) { + final StatementAssignment paramAssignment = new StatementAssignment((LValue) param.getRef(), new ParamValue((VariableRef) param.getRef()), true, null, Comment.NO_COMMENTS); + procedureBlock.getStatements().add(0, paramAssignment); + getLog().append("Adding parameter assignment in "+procedure.getCallingConvention().getName()+" procedure "+paramAssignment.toString(getProgram(), false)); + } + } + } + return false; } diff --git a/src/test/java/dk/camelot64/kickc/test/TestProgramsFast.java b/src/test/java/dk/camelot64/kickc/test/TestProgramsFast.java index d2a48d2f9..4a868695e 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestProgramsFast.java +++ b/src/test/java/dk/camelot64/kickc/test/TestProgramsFast.java @@ -3020,6 +3020,11 @@ public class TestProgramsFast extends TestPrograms { compileAndCompare("function-pointer-param-workaround.c"); } + //@Test + //public void testFunctionPointerParam0() throws IOException { + // compileAndCompare("function-pointer-param-0.c", log().verboseParse().verboseCreateSsa()); + //} + @Test public void testFunctionPointerNoargCall14() throws IOException { compileAndCompare("function-pointer-noarg-call-14.c"); diff --git a/src/test/kc/function-pointer-param-0.c b/src/test/kc/function-pointer-param-0.c new file mode 100644 index 000000000..cbc4689e9 --- /dev/null +++ b/src/test/kc/function-pointer-param-0.c @@ -0,0 +1,35 @@ +// Test function pointers with parameters +// Currently the parameter is not transferred properly + +void main() { + + // A pointer to a function taking a single char param + void(*f)(char); + + for(char i=0;i<160;i++) { + if((i&1)==0) { + fn3(i); + continue; + } + if((i&3)==1) { + f = &fn1; + } else { + f = &fn2; + } + (*f)(i); + } +} + +char* const SCREEN = (char*)0x400; + +void fn1(char c) { + SCREEN[c] = 'a'; +} + +void fn2(char d) { + SCREEN[d] = 'b'; +} + +__stackcall void fn3(char e) { + SCREEN[e] = 'c'; +} \ No newline at end of file diff --git a/src/test/ref/examples/rom/rom.log b/src/test/ref/examples/rom/rom.log index 1aa79a7d0..b4b926a84 100644 --- a/src/test/ref/examples/rom/rom.log +++ b/src/test/ref/examples/rom/rom.log @@ -1,4 +1,6 @@ Loading link script "rom.ld" +Adding parameter assignment in __stackcall procedure call1::param2 = param(call1::param2) +Adding parameter assignment in __stackcall procedure call1::param1 = param(call1::param1) Calling convention __stackcall adding prepare/execute/finalize for main::$0 = call call1 1 2 Calling convention __stackcall adding prepare/execute/finalize for main::$1 = call call1 3 4 Calling convention STACK_CALL replacing param(call1::param1) with stackidx(byte,call1::OFFSET_STACK_PARAM1) diff --git a/src/test/ref/procedure-callingconvention-stack-0.asm b/src/test/ref/procedure-callingconvention-stack-0.asm index ad606b33f..c1be5b20b 100644 --- a/src/test/ref/procedure-callingconvention-stack-0.asm +++ b/src/test/ref/procedure-callingconvention-stack-0.asm @@ -16,7 +16,6 @@ plus: { .const OFFSET_STACK_B = 0 .const OFFSET_STACK_RETURN = 1 .label a = 2 - // } tsx lda STACK_BASE+OFFSET_STACK_A,x sta.z a diff --git a/src/test/ref/procedure-callingconvention-stack-0.log b/src/test/ref/procedure-callingconvention-stack-0.log index 93f099948..e1b2a0044 100644 --- a/src/test/ref/procedure-callingconvention-stack-0.log +++ b/src/test/ref/procedure-callingconvention-stack-0.log @@ -1,3 +1,5 @@ +Adding parameter assignment in __stackcall procedure plus::b = param(plus::b) +Adding parameter assignment in __stackcall procedure plus::a = param(plus::a) Calling convention __stackcall adding prepare/execute/finalize for main::$0 = call plus '0' 7 Calling convention STACK_CALL replacing param(plus::a) with stackidx(byte,plus::OFFSET_STACK_A) Calling convention STACK_CALL replacing param(plus::b) with stackidx(byte,plus::OFFSET_STACK_B) @@ -300,7 +302,6 @@ plus: { .const OFFSET_STACK_B = 0 .const OFFSET_STACK_RETURN = 1 .label a = 2 - // } // [0] plus::a#0 = stackidx(byte,plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_A,x diff --git a/src/test/ref/procedure-callingconvention-stack-1.asm b/src/test/ref/procedure-callingconvention-stack-1.asm index a039a0c7c..fc730c904 100644 --- a/src/test/ref/procedure-callingconvention-stack-1.asm +++ b/src/test/ref/procedure-callingconvention-stack-1.asm @@ -16,7 +16,6 @@ plus: { .const OFFSET_STACK_B = 0 .const OFFSET_STACK_RETURN = 1 .label a = 2 - // } tsx lda STACK_BASE+OFFSET_STACK_A,x sta.z a diff --git a/src/test/ref/procedure-callingconvention-stack-1.log b/src/test/ref/procedure-callingconvention-stack-1.log index 80f611604..cc61ae2b7 100644 --- a/src/test/ref/procedure-callingconvention-stack-1.log +++ b/src/test/ref/procedure-callingconvention-stack-1.log @@ -1,3 +1,5 @@ +Adding parameter assignment in __stackcall procedure plus::b = param(plus::b) +Adding parameter assignment in __stackcall procedure plus::a = param(plus::a) Calling convention __stackcall adding prepare/execute/finalize for main::$0 = call plus '0' 7 Calling convention STACK_CALL replacing param(plus::a) with stackidx(byte,plus::OFFSET_STACK_A) Calling convention STACK_CALL replacing param(plus::b) with stackidx(byte,plus::OFFSET_STACK_B) @@ -300,7 +302,6 @@ plus: { .const OFFSET_STACK_B = 0 .const OFFSET_STACK_RETURN = 1 .label a = 2 - // } // [0] plus::a#0 = stackidx(byte,plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_A,x diff --git a/src/test/ref/procedure-callingconvention-stack-10.asm b/src/test/ref/procedure-callingconvention-stack-10.asm index d908b5fa4..12062a067 100644 --- a/src/test/ref/procedure-callingconvention-stack-10.asm +++ b/src/test/ref/procedure-callingconvention-stack-10.asm @@ -24,7 +24,6 @@ __start: { print: { .const OFFSET_STACK_P_X = 1 .const OFFSET_STACK_P_Y = 0 - // } tsx lda STACK_BASE+OFFSET_STACK_P_X,x tay diff --git a/src/test/ref/procedure-callingconvention-stack-10.log b/src/test/ref/procedure-callingconvention-stack-10.log index 5b5ab8bd5..68fa48f74 100644 --- a/src/test/ref/procedure-callingconvention-stack-10.log +++ b/src/test/ref/procedure-callingconvention-stack-10.log @@ -1,4 +1,6 @@ Converting variable modified inside __stackcall procedure main() to load/store idx +Adding parameter assignment in __stackcall procedure get::i = param(get::i) +Adding parameter assignment in __stackcall procedure print::p = param(print::p) Inlined call call __init Eliminating unused variable with no statement main::$1 Calling convention __stackcall adding prepare/execute/finalize for { main::$1_x, main::$1_y } = call get main::i @@ -635,7 +637,6 @@ __start: { print: { .const OFFSET_STACK_P_X = 1 .const OFFSET_STACK_P_Y = 0 - // } // [5] print::p_x#0 = stackidx(byte,print::OFFSET_STACK_P_X) -- vbuyy=_stackidxbyte_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_P_X,x diff --git a/src/test/ref/procedure-callingconvention-stack-11.asm b/src/test/ref/procedure-callingconvention-stack-11.asm index 6bda13048..9dc25e09a 100644 --- a/src/test/ref/procedure-callingconvention-stack-11.asm +++ b/src/test/ref/procedure-callingconvention-stack-11.asm @@ -29,7 +29,6 @@ print: { .const OFFSET_STACK_V_P2_Y = 0 .label v_p1_y = 4 .label v_p2_x = 5 - // } tsx lda STACK_BASE+OFFSET_STACK_V_P1_X,x tay diff --git a/src/test/ref/procedure-callingconvention-stack-11.log b/src/test/ref/procedure-callingconvention-stack-11.log index 3ba3c67e2..8ecf1d345 100644 --- a/src/test/ref/procedure-callingconvention-stack-11.log +++ b/src/test/ref/procedure-callingconvention-stack-11.log @@ -1,4 +1,6 @@ Converting variable modified inside __stackcall procedure main() to load/store idx +Adding parameter assignment in __stackcall procedure get::i = param(get::i) +Adding parameter assignment in __stackcall procedure print::v = param(print::v) Inlined call call __init Eliminating unused variable with no statement main::$1 Eliminating unused variable with no statement main::$1_p1 @@ -941,7 +943,6 @@ print: { .const OFFSET_STACK_V_P2_Y = 0 .label v_p1_y = 4 .label v_p2_x = 5 - // } // [5] print::v_p1_x#0 = stackidx(byte,print::OFFSET_STACK_V_P1_X) -- vbuyy=_stackidxbyte_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_V_P1_X,x diff --git a/src/test/ref/procedure-callingconvention-stack-12.asm b/src/test/ref/procedure-callingconvention-stack-12.asm index fc4d2e894..18a98cac3 100644 --- a/src/test/ref/procedure-callingconvention-stack-12.asm +++ b/src/test/ref/procedure-callingconvention-stack-12.asm @@ -25,7 +25,6 @@ print: { .const OFFSET_STACK_SPACING = 0 .label str = 2 .label spacing = 5 - // } tsx lda STACK_BASE+OFFSET_STACK_STR,x sta.z str diff --git a/src/test/ref/procedure-callingconvention-stack-12.log b/src/test/ref/procedure-callingconvention-stack-12.log index e7ea3f0f8..dfa1502de 100644 --- a/src/test/ref/procedure-callingconvention-stack-12.log +++ b/src/test/ref/procedure-callingconvention-stack-12.log @@ -1,4 +1,6 @@ Converting variable modified inside __stackcall procedure main() to load/store idx +Adding parameter assignment in __stackcall procedure print::spacing = param(print::spacing) +Adding parameter assignment in __stackcall procedure print::str = param(print::str) Inlined call call __init Calling convention __stackcall adding prepare/execute/finalize for call print main::str 1 Calling convention __stackcall adding prepare/execute/finalize for call print main::str1 2 @@ -556,7 +558,6 @@ print: { .const OFFSET_STACK_SPACING = 0 .label str = 2 .label spacing = 5 - // } // [5] print::str#0 = stackidx(byte*,print::OFFSET_STACK_STR) -- pbuz1=_stackidxptr_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_STR,x diff --git a/src/test/ref/procedure-callingconvention-stack-13.asm b/src/test/ref/procedure-callingconvention-stack-13.asm index 89be9a9ed..a6f1e53ea 100644 --- a/src/test/ref/procedure-callingconvention-stack-13.asm +++ b/src/test/ref/procedure-callingconvention-stack-13.asm @@ -15,7 +15,6 @@ pow2: { .const OFFSET_STACK_N = 0 .const OFFSET_STACK_RETURN = 0 - // } tsx lda STACK_BASE+OFFSET_STACK_N,x // if (n == 0) diff --git a/src/test/ref/procedure-callingconvention-stack-13.log b/src/test/ref/procedure-callingconvention-stack-13.log index ae821584c..16cff40a1 100644 --- a/src/test/ref/procedure-callingconvention-stack-13.log +++ b/src/test/ref/procedure-callingconvention-stack-13.log @@ -1,3 +1,4 @@ +Adding parameter assignment in __stackcall procedure pow2::n = param(pow2::n) Calling convention __stackcall adding prepare/execute/finalize for main::$0 = call pow2 6 Calling convention __stackcall adding prepare/execute/finalize for pow2::$2 = call pow2 pow2::$1 Calling convention STACK_CALL replacing param(pow2::n) with stackidx(byte,pow2::OFFSET_STACK_N) @@ -349,7 +350,6 @@ Score: 72 pow2: { .const OFFSET_STACK_N = 0 .const OFFSET_STACK_RETURN = 0 - // } // [0] pow2::n#0 = stackidx(byte,pow2::OFFSET_STACK_N) -- vbuaa=_stackidxbyte_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_N,x diff --git a/src/test/ref/procedure-callingconvention-stack-2.asm b/src/test/ref/procedure-callingconvention-stack-2.asm index 3ee3fb7d9..0d9e3c2a1 100644 --- a/src/test/ref/procedure-callingconvention-stack-2.asm +++ b/src/test/ref/procedure-callingconvention-stack-2.asm @@ -18,7 +18,6 @@ plus: { .label a = 4 .label b = 2 .label return = 4 - // } tsx lda STACK_BASE+OFFSET_STACK_A,x sta.z a diff --git a/src/test/ref/procedure-callingconvention-stack-2.log b/src/test/ref/procedure-callingconvention-stack-2.log index e20e0b146..15ae684ee 100644 --- a/src/test/ref/procedure-callingconvention-stack-2.log +++ b/src/test/ref/procedure-callingconvention-stack-2.log @@ -1,3 +1,5 @@ +Adding parameter assignment in __stackcall procedure plus::b = param(plus::b) +Adding parameter assignment in __stackcall procedure plus::a = param(plus::a) Calling convention __stackcall adding prepare/execute/finalize for main::$0 = call plus $1234 $2345 Calling convention STACK_CALL replacing param(plus::a) with stackidx(word,plus::OFFSET_STACK_A) Calling convention STACK_CALL replacing param(plus::b) with stackidx(word,plus::OFFSET_STACK_B) @@ -338,7 +340,6 @@ plus: { .label a = 4 .label b = 2 .label return = 4 - // } // [0] plus::a#0 = stackidx(word,plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_A,x diff --git a/src/test/ref/procedure-callingconvention-stack-3.asm b/src/test/ref/procedure-callingconvention-stack-3.asm index c235070fb..a1d1d4799 100644 --- a/src/test/ref/procedure-callingconvention-stack-3.asm +++ b/src/test/ref/procedure-callingconvention-stack-3.asm @@ -21,7 +21,6 @@ plus: { .label a = 4 .label b = 2 .label return = 4 - // } tsx lda STACK_BASE+OFFSET_STACK_A,x sta.z a diff --git a/src/test/ref/procedure-callingconvention-stack-3.log b/src/test/ref/procedure-callingconvention-stack-3.log index 81e652fbf..f7a8edbb5 100644 --- a/src/test/ref/procedure-callingconvention-stack-3.log +++ b/src/test/ref/procedure-callingconvention-stack-3.log @@ -1,3 +1,5 @@ +Adding parameter assignment in __stackcall procedure plus::b = param(plus::b) +Adding parameter assignment in __stackcall procedure plus::a = param(plus::a) Calling convention __stackcall adding prepare/execute/finalize for main::$0 = call plus '0' 7 Calling convention STACK_CALL replacing param(plus::a) with stackidx(word,plus::OFFSET_STACK_A) Calling convention STACK_CALL replacing param(plus::b) with stackidx(word,plus::OFFSET_STACK_B) @@ -340,7 +342,6 @@ plus: { .label a = 4 .label b = 2 .label return = 4 - // } // [0] plus::a#0 = stackidx(word,plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_A,x diff --git a/src/test/ref/procedure-callingconvention-stack-4.asm b/src/test/ref/procedure-callingconvention-stack-4.asm index b8ce17e34..ff637c385 100644 --- a/src/test/ref/procedure-callingconvention-stack-4.asm +++ b/src/test/ref/procedure-callingconvention-stack-4.asm @@ -25,7 +25,6 @@ plus: { .const OFFSET_STACK_B = 0 .const OFFSET_STACK_RETURN = 1 .label a = 4 - // } tsx lda STACK_BASE+OFFSET_STACK_A,x sta.z a diff --git a/src/test/ref/procedure-callingconvention-stack-4.log b/src/test/ref/procedure-callingconvention-stack-4.log index 1bbd75ab0..a60895990 100644 --- a/src/test/ref/procedure-callingconvention-stack-4.log +++ b/src/test/ref/procedure-callingconvention-stack-4.log @@ -1,4 +1,6 @@ Converting variable modified inside __stackcall procedure plus() to load/store i +Adding parameter assignment in __stackcall procedure plus::b = param(plus::b) +Adding parameter assignment in __stackcall procedure plus::a = param(plus::a) Inlined call call __init Calling convention __stackcall adding prepare/execute/finalize for main::$1 = call plus '0' main::v Calling convention STACK_CALL replacing param(plus::a) with stackidx(byte,plus::OFFSET_STACK_A) @@ -517,7 +519,6 @@ plus: { .const OFFSET_STACK_B = 0 .const OFFSET_STACK_RETURN = 1 .label a = 4 - // } // [5] plus::a#0 = stackidx(byte,plus::OFFSET_STACK_A) -- vbuz1=_stackidxbyte_vbuc1 tsx lda STACK_BASE+OFFSET_STACK_A,x