diff --git a/src/main/fragment/mos6502-common/vdum1_lt_vdum2_then_la1.asm b/src/main/fragment/mos6502-common/vdum1_lt_vdum2_then_la1.asm new file mode 100644 index 000000000..8b8a09932 --- /dev/null +++ b/src/main/fragment/mos6502-common/vdum1_lt_vdum2_then_la1.asm @@ -0,0 +1,16 @@ +lda {m1}+3 +cmp {m2}+3 +bcc {la1} +bne !+ +lda {m1}+2 +cmp {m2}+2 +bcc {la1} +bne !+ +lda {m1}+1 +cmp {m2}+1 +bcc {la1} +bne !+ +lda {m1} +cmp {m2} +bcc {la1} +!: diff --git a/src/main/java/dk/camelot64/kickc/asm/AsmChunk.java b/src/main/java/dk/camelot64/kickc/asm/AsmChunk.java index 31cf452c5..d73d71e6e 100644 --- a/src/main/java/dk/camelot64/kickc/asm/AsmChunk.java +++ b/src/main/java/dk/camelot64/kickc/asm/AsmChunk.java @@ -42,11 +42,13 @@ public class AsmChunk { */ private String fragment; - /** If the chunk represents a PHI transition (See. {@link PhiTransitions}) this contains the transition ID. */ - private String phiTransitionId; + /** If the chunk is part of a complex statement this is the sub-ID used for identifying the part of the statement represented. + * For PHI transitions (See. {@link PhiTransitions}) this contains the transition ID. For call prepare this holds the parameter. */ + private String subStatementId; - /** If the chunk is an assignment in a PHI transition this contains the index of the assignment within the transition. */ - private Integer phiTransitionAssignmentIdx; + /** If the chunk is part of a complex statement this is the sub index used for identifying the part of the statement represented. + * For PHI transitions this contains the index of the assignment within the transition. For call prepares this is the index of the parameter. */ + private Integer subStatementIdx; /** The full name of the containing scope (procedure). */ private String scopeLabel; @@ -112,20 +114,20 @@ public class AsmChunk { this.fragment = fragment; } - public String getPhiTransitionId() { - return phiTransitionId; + public String getSubStatementId() { + return subStatementId; } - public void setPhiTransitionId(String phiTransitionId) { - this.phiTransitionId = phiTransitionId; + public void setSubStatementId(String subStatementId) { + this.subStatementId = subStatementId; } - public Integer getPhiTransitionAssignmentIdx() { - return phiTransitionAssignmentIdx; + public Integer getSubStatementIdx() { + return subStatementIdx; } - public void setPhiTransitionAssignmentIdx(Integer phiTransitionAssignmentIdx) { - this.phiTransitionAssignmentIdx = phiTransitionAssignmentIdx; + public void setSubStatementIdx(Integer subStatementIdx) { + this.subStatementIdx = subStatementIdx; } public String getScopeLabel() { @@ -252,10 +254,10 @@ public class AsmChunk { if(source != null) { out.append(" ").append(source.replace('\r', ' ').replace('\n', ' ')); } - if(phiTransitionId != null) { - out.append(" [").append(phiTransitionId); - if(phiTransitionAssignmentIdx != null) { - out.append("#").append(phiTransitionAssignmentIdx); + if(subStatementId != null) { + out.append(" [").append(subStatementId); + if(subStatementIdx != null) { + out.append("#").append(subStatementIdx); } out.append("]"); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4AssertNoCpuClobber.java b/src/main/java/dk/camelot64/kickc/passes/Pass4AssertNoCpuClobber.java index 38a343c5d..b9470e4ab 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4AssertNoCpuClobber.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4AssertNoCpuClobber.java @@ -5,6 +5,8 @@ import dk.camelot64.kickc.asm.AsmClobber; import dk.camelot64.kickc.asm.AsmProgram; import dk.camelot64.kickc.model.*; import dk.camelot64.kickc.model.statements.Statement; +import dk.camelot64.kickc.model.statements.StatementCallPrepare; +import dk.camelot64.kickc.model.statements.StatementPhiBlock; import dk.camelot64.kickc.model.symbols.Variable; import dk.camelot64.kickc.model.values.LabelRef; import dk.camelot64.kickc.model.values.RValue; @@ -73,10 +75,11 @@ public class Pass4AssertNoCpuClobber extends Pass2Base { // Find alive variables List aliveVars = new ArrayList<>(getProgram().getLiveRangeVariablesEffective().getAliveEffective(statement)); + // If the chunk is an assignment in a phi transition, examine the later phi transition assignments and update alive variables alive and variables assigned - if(asmChunk.getPhiTransitionId() != null && asmChunk.getPhiTransitionAssignmentIdx() != null) { - String phiTransitionId = asmChunk.getPhiTransitionId(); - int transitionAssignmentIdx = asmChunk.getPhiTransitionAssignmentIdx(); + if(statement instanceof StatementPhiBlock && asmChunk.getSubStatementId() != null && asmChunk.getSubStatementIdx() != null) { + String phiTransitionId = asmChunk.getSubStatementId(); + int transitionAssignmentIdx = asmChunk.getSubStatementIdx(); ControlFlowBlock statementBlock = getProgram().getStatementInfos().getBlock(statementIdx); Map programPhiTransitions = getProgram().getPhiTransitions(); PhiTransitions phiTransitions = programPhiTransitions.get(statementBlock.getLabel()); @@ -98,6 +101,21 @@ public class Pass4AssertNoCpuClobber extends Pass2Base { } } + // If the chunk is an call parameter prepare, examine the later call parameter prepares and update alive variables + if(statement instanceof StatementCallPrepare && asmChunk.getSubStatementId() != null && asmChunk.getSubStatementIdx() != null) { + int transitionAssignmentIdx = asmChunk.getSubStatementIdx(); + final StatementCallPrepare callPrepare = (StatementCallPrepare) statement; + final int numParameters = callPrepare.getNumParameters(); + for(int idx = 0; idx < numParameters; idx++) { + final RValue parameter = callPrepare.getParameter(idx); + if(idx > transitionAssignmentIdx) { + // If the parameter prepare is later than the current one + Collection alive = VariableReferenceInfos.getReferencedVars(parameter); + aliveVars.addAll(alive); + } + } + } + // Non-assigned alive variables must not be clobbered for(VariableRef aliveVar : aliveVars) { Variable variable = getProgram().getSymbolInfos().getVariable(aliveVar); @@ -115,7 +133,7 @@ public class Pass4AssertNoCpuClobber extends Pass2Base { if(verbose) { throw new CompileError( "Error! Generated ASM has register clobber problem. " + - "Alive variable "+aliveVar + " register " + aliveVarRegister + " clobbered by the ASM generated by statement "+statement.toString(getProgram(), true), + "Alive variable " + aliveVar + " register " + aliveVarRegister + " clobbered by the ASM generated by statement " + statement.toString(getProgram(), true), statement.getSource() ); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java index de91c502b..2dea37fb3 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java @@ -280,7 +280,7 @@ public class Pass4CodeGeneration { signature.append("zp(").append(AsmFormat.getAsmNumber(registerZp.getZp())).append(")"); } else if(allocation instanceof Registers.RegisterMainMem) { Registers.RegisterMainMem registerMainMem = (Registers.RegisterMainMem) allocation; - signature.append("mem(").append(registerMainMem.getAddress()==null?"":AsmFormat.getAsmNumber(registerMainMem.getAddress())).append(")"); + signature.append("mem(").append(registerMainMem.getAddress() == null ? "" : AsmFormat.getAsmNumber(registerMainMem.getAddress())).append(")"); } else if(allocation instanceof Registers.RegisterAByte) { signature.append("register(A)"); } else if(allocation instanceof Registers.RegisterXByte) { @@ -850,26 +850,29 @@ public class Pass4CodeGeneration { List callParameters = call.getParameters(); List procParameters = procedure.getParameters(); for(int i = 0; i < procParameters.size(); i++) { + if(i > 0) + asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo)); Variable procParameter = procParameters.get(i); RValue callParameter = callParameters.get(i); SymbolType parameterType = procParameter.getType(); AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(new StackPushValue(parameterType), callParameter, program, block.getScope()); - asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo)); ensureEncoding(asm, asmFragmentInstanceSpecFactory); generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec()); + asm.getCurrentChunk().setSubStatementIdx(i); + asm.getCurrentChunk().setSubStatementId(procParameter.toString(program)); } // Push additional bytes if needed long stackFrameByteSize = CallingConventionStack.getStackFrameByteSize(procedure); long parametersByteSize = CallingConventionStack.getParametersByteSize(procedure); if(stackFrameByteSize > parametersByteSize) { + if(procParameters.size() > 0) + asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo)); // Add padding to the stack to make room for the return value String pushSignature = "_stackpushbyte_" + (stackFrameByteSize - parametersByteSize); AsmFragmentInstanceSpec pushFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, pushSignature, new LinkedHashMap<>(), block.getScope()); - asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo)); generateAsm(asm, pushFragmentInstanceSpec); } - asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo)); } } else if(statement instanceof StatementCallExecute) { StatementCallExecute call = (StatementCallExecute) statement; @@ -882,26 +885,24 @@ public class Pass4CodeGeneration { StatementCallFinalize call = (StatementCallFinalize) statement; Procedure procedure = getScope().getProcedure(call.getProcedure()); if(Procedure.CallingConvention.STACK_CALL.equals(procedure.getCallingConvention())) { - long stackFrameByteSize = CallingConventionStack.getStackFrameByteSize(procedure); long returnByteSize = procedure.getReturnType() == null ? 0 : procedure.getReturnType().getSizeBytes(); - if(stackFrameByteSize > returnByteSize) { + long stackCleanBytes = (call.getlValue() == null) ? stackFrameByteSize : (stackFrameByteSize - returnByteSize); + if(stackCleanBytes > 0) { // Clean up the stack - String pullSignature = "_stackpullbyte_" + (stackFrameByteSize - returnByteSize); + String pullSignature = "_stackpullbyte_" + stackCleanBytes; AsmFragmentInstanceSpec pullFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, pullSignature, new LinkedHashMap<>(), block.getScope()); - asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo)); generateAsm(asm, pullFragmentInstanceSpec); } - // Pull result from the stack if(call.getlValue() != null) { + if(stackCleanBytes>0) + asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo)); SymbolType returnType = procedure.getReturnType(); AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(call.getlValue(), new StackPullValue(returnType), program, block.getScope()); - asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo)); ensureEncoding(asm, asmFragmentInstanceSpecFactory); generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec()); } - } } else if(statement instanceof StatementReturn) { Procedure procedure = null; @@ -1173,7 +1174,7 @@ public class Pass4CodeGeneration { } chunkSrc += "to " + toBlock.getLabel().getFullName(); asm.startChunk(scope, toFirstStatement.getIndex(), chunkSrc); - asm.getCurrentChunk().setPhiTransitionId(transition.getTransitionId()); + asm.getCurrentChunk().setSubStatementId(transition.getTransitionId()); for(ControlFlowBlock fBlock : transition.getFromBlocks()) { asm.addLabel(AsmFormat.asmFix(toBlock.getLabel().getLocalName() + "_from_" + fBlock.getLabel().getLocalName())); } @@ -1184,8 +1185,8 @@ public class Pass4CodeGeneration { Statement statement = assignment.getPhiBlock(); // Generate an ASM move fragment asm.startChunk(scope, statement.getIndex(), "[" + statement.getIndex() + "] phi " + lValue.toString(program) + " = " + rValue.toString(program)); - asm.getCurrentChunk().setPhiTransitionId(transition.getTransitionId()); - asm.getCurrentChunk().setPhiTransitionAssignmentIdx(assignment.getAssignmentIdx()); + asm.getCurrentChunk().setSubStatementId(transition.getTransitionId()); + asm.getCurrentChunk().setSubStatementIdx(assignment.getAssignmentIdx()); if(isRegisterCopy(lValue, rValue)) { asm.getCurrentChunk().setFragment("register_copy"); } else { diff --git a/src/test/ref/procedure-callingconvention-stack-0.log b/src/test/ref/procedure-callingconvention-stack-0.log index e9ce5d9db..ac3d5e833 100644 --- a/src/test/ref/procedure-callingconvention-stack-0.log +++ b/src/test/ref/procedure-callingconvention-stack-0.log @@ -177,17 +177,14 @@ __bend: // main main: { .label __0 = 2 - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::b#1] -- _stackpushbyte_=vbuc1 lda #7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (byte~) main::$0 ← callfinalize plus // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_ @@ -296,17 +293,14 @@ __bend_from___b1: __bend: // main main: { - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::b#1] -- _stackpushbyte_=vbuc1 lda #7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (byte~) main::$0 ← callfinalize plus // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_ @@ -418,17 +412,14 @@ Score: 67 // main main: { // plus('0', 7) - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::b#1] -- _stackpushbyte_=vbuc1 lda #7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (byte~) main::$0 ← callfinalize plus // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_ diff --git a/src/test/ref/procedure-callingconvention-stack-1.log b/src/test/ref/procedure-callingconvention-stack-1.log index e9ce5d9db..ac3d5e833 100644 --- a/src/test/ref/procedure-callingconvention-stack-1.log +++ b/src/test/ref/procedure-callingconvention-stack-1.log @@ -177,17 +177,14 @@ __bend: // main main: { .label __0 = 2 - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::b#1] -- _stackpushbyte_=vbuc1 lda #7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (byte~) main::$0 ← callfinalize plus // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_ @@ -296,17 +293,14 @@ __bend_from___b1: __bend: // main main: { - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::b#1] -- _stackpushbyte_=vbuc1 lda #7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (byte~) main::$0 ← callfinalize plus // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_ @@ -418,17 +412,14 @@ Score: 67 // main main: { // plus('0', 7) - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::b#1] -- _stackpushbyte_=vbuc1 lda #7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (byte~) main::$0 ← callfinalize plus // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 pla // [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_ diff --git a/src/test/ref/procedure-callingconvention-stack-2.log b/src/test/ref/procedure-callingconvention-stack-2.log index ae87a0b51..e566d81a9 100644 --- a/src/test/ref/procedure-callingconvention-stack-2.log +++ b/src/test/ref/procedure-callingconvention-stack-2.log @@ -195,21 +195,18 @@ __bend: // main main: { .label __0 = 2 - // [5] callprepare plus (word) $1234 (word) $2345 - // [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1 + // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::a#0] -- _stackpushword_=vwuc1 lda #>$1234 pha lda #<$1234 pha - // [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1 + // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::b#1] -- _stackpushword_=vwuc1 lda #>$2345 pha lda #<$2345 pha - // [5] callprepare plus (word) $1234 (word) $2345 // [6] callexecute plus -- jsr jsr plus - // [7] (word~) main::$0 ← callfinalize plus // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 pla pla @@ -327,21 +324,18 @@ __bend: // main main: { .label __0 = 2 - // [5] callprepare plus (word) $1234 (word) $2345 - // [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1 + // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::a#0] -- _stackpushword_=vwuc1 lda #>$1234 pha lda #<$1234 pha - // [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1 + // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::b#1] -- _stackpushword_=vwuc1 lda #>$2345 pha lda #<$2345 pha - // [5] callprepare plus (word) $1234 (word) $2345 // [6] callexecute plus -- jsr jsr plus - // [7] (word~) main::$0 ← callfinalize plus // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 pla pla @@ -474,21 +468,18 @@ Score: 146 main: { .label __0 = 2 // plus(0x1234, 0x2345) - // [5] callprepare plus (word) $1234 (word) $2345 - // [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1 + // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::a#0] -- _stackpushword_=vwuc1 lda #>$1234 pha lda #<$1234 pha - // [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1 + // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::b#1] -- _stackpushword_=vwuc1 lda #>$2345 pha lda #<$2345 pha - // [5] callprepare plus (word) $1234 (word) $2345 // [6] callexecute plus -- jsr jsr plus - // [7] (word~) main::$0 ← callfinalize plus // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 pla pla diff --git a/src/test/ref/procedure-callingconvention-stack-3.log b/src/test/ref/procedure-callingconvention-stack-3.log index c91422f66..9d08be1a5 100644 --- a/src/test/ref/procedure-callingconvention-stack-3.log +++ b/src/test/ref/procedure-callingconvention-stack-3.log @@ -195,21 +195,18 @@ __bend: // main main: { .label __0 = 2 - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::a#0] -- _stackpushword_=vbuc1 lda #0 pha lda #<'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::b#1] -- _stackpushword_=vbuc1 lda #0 pha lda #<7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (word~) main::$0 ← callfinalize plus // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 pla pla @@ -330,21 +327,18 @@ __bend: // main main: { .label __0 = 2 - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::a#0] -- _stackpushword_=vbuc1 lda #0 pha lda #<'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::b#1] -- _stackpushword_=vbuc1 lda #0 pha lda #<7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (word~) main::$0 ← callfinalize plus // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 pla pla @@ -480,21 +474,18 @@ Score: 146 main: { .label __0 = 2 // plus('0', 7) - // [5] callprepare plus (byte) '0' (byte) 7 - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::a#0] -- _stackpushword_=vbuc1 lda #0 pha lda #<'0' pha - // [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1 + // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::b#1] -- _stackpushword_=vbuc1 lda #0 pha lda #<7 pha - // [5] callprepare plus (byte) '0' (byte) 7 // [6] callexecute plus -- jsr jsr plus - // [7] (word~) main::$0 ← callfinalize plus // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 pla pla diff --git a/src/test/ref/procedure-callingconvention-stack-4.log b/src/test/ref/procedure-callingconvention-stack-4.log index e78c1f3fc..5e414c40e 100644 --- a/src/test/ref/procedure-callingconvention-stack-4.log +++ b/src/test/ref/procedure-callingconvention-stack-4.log @@ -298,17 +298,14 @@ main: { ldy.z a iny sty.z v - // [7] callprepare plus (byte) '0' (byte) main::v#0 - // [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuc1 + // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuz1 + // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::b#1] -- _stackpushbyte_=vbuz1 lda.z v pha - // [7] callprepare plus (byte) '0' (byte) main::v#0 // [8] callexecute plus -- jsr jsr plus - // [9] (byte) main::w#0 ← callfinalize plus // [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1 pla // [9] (byte) main::w#0 ← callfinalize plus -- vbuz1=_stackpullbyte_ @@ -452,17 +449,14 @@ main: { tya tax inx - // [7] callprepare plus (byte) '0' (byte) main::v#0 - // [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuc1 + // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuxx + // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::b#1] -- _stackpushbyte_=vbuxx txa pha - // [7] callprepare plus (byte) '0' (byte) main::v#0 // [8] callexecute plus -- jsr jsr plus - // [9] (byte) main::w#0 ← callfinalize plus // [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1 pla // [9] (byte) main::w#0 ← callfinalize plus -- vbuaa=_stackpullbyte_ @@ -614,17 +608,14 @@ main: { tax inx // w = plus('0', v) - // [7] callprepare plus (byte) '0' (byte) main::v#0 - // [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuc1 + // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1 lda #'0' pha - // [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuxx + // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::b#1] -- _stackpushbyte_=vbuxx txa pha - // [7] callprepare plus (byte) '0' (byte) main::v#0 // [8] callexecute plus -- jsr jsr plus - // [9] (byte) main::w#0 ← callfinalize plus // [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1 pla // [9] (byte) main::w#0 ← callfinalize plus -- vbuaa=_stackpullbyte_ diff --git a/src/test/ref/procedure-callingconvention-stack-5.log b/src/test/ref/procedure-callingconvention-stack-5.log index ccffe5550..7cab745e3 100644 --- a/src/test/ref/procedure-callingconvention-stack-5.log +++ b/src/test/ref/procedure-callingconvention-stack-5.log @@ -234,14 +234,11 @@ __bend: main: { .label __0 = 4 .label __1 = 6 - // [5] callprepare next // [5] callprepare next -- _stackpushbyte_2 pha pha - // [5] callprepare next // [6] callexecute next -- jsr jsr next - // [7] (signed word~) main::$0 ← callfinalize next // [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_ pla sta.z __0 @@ -252,14 +249,11 @@ main: { sta SCREEN lda.z __0+1 sta SCREEN+1 - // [9] callprepare next // [9] callprepare next -- _stackpushbyte_2 pha pha - // [9] callprepare next // [10] callexecute next -- jsr jsr next - // [11] (signed word~) main::$1 ← callfinalize next // [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_ pla sta.z __1 @@ -357,14 +351,11 @@ __bend: main: { .label __0 = 2 .label __1 = 4 - // [5] callprepare next // [5] callprepare next -- _stackpushbyte_2 pha pha - // [5] callprepare next // [6] callexecute next -- jsr jsr next - // [7] (signed word~) main::$0 ← callfinalize next // [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_ pla sta.z __0 @@ -375,14 +366,11 @@ main: { sta SCREEN lda.z __0+1 sta SCREEN+1 - // [9] callprepare next // [9] callprepare next -- _stackpushbyte_2 pha pha - // [9] callprepare next // [10] callexecute next -- jsr jsr next - // [11] (signed word~) main::$1 ← callfinalize next // [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_ pla sta.z __1 @@ -490,14 +478,11 @@ main: { .label __0 = 2 .label __1 = 4 // next() - // [5] callprepare next // [5] callprepare next -- _stackpushbyte_2 pha pha - // [5] callprepare next // [6] callexecute next -- jsr jsr next - // [7] (signed word~) main::$0 ← callfinalize next // [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_ pla sta.z __0 @@ -510,14 +495,11 @@ main: { lda.z __0+1 sta SCREEN+1 // next() - // [9] callprepare next // [9] callprepare next -- _stackpushbyte_2 pha pha - // [9] callprepare next // [10] callexecute next -- jsr jsr next - // [11] (signed word~) main::$1 ← callfinalize next // [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_ pla sta.z __1