1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-26 18:29:54 +00:00

Added proper clobber check to call prepare sub-statements. Fixed stack clean-up after stack call return.

This commit is contained in:
jespergravgaard 2020-03-01 16:00:42 +01:00
parent 4346790c43
commit 648d08a13d
10 changed files with 101 additions and 127 deletions

View File

@ -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}
!:

View File

@ -42,11 +42,13 @@ public class AsmChunk {
*/ */
private String fragment; private String fragment;
/** If the chunk represents a PHI transition (See. {@link PhiTransitions}) this contains the transition ID. */ /** If the chunk is part of a complex statement this is the sub-ID used for identifying the part of the statement represented.
private String phiTransitionId; * 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. */ /** If the chunk is part of a complex statement this is the sub index used for identifying the part of the statement represented.
private Integer phiTransitionAssignmentIdx; * 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). */ /** The full name of the containing scope (procedure). */
private String scopeLabel; private String scopeLabel;
@ -112,20 +114,20 @@ public class AsmChunk {
this.fragment = fragment; this.fragment = fragment;
} }
public String getPhiTransitionId() { public String getSubStatementId() {
return phiTransitionId; return subStatementId;
} }
public void setPhiTransitionId(String phiTransitionId) { public void setSubStatementId(String subStatementId) {
this.phiTransitionId = phiTransitionId; this.subStatementId = subStatementId;
} }
public Integer getPhiTransitionAssignmentIdx() { public Integer getSubStatementIdx() {
return phiTransitionAssignmentIdx; return subStatementIdx;
} }
public void setPhiTransitionAssignmentIdx(Integer phiTransitionAssignmentIdx) { public void setSubStatementIdx(Integer subStatementIdx) {
this.phiTransitionAssignmentIdx = phiTransitionAssignmentIdx; this.subStatementIdx = subStatementIdx;
} }
public String getScopeLabel() { public String getScopeLabel() {
@ -252,10 +254,10 @@ public class AsmChunk {
if(source != null) { if(source != null) {
out.append(" ").append(source.replace('\r', ' ').replace('\n', ' ')); out.append(" ").append(source.replace('\r', ' ').replace('\n', ' '));
} }
if(phiTransitionId != null) { if(subStatementId != null) {
out.append(" [").append(phiTransitionId); out.append(" [").append(subStatementId);
if(phiTransitionAssignmentIdx != null) { if(subStatementIdx != null) {
out.append("#").append(phiTransitionAssignmentIdx); out.append("#").append(subStatementIdx);
} }
out.append("]"); out.append("]");
} }

View File

@ -5,6 +5,8 @@ import dk.camelot64.kickc.asm.AsmClobber;
import dk.camelot64.kickc.asm.AsmProgram; import dk.camelot64.kickc.asm.AsmProgram;
import dk.camelot64.kickc.model.*; import dk.camelot64.kickc.model.*;
import dk.camelot64.kickc.model.statements.Statement; 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.symbols.Variable;
import dk.camelot64.kickc.model.values.LabelRef; import dk.camelot64.kickc.model.values.LabelRef;
import dk.camelot64.kickc.model.values.RValue; import dk.camelot64.kickc.model.values.RValue;
@ -73,10 +75,11 @@ public class Pass4AssertNoCpuClobber extends Pass2Base {
// Find alive variables // Find alive variables
List<VariableRef> aliveVars = new ArrayList<>(getProgram().getLiveRangeVariablesEffective().getAliveEffective(statement)); List<VariableRef> 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 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) { if(statement instanceof StatementPhiBlock && asmChunk.getSubStatementId() != null && asmChunk.getSubStatementIdx() != null) {
String phiTransitionId = asmChunk.getPhiTransitionId(); String phiTransitionId = asmChunk.getSubStatementId();
int transitionAssignmentIdx = asmChunk.getPhiTransitionAssignmentIdx(); int transitionAssignmentIdx = asmChunk.getSubStatementIdx();
ControlFlowBlock statementBlock = getProgram().getStatementInfos().getBlock(statementIdx); ControlFlowBlock statementBlock = getProgram().getStatementInfos().getBlock(statementIdx);
Map<LabelRef, PhiTransitions> programPhiTransitions = getProgram().getPhiTransitions(); Map<LabelRef, PhiTransitions> programPhiTransitions = getProgram().getPhiTransitions();
PhiTransitions phiTransitions = programPhiTransitions.get(statementBlock.getLabel()); 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<VariableRef> alive = VariableReferenceInfos.getReferencedVars(parameter);
aliveVars.addAll(alive);
}
}
}
// Non-assigned alive variables must not be clobbered // Non-assigned alive variables must not be clobbered
for(VariableRef aliveVar : aliveVars) { for(VariableRef aliveVar : aliveVars) {
Variable variable = getProgram().getSymbolInfos().getVariable(aliveVar); Variable variable = getProgram().getSymbolInfos().getVariable(aliveVar);
@ -115,7 +133,7 @@ public class Pass4AssertNoCpuClobber extends Pass2Base {
if(verbose) { if(verbose) {
throw new CompileError( throw new CompileError(
"Error! Generated ASM has register clobber problem. " + "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() statement.getSource()
); );
} }

View File

@ -280,7 +280,7 @@ public class Pass4CodeGeneration {
signature.append("zp(").append(AsmFormat.getAsmNumber(registerZp.getZp())).append(")"); signature.append("zp(").append(AsmFormat.getAsmNumber(registerZp.getZp())).append(")");
} else if(allocation instanceof Registers.RegisterMainMem) { } else if(allocation instanceof Registers.RegisterMainMem) {
Registers.RegisterMainMem registerMainMem = (Registers.RegisterMainMem) allocation; 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) { } else if(allocation instanceof Registers.RegisterAByte) {
signature.append("register(A)"); signature.append("register(A)");
} else if(allocation instanceof Registers.RegisterXByte) { } else if(allocation instanceof Registers.RegisterXByte) {
@ -850,26 +850,29 @@ public class Pass4CodeGeneration {
List<RValue> callParameters = call.getParameters(); List<RValue> callParameters = call.getParameters();
List<Variable> procParameters = procedure.getParameters(); List<Variable> procParameters = procedure.getParameters();
for(int i = 0; i < procParameters.size(); i++) { 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); Variable procParameter = procParameters.get(i);
RValue callParameter = callParameters.get(i); RValue callParameter = callParameters.get(i);
SymbolType parameterType = procParameter.getType(); SymbolType parameterType = procParameter.getType();
AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(new StackPushValue(parameterType), callParameter, program, block.getScope()); AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(new StackPushValue(parameterType), callParameter, program, block.getScope());
asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo));
ensureEncoding(asm, asmFragmentInstanceSpecFactory); ensureEncoding(asm, asmFragmentInstanceSpecFactory);
generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec()); generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec());
asm.getCurrentChunk().setSubStatementIdx(i);
asm.getCurrentChunk().setSubStatementId(procParameter.toString(program));
} }
// Push additional bytes if needed // Push additional bytes if needed
long stackFrameByteSize = CallingConventionStack.getStackFrameByteSize(procedure); long stackFrameByteSize = CallingConventionStack.getStackFrameByteSize(procedure);
long parametersByteSize = CallingConventionStack.getParametersByteSize(procedure); long parametersByteSize = CallingConventionStack.getParametersByteSize(procedure);
if(stackFrameByteSize > parametersByteSize) { 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 // Add padding to the stack to make room for the return value
String pushSignature = "_stackpushbyte_" + (stackFrameByteSize - parametersByteSize); String pushSignature = "_stackpushbyte_" + (stackFrameByteSize - parametersByteSize);
AsmFragmentInstanceSpec pushFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, pushSignature, new LinkedHashMap<>(), block.getScope()); AsmFragmentInstanceSpec pushFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, pushSignature, new LinkedHashMap<>(), block.getScope());
asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo));
generateAsm(asm, pushFragmentInstanceSpec); generateAsm(asm, pushFragmentInstanceSpec);
} }
asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo));
} }
} else if(statement instanceof StatementCallExecute) { } else if(statement instanceof StatementCallExecute) {
StatementCallExecute call = (StatementCallExecute) statement; StatementCallExecute call = (StatementCallExecute) statement;
@ -882,26 +885,24 @@ public class Pass4CodeGeneration {
StatementCallFinalize call = (StatementCallFinalize) statement; StatementCallFinalize call = (StatementCallFinalize) statement;
Procedure procedure = getScope().getProcedure(call.getProcedure()); Procedure procedure = getScope().getProcedure(call.getProcedure());
if(Procedure.CallingConvention.STACK_CALL.equals(procedure.getCallingConvention())) { if(Procedure.CallingConvention.STACK_CALL.equals(procedure.getCallingConvention())) {
long stackFrameByteSize = CallingConventionStack.getStackFrameByteSize(procedure); long stackFrameByteSize = CallingConventionStack.getStackFrameByteSize(procedure);
long returnByteSize = procedure.getReturnType() == null ? 0 : procedure.getReturnType().getSizeBytes(); 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 // Clean up the stack
String pullSignature = "_stackpullbyte_" + (stackFrameByteSize - returnByteSize); String pullSignature = "_stackpullbyte_" + stackCleanBytes;
AsmFragmentInstanceSpec pullFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, pullSignature, new LinkedHashMap<>(), block.getScope()); AsmFragmentInstanceSpec pullFragmentInstanceSpec = new AsmFragmentInstanceSpec(program, pullSignature, new LinkedHashMap<>(), block.getScope());
asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo));
generateAsm(asm, pullFragmentInstanceSpec); generateAsm(asm, pullFragmentInstanceSpec);
} }
// Pull result from the stack // Pull result from the stack
if(call.getlValue() != null) { if(call.getlValue() != null) {
if(stackCleanBytes>0)
asm.startChunk(block.getScope(), statement.getIndex(), statement.toString(program, verboseAliveInfo));
SymbolType returnType = procedure.getReturnType(); SymbolType returnType = procedure.getReturnType();
AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory = new AsmFragmentInstanceSpecFactory(call.getlValue(), new StackPullValue(returnType), program, block.getScope()); 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); ensureEncoding(asm, asmFragmentInstanceSpecFactory);
generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec()); generateAsm(asm, asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec());
} }
} }
} else if(statement instanceof StatementReturn) { } else if(statement instanceof StatementReturn) {
Procedure procedure = null; Procedure procedure = null;
@ -1173,7 +1174,7 @@ public class Pass4CodeGeneration {
} }
chunkSrc += "to " + toBlock.getLabel().getFullName(); chunkSrc += "to " + toBlock.getLabel().getFullName();
asm.startChunk(scope, toFirstStatement.getIndex(), chunkSrc); asm.startChunk(scope, toFirstStatement.getIndex(), chunkSrc);
asm.getCurrentChunk().setPhiTransitionId(transition.getTransitionId()); asm.getCurrentChunk().setSubStatementId(transition.getTransitionId());
for(ControlFlowBlock fBlock : transition.getFromBlocks()) { for(ControlFlowBlock fBlock : transition.getFromBlocks()) {
asm.addLabel(AsmFormat.asmFix(toBlock.getLabel().getLocalName() + "_from_" + fBlock.getLabel().getLocalName())); asm.addLabel(AsmFormat.asmFix(toBlock.getLabel().getLocalName() + "_from_" + fBlock.getLabel().getLocalName()));
} }
@ -1184,8 +1185,8 @@ public class Pass4CodeGeneration {
Statement statement = assignment.getPhiBlock(); Statement statement = assignment.getPhiBlock();
// Generate an ASM move fragment // Generate an ASM move fragment
asm.startChunk(scope, statement.getIndex(), "[" + statement.getIndex() + "] phi " + lValue.toString(program) + " = " + rValue.toString(program)); asm.startChunk(scope, statement.getIndex(), "[" + statement.getIndex() + "] phi " + lValue.toString(program) + " = " + rValue.toString(program));
asm.getCurrentChunk().setPhiTransitionId(transition.getTransitionId()); asm.getCurrentChunk().setSubStatementId(transition.getTransitionId());
asm.getCurrentChunk().setPhiTransitionAssignmentIdx(assignment.getAssignmentIdx()); asm.getCurrentChunk().setSubStatementIdx(assignment.getAssignmentIdx());
if(isRegisterCopy(lValue, rValue)) { if(isRegisterCopy(lValue, rValue)) {
asm.getCurrentChunk().setFragment("register_copy"); asm.getCurrentChunk().setFragment("register_copy");
} else { } else {

View File

@ -177,17 +177,14 @@ __bend:
// main // main
main: { main: {
.label __0 = 2 .label __0 = 2
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 lda #7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (byte~) main::$0 ← callfinalize plus
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_ // [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_
@ -296,17 +293,14 @@ __bend_from___b1:
__bend: __bend:
// main // main
main: { main: {
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 lda #7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (byte~) main::$0 ← callfinalize plus
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_ // [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_
@ -418,17 +412,14 @@ Score: 67
// main // main
main: { main: {
// plus('0', 7) // plus('0', 7)
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 lda #7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (byte~) main::$0 ← callfinalize plus
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_ // [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_

View File

@ -177,17 +177,14 @@ __bend:
// main // main
main: { main: {
.label __0 = 2 .label __0 = 2
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 lda #7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (byte~) main::$0 ← callfinalize plus
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_ // [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_
@ -296,17 +293,14 @@ __bend_from___b1:
__bend: __bend:
// main // main
main: { main: {
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 lda #7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (byte~) main::$0 ← callfinalize plus
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_ // [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_
@ -418,17 +412,14 @@ Score: 67
// main // main
main: { main: {
// plus('0', 7) // plus('0', 7)
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 lda #7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (byte~) main::$0 ← callfinalize plus
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1 // [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_ // [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_

View File

@ -195,21 +195,18 @@ __bend:
// main // main
main: { main: {
.label __0 = 2 .label __0 = 2
// [5] callprepare plus (word) $1234 (word) $2345 // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::a#0] -- _stackpushword_=vwuc1
// [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1
lda #>$1234 lda #>$1234
pha pha
lda #<$1234 lda #<$1234
pha 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 lda #>$2345
pha pha
lda #<$2345 lda #<$2345
pha pha
// [5] callprepare plus (word) $1234 (word) $2345
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (word~) main::$0 ← callfinalize plus
// [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2
pla pla
pla pla
@ -327,21 +324,18 @@ __bend:
// main // main
main: { main: {
.label __0 = 2 .label __0 = 2
// [5] callprepare plus (word) $1234 (word) $2345 // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::a#0] -- _stackpushword_=vwuc1
// [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1
lda #>$1234 lda #>$1234
pha pha
lda #<$1234 lda #<$1234
pha 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 lda #>$2345
pha pha
lda #<$2345 lda #<$2345
pha pha
// [5] callprepare plus (word) $1234 (word) $2345
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (word~) main::$0 ← callfinalize plus
// [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2
pla pla
pla pla
@ -474,21 +468,18 @@ Score: 146
main: { main: {
.label __0 = 2 .label __0 = 2
// plus(0x1234, 0x2345) // plus(0x1234, 0x2345)
// [5] callprepare plus (word) $1234 (word) $2345 // [5] callprepare plus (word) $1234 (word) $2345 [(word) plus::a#0] -- _stackpushword_=vwuc1
// [5] callprepare plus (word) $1234 (word) $2345 -- _stackpushword_=vwuc1
lda #>$1234 lda #>$1234
pha pha
lda #<$1234 lda #<$1234
pha 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 lda #>$2345
pha pha
lda #<$2345 lda #<$2345
pha pha
// [5] callprepare plus (word) $1234 (word) $2345
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (word~) main::$0 ← callfinalize plus
// [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2
pla pla
pla pla

View File

@ -195,21 +195,18 @@ __bend:
// main // main
main: { main: {
.label __0 = 2 .label __0 = 2
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::a#0] -- _stackpushword_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1
lda #0 lda #0
pha pha
lda #<'0' lda #<'0'
pha 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 lda #0
pha pha
lda #<7 lda #<7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (word~) main::$0 ← callfinalize plus
// [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2
pla pla
pla pla
@ -330,21 +327,18 @@ __bend:
// main // main
main: { main: {
.label __0 = 2 .label __0 = 2
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::a#0] -- _stackpushword_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1
lda #0 lda #0
pha pha
lda #<'0' lda #<'0'
pha 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 lda #0
pha pha
lda #<7 lda #<7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (word~) main::$0 ← callfinalize plus
// [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2
pla pla
pla pla
@ -480,21 +474,18 @@ Score: 146
main: { main: {
.label __0 = 2 .label __0 = 2
// plus('0', 7) // plus('0', 7)
// [5] callprepare plus (byte) '0' (byte) 7 // [5] callprepare plus (byte) '0' (byte) 7 [(word) plus::a#0] -- _stackpushword_=vbuc1
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushword_=vbuc1
lda #0 lda #0
pha pha
lda #<'0' lda #<'0'
pha 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 lda #0
pha pha
lda #<7 lda #<7
pha pha
// [5] callprepare plus (byte) '0' (byte) 7
// [6] callexecute plus -- jsr // [6] callexecute plus -- jsr
jsr plus jsr plus
// [7] (word~) main::$0 ← callfinalize plus
// [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2 // [7] (word~) main::$0 ← callfinalize plus -- _stackpullbyte_2
pla pla
pla pla

View File

@ -298,17 +298,14 @@ main: {
ldy.z a ldy.z a
iny iny
sty.z v sty.z v
// [7] callprepare plus (byte) '0' (byte) main::v#0 // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 lda.z v
pha pha
// [7] callprepare plus (byte) '0' (byte) main::v#0
// [8] callexecute plus -- jsr // [8] callexecute plus -- jsr
jsr plus jsr plus
// [9] (byte) main::w#0 ← callfinalize plus
// [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1 // [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [9] (byte) main::w#0 ← callfinalize plus -- vbuz1=_stackpullbyte_ // [9] (byte) main::w#0 ← callfinalize plus -- vbuz1=_stackpullbyte_
@ -452,17 +449,14 @@ main: {
tya tya
tax tax
inx inx
// [7] callprepare plus (byte) '0' (byte) main::v#0 // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 txa
pha pha
// [7] callprepare plus (byte) '0' (byte) main::v#0
// [8] callexecute plus -- jsr // [8] callexecute plus -- jsr
jsr plus jsr plus
// [9] (byte) main::w#0 ← callfinalize plus
// [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1 // [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [9] (byte) main::w#0 ← callfinalize plus -- vbuaa=_stackpullbyte_ // [9] (byte) main::w#0 ← callfinalize plus -- vbuaa=_stackpullbyte_
@ -614,17 +608,14 @@ main: {
tax tax
inx inx
// w = plus('0', v) // w = plus('0', v)
// [7] callprepare plus (byte) '0' (byte) main::v#0 // [7] callprepare plus (byte) '0' (byte) main::v#0 [(byte) plus::a#0] -- _stackpushbyte_=vbuc1
// [7] callprepare plus (byte) '0' (byte) main::v#0 -- _stackpushbyte_=vbuc1
lda #'0' lda #'0'
pha 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 txa
pha pha
// [7] callprepare plus (byte) '0' (byte) main::v#0
// [8] callexecute plus -- jsr // [8] callexecute plus -- jsr
jsr plus jsr plus
// [9] (byte) main::w#0 ← callfinalize plus
// [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1 // [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1
pla pla
// [9] (byte) main::w#0 ← callfinalize plus -- vbuaa=_stackpullbyte_ // [9] (byte) main::w#0 ← callfinalize plus -- vbuaa=_stackpullbyte_

View File

@ -234,14 +234,11 @@ __bend:
main: { main: {
.label __0 = 4 .label __0 = 4
.label __1 = 6 .label __1 = 6
// [5] callprepare next
// [5] callprepare next -- _stackpushbyte_2 // [5] callprepare next -- _stackpushbyte_2
pha pha
pha pha
// [5] callprepare next
// [6] callexecute next -- jsr // [6] callexecute next -- jsr
jsr next jsr next
// [7] (signed word~) main::$0 ← callfinalize next
// [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_ // [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_
pla pla
sta.z __0 sta.z __0
@ -252,14 +249,11 @@ main: {
sta SCREEN sta SCREEN
lda.z __0+1 lda.z __0+1
sta SCREEN+1 sta SCREEN+1
// [9] callprepare next
// [9] callprepare next -- _stackpushbyte_2 // [9] callprepare next -- _stackpushbyte_2
pha pha
pha pha
// [9] callprepare next
// [10] callexecute next -- jsr // [10] callexecute next -- jsr
jsr next jsr next
// [11] (signed word~) main::$1 ← callfinalize next
// [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_ // [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_
pla pla
sta.z __1 sta.z __1
@ -357,14 +351,11 @@ __bend:
main: { main: {
.label __0 = 2 .label __0 = 2
.label __1 = 4 .label __1 = 4
// [5] callprepare next
// [5] callprepare next -- _stackpushbyte_2 // [5] callprepare next -- _stackpushbyte_2
pha pha
pha pha
// [5] callprepare next
// [6] callexecute next -- jsr // [6] callexecute next -- jsr
jsr next jsr next
// [7] (signed word~) main::$0 ← callfinalize next
// [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_ // [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_
pla pla
sta.z __0 sta.z __0
@ -375,14 +366,11 @@ main: {
sta SCREEN sta SCREEN
lda.z __0+1 lda.z __0+1
sta SCREEN+1 sta SCREEN+1
// [9] callprepare next
// [9] callprepare next -- _stackpushbyte_2 // [9] callprepare next -- _stackpushbyte_2
pha pha
pha pha
// [9] callprepare next
// [10] callexecute next -- jsr // [10] callexecute next -- jsr
jsr next jsr next
// [11] (signed word~) main::$1 ← callfinalize next
// [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_ // [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_
pla pla
sta.z __1 sta.z __1
@ -490,14 +478,11 @@ main: {
.label __0 = 2 .label __0 = 2
.label __1 = 4 .label __1 = 4
// next() // next()
// [5] callprepare next
// [5] callprepare next -- _stackpushbyte_2 // [5] callprepare next -- _stackpushbyte_2
pha pha
pha pha
// [5] callprepare next
// [6] callexecute next -- jsr // [6] callexecute next -- jsr
jsr next jsr next
// [7] (signed word~) main::$0 ← callfinalize next
// [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_ // [7] (signed word~) main::$0 ← callfinalize next -- vwsz1=_stackpullsword_
pla pla
sta.z __0 sta.z __0
@ -510,14 +495,11 @@ main: {
lda.z __0+1 lda.z __0+1
sta SCREEN+1 sta SCREEN+1
// next() // next()
// [9] callprepare next
// [9] callprepare next -- _stackpushbyte_2 // [9] callprepare next -- _stackpushbyte_2
pha pha
pha pha
// [9] callprepare next
// [10] callexecute next -- jsr // [10] callexecute next -- jsr
jsr next jsr next
// [11] (signed word~) main::$1 ← callfinalize next
// [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_ // [11] (signed word~) main::$1 ← callfinalize next -- vwsz1=_stackpullsword_
pla pla
sta.z __1 sta.z __1