From f0d77acb297bde4549b02dc154610b91887b6835 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 17 Feb 2019 18:21:16 +0100 Subject: [PATCH] Added comments to variables identified as constants. --- .../passes/Pass2ConstantIdentification.java | 67 +++++++++++++++---- src/test/ref/c64dtv-8bppcharstretch.asm | 1 + src/test/ref/c64dtv-8bppcharstretch.log | 3 + src/test/ref/c64dtv-8bppchunkystretch.asm | 1 + src/test/ref/c64dtv-8bppchunkystretch.log | 3 + src/test/ref/c64dtv-blittermin.asm | 1 + src/test/ref/c64dtv-blittermin.log | 3 + src/test/ref/c64dtv-gfxexplorer.asm | 2 + src/test/ref/c64dtv-gfxexplorer.log | 30 +++++---- src/test/ref/c64dtv-gfxmodes.asm | 1 + src/test/ref/c64dtv-gfxmodes.log | 3 + src/test/ref/examples/3d/3d.asm | 20 ++++++ src/test/ref/examples/3d/3d.log | 66 +++++++++++++++++- src/test/ref/examples/3d/perspective.asm | 3 + src/test/ref/examples/3d/perspective.log | 9 +++ .../examples/fastmultiply/fastmultiply8.asm | 4 ++ .../examples/fastmultiply/fastmultiply8.log | 12 ++++ .../multiplexer/simple-multiplexer.asm | 1 + .../multiplexer/simple-multiplexer.log | 3 + src/test/ref/examples/rotate/rotate.asm | 4 ++ src/test/ref/examples/rotate/rotate.log | 14 +++- .../ref/examples/sinsprites/sinus-sprites.asm | 1 + .../ref/examples/sinsprites/sinus-sprites.log | 3 + src/test/ref/ptr-complex.asm | 2 + src/test/ref/ptr-complex.log | 6 ++ src/test/ref/ptrtest.asm | 1 + src/test/ref/ptrtest.log | 3 + src/test/ref/test-comments-single.asm | 1 + src/test/ref/test-comments-single.log | 3 + src/test/ref/test-multiply-8bit.asm | 1 + src/test/ref/test-multiply-8bit.log | 3 + src/test/ref/true-inline-words.asm | 2 + src/test/ref/true-inline-words.log | 6 ++ src/test/ref/unused-vars.asm | 1 + src/test/ref/unused-vars.log | 3 + src/test/ref/voronoi.asm | 1 + src/test/ref/voronoi.log | 3 + 37 files changed, 262 insertions(+), 29 deletions(-) diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantIdentification.java b/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantIdentification.java index bd566acbf..99a43c56b 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantIdentification.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantIdentification.java @@ -38,7 +38,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { */ @Override public boolean step() { - Map constants = findConstantVariables(); + Map constants = findConstantVariables(); LinkedHashMap constAliases = new LinkedHashMap<>(); // Update symbol table with the constant value Set constVars = new LinkedHashSet<>(constants.keySet()); @@ -51,9 +51,10 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { continue; } - ConstantValue constVal = constants.get(constRef); + ConstantVariableValue constVarVal = constants.get(constRef); Scope constScope = variable.getScope(); + ConstantValue constVal = constVarVal.getConstantValue(); SymbolType valueType = SymbolTypeInference.inferType(getScope(), constVal); SymbolType variableType = variable.getType(); SymbolType constType = variableType; @@ -78,7 +79,11 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { constVal); constantVar.setDeclaredAlignment(variable.getDeclaredAlignment()); constantVar.setDeclaredRegister(variable.getDeclaredRegister()); - constantVar.setComments(variable.getComments()); + if(variable.getComments().size()>0) { + constantVar.setComments(variable.getComments()); + } else { + constantVar.setComments(constVarVal.getAssignment().getComments()); + } constScope.remove(variable); constScope.add(constantVar); constAliases.put(constRef, constantVar.getRef()); @@ -91,13 +96,49 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { return constants.size() > 0; } + /** + * A variable identified as a constant. + */ + private static class ConstantVariableValue { + + /** The variable that has been determined to be constant. */ + private VariableRef variableRef; + + /** The constant value of the variable. */ + private ConstantValue constantValue; + + /** + * The statement that assigns the variable its value (the assignment will be removed at the end). + * Either a {@link StatementAssignment} or a {@link StatementPhiBlock}. + * */ + private Statement assignment; + + public ConstantVariableValue(VariableRef variableRef, ConstantValue constantValue, Statement assignment) { + this.variableRef = variableRef; + this.constantValue = constantValue; + this.assignment = assignment; + } + + public VariableRef getVariableRef() { + return variableRef; + } + + public ConstantValue getConstantValue() { + return constantValue; + } + + public Statement getAssignment() { + return assignment; + } + } + /** * Find variables that have constant values. * * @return Map from Variable to the Constant value */ - private Map findConstantVariables() { - final Map constants = new LinkedHashMap<>(); + private Map findConstantVariables() { + final Map constants = new LinkedHashMap<>(); for(ControlFlowBlock block : getGraph().getAllBlocks()) { for(Statement statement : block.getStatements()) { if(statement instanceof StatementAssignment) { @@ -113,7 +154,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { return constants; } - private void findConstantsPhi(Map constants, StatementPhiBlock phi) { + private void findConstantsPhi(Map constants, StatementPhiBlock phi) { for(StatementPhiBlock.PhiVariable phiVariable : phi.getPhiVariables()) { if(phiVariable.getValues().size() == 1) { StatementPhiBlock.PhiRValue phiRValue = phiVariable.getValues().get(0); @@ -125,13 +166,13 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { continue; } ConstantValue constant = getConstant(phiRValue.getrValue()); - constants.put(variable, constant); + constants.put(variable, new ConstantVariableValue(variable, constant, phi)); } } } } - private void findConstantsAssignment(Map constants, StatementAssignment assignment) { + private void findConstantsAssignment(Map constants, StatementAssignment assignment) { LValue lValue = assignment.getlValue(); if(lValue instanceof VariableRef) { VariableRef variable = (VariableRef) lValue; @@ -145,7 +186,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { // Constant assignment ConstantValue constant = getConstant(assignment.getrValue2()); if(constant != null) { - constants.put(variable, constant); + constants.put(variable, new ConstantVariableValue(variable, constant, assignment)); } } else { // Constant unary expression @@ -154,7 +195,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { getConstant(assignment.getrValue2()) ); if(constant != null) { - constants.put(variable, constant); + constants.put(variable, new ConstantVariableValue(variable, constant, assignment)); } } } else if(getConstant(assignment.getrValue1()) != null && getConstant(assignment.getrValue2()) != null) { @@ -165,7 +206,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { getConstant(assignment.getrValue2()), getScope()); if(constant != null) { - constants.put(variable, constant); + constants.put(variable, new ConstantVariableValue(variable, constant, assignment)); } } else if(assignment.getrValue2() instanceof ValueList && assignment.getOperator() == null && assignment.getrValue1() == null) { // A candidate for a constant list - examine to confirm @@ -204,14 +245,14 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization { if(allConstant && listType != null) { // Constant list confirmed! ConstantValue constant = new ConstantArrayList(elements, listType); - constants.put(variable, constant); + constants.put(variable, new ConstantVariableValue(variable, constant, assignment)); } } } else if(Operators.ADDRESS_OF.equals(assignment.getOperator()) && assignment.getrValue1() == null) { // Constant address-of variable if(assignment.getrValue2() instanceof SymbolRef) { ConstantSymbolPointer constantSymbolPointer = new ConstantSymbolPointer((SymbolRef) assignment.getrValue2()); - constants.put(variable, constantSymbolPointer); + constants.put(variable, new ConstantVariableValue(variable, constantSymbolPointer, assignment)); } } } diff --git a/src/test/ref/c64dtv-8bppcharstretch.asm b/src/test/ref/c64dtv-8bppcharstretch.asm index e532de27f..d04c2c64f 100644 --- a/src/test/ref/c64dtv-8bppcharstretch.asm +++ b/src/test/ref/c64dtv-8bppcharstretch.asm @@ -292,6 +292,7 @@ gfx_init_plane_charset8: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff sta cpuBank .byte $32, $dd diff --git a/src/test/ref/c64dtv-8bppcharstretch.log b/src/test/ref/c64dtv-8bppcharstretch.log index a7b1bbf4f..e7c40c849 100644 --- a/src/test/ref/c64dtv-8bppcharstretch.log +++ b/src/test/ref/c64dtv-8bppcharstretch.log @@ -2435,6 +2435,7 @@ gfx_init_plane_charset8: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff .label cpuBankIdx = $d //SEG139 [75] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#2 -- _deref_pbuc1=vbuz1 @@ -3193,6 +3194,7 @@ gfx_init_plane_charset8: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff //SEG139 [75] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#2 -- _deref_pbuc1=vbuaa sta cpuBank @@ -4143,6 +4145,7 @@ gfx_init_plane_charset8: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff //SEG139 [75] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#2 -- _deref_pbuc1=vbuaa sta cpuBank diff --git a/src/test/ref/c64dtv-8bppchunkystretch.asm b/src/test/ref/c64dtv-8bppchunkystretch.asm index fcf95c113..2aca00602 100644 --- a/src/test/ref/c64dtv-8bppchunkystretch.asm +++ b/src/test/ref/c64dtv-8bppchunkystretch.asm @@ -259,6 +259,7 @@ gfx_init_chunky: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff sta cpuBank .byte $32, $dd diff --git a/src/test/ref/c64dtv-8bppchunkystretch.log b/src/test/ref/c64dtv-8bppchunkystretch.log index c59ec6ae9..123fb3796 100644 --- a/src/test/ref/c64dtv-8bppchunkystretch.log +++ b/src/test/ref/c64dtv-8bppchunkystretch.log @@ -2006,6 +2006,7 @@ gfx_init_chunky: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff .label cpuBankIdx = 9 //SEG108 [59] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#3 -- _deref_pbuc1=vbuz1 @@ -2535,6 +2536,7 @@ gfx_init_chunky: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff //SEG108 [59] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#3 -- _deref_pbuc1=vbuaa sta cpuBank @@ -3263,6 +3265,7 @@ gfx_init_chunky: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff //SEG108 [59] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#3 -- _deref_pbuc1=vbuaa sta cpuBank diff --git a/src/test/ref/c64dtv-blittermin.asm b/src/test/ref/c64dtv-blittermin.asm index 0aa7b49d9..787b6f9ec 100644 --- a/src/test/ref/c64dtv-blittermin.asm +++ b/src/test/ref/c64dtv-blittermin.asm @@ -58,6 +58,7 @@ // No transparancy // Bit[2]==Bit[1]==0: write in any case .const DTV_BLIT_TRANSPARANCY_NONE = 0 + // Controls the ALU operation .label DTV_BLITTER_ALU = $d33e .const DTV_BLIT_ADD = $30 // Blitter Control 2 diff --git a/src/test/ref/c64dtv-blittermin.log b/src/test/ref/c64dtv-blittermin.log index 153f597b3..6534f5639 100644 --- a/src/test/ref/c64dtv-blittermin.log +++ b/src/test/ref/c64dtv-blittermin.log @@ -1238,6 +1238,7 @@ INITIAL ASM // No transparancy // Bit[2]==Bit[1]==0: write in any case .const DTV_BLIT_TRANSPARANCY_NONE = 0 + // Controls the ALU operation .label DTV_BLITTER_ALU = $d33e .const DTV_BLIT_ADD = $30 // Blitter Control 2 @@ -1560,6 +1561,7 @@ ASSEMBLER BEFORE OPTIMIZATION // No transparancy // Bit[2]==Bit[1]==0: write in any case .const DTV_BLIT_TRANSPARANCY_NONE = 0 + // Controls the ALU operation .label DTV_BLITTER_ALU = $d33e .const DTV_BLIT_ADD = $30 // Blitter Control 2 @@ -2079,6 +2081,7 @@ Score: 1561 // No transparancy // Bit[2]==Bit[1]==0: write in any case .const DTV_BLIT_TRANSPARANCY_NONE = 0 + // Controls the ALU operation .label DTV_BLITTER_ALU = $d33e .const DTV_BLIT_ADD = $30 // Blitter Control 2 diff --git a/src/test/ref/c64dtv-gfxexplorer.asm b/src/test/ref/c64dtv-gfxexplorer.asm index 50b2e5118..7162f614c 100644 --- a/src/test/ref/c64dtv-gfxexplorer.asm +++ b/src/test/ref/c64dtv-gfxexplorer.asm @@ -124,6 +124,7 @@ .label FORM_SCREEN = $400 // Charset used for the FORM .label FORM_CHARSET = $1800 + // Number of form fields .const form_fields_cnt = $24 // The number of frames to use for a full blink cycle .const FORM_CURSOR_BLINK = $28 @@ -1661,6 +1662,7 @@ gfx_init_plane_fill: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff sta cpuBank .byte $32, $dd diff --git a/src/test/ref/c64dtv-gfxexplorer.log b/src/test/ref/c64dtv-gfxexplorer.log index cabca5121..d64dbba57 100644 --- a/src/test/ref/c64dtv-gfxexplorer.log +++ b/src/test/ref/c64dtv-gfxexplorer.log @@ -13865,6 +13865,7 @@ INITIAL ASM .label FORM_SCREEN = $400 // Charset used for the FORM .label FORM_CHARSET = $1800 + // Number of form fields .const form_fields_cnt = $24 // The number of frames to use for a full blink cycle .const FORM_CURSOR_BLINK = $28 @@ -17335,6 +17336,7 @@ gfx_init_plane_fill: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff .label cpuBankIdx = $43 //SEG1003 [506] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#13 -- _deref_pbuc1=vbuz1 @@ -21155,6 +21157,7 @@ ASSEMBLER BEFORE OPTIMIZATION .label FORM_SCREEN = $400 // Charset used for the FORM .label FORM_CHARSET = $1800 + // Number of form fields .const form_fields_cnt = $24 // The number of frames to use for a full blink cycle .const FORM_CURSOR_BLINK = $28 @@ -24225,6 +24228,7 @@ gfx_init_plane_fill: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff //SEG1003 [506] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#13 -- _deref_pbuc1=vbuaa sta cpuBank @@ -27330,18 +27334,18 @@ Removing instruction b37: Succesful ASM optimization Pass5UnusedLabelElimination Removing unreachable instruction jmp b7 Succesful ASM optimization Pass5UnreachableCodeElimination -Fixing long branch [761] beq b5 to bne -Fixing long branch [765] beq b6 to bne -Fixing long branch [769] beq b7 to bne -Fixing long branch [773] beq b8 to bne -Fixing long branch [759] beq b4 to bne -Fixing long branch [779] beq b9 to bne -Fixing long branch [783] beq b10 to bne -Fixing long branch [787] beq b11 to bne -Fixing long branch [791] beq b12 to bne -Fixing long branch [757] beq b3 to bne -Fixing long branch [797] beq b13 to bne -Fixing long branch [1345] bmi b2 to bpl +Fixing long branch [762] beq b5 to bne +Fixing long branch [766] beq b6 to bne +Fixing long branch [770] beq b7 to bne +Fixing long branch [774] beq b8 to bne +Fixing long branch [760] beq b4 to bne +Fixing long branch [780] beq b9 to bne +Fixing long branch [784] beq b10 to bne +Fixing long branch [788] beq b11 to bne +Fixing long branch [792] beq b12 to bne +Fixing long branch [758] beq b3 to bne +Fixing long branch [798] beq b13 to bne +Fixing long branch [1346] bmi b2 to bpl FINAL SYMBOL TABLE (label) @68 @@ -29179,6 +29183,7 @@ Score: 11370517 .label FORM_SCREEN = $400 // Charset used for the FORM .label FORM_CHARSET = $1800 + // Number of form fields .const form_fields_cnt = $24 // The number of frames to use for a full blink cycle .const FORM_CURSOR_BLINK = $28 @@ -31716,6 +31721,7 @@ gfx_init_plane_fill: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff //SEG1003 [506] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#13 -- _deref_pbuc1=vbuaa sta cpuBank diff --git a/src/test/ref/c64dtv-gfxmodes.asm b/src/test/ref/c64dtv-gfxmodes.asm index 4276e5707..0e1a29a36 100644 --- a/src/test/ref/c64dtv-gfxmodes.asm +++ b/src/test/ref/c64dtv-gfxmodes.asm @@ -483,6 +483,7 @@ keyboard_matrix_read: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff sta cpuBank .byte $32, $dd diff --git a/src/test/ref/c64dtv-gfxmodes.log b/src/test/ref/c64dtv-gfxmodes.log index eb7189c0f..d8a12c6e3 100644 --- a/src/test/ref/c64dtv-gfxmodes.log +++ b/src/test/ref/c64dtv-gfxmodes.log @@ -13919,6 +13919,7 @@ keyboard_matrix_read: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff .label cpuBankIdx = $f //SEG408 [224] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#3 -- _deref_pbuc1=vbuz1 @@ -20632,6 +20633,7 @@ keyboard_matrix_read: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff //SEG408 [224] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#3 -- _deref_pbuc1=vbuaa sta cpuBank @@ -27538,6 +27540,7 @@ keyboard_matrix_read: { // This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff // The actual memory addressed will be $4000*cpuSegmentIdx dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff //SEG408 [224] *((const byte*) dtvSetCpuBankSegment1::cpuBank#0) ← (byte) dtvSetCpuBankSegment1::cpuBankIdx#3 -- _deref_pbuc1=vbuaa sta cpuBank diff --git a/src/test/ref/examples/3d/3d.asm b/src/test/ref/examples/3d/3d.asm index ff5f2f55d..2897b406b 100644 --- a/src/test/ref/examples/3d/3d.asm +++ b/src/test/ref/examples/3d/3d.asm @@ -15,25 +15,45 @@ .const LIGHT_BLUE = $e .const LIGHT_GREY = $f .label print_line_cursor = $400 + // The rotated point - updated by calling rotate_matrix() .label xr = $f0 .label yr = $f1 .label zr = $f2 + // The rotated point with perspective .label pp = $f3 .label xp = $f4 .label yp = $f5 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2 .label psp1 = $f6 .label psp2 = $f8 .label SCREEN = $400 .const sz = 0 + // mulf_sqr tables will contain f(x)=int(x*x) and g(x) = f(1-x). + // f(x) = >(( x * x )) .label mulf_sqr1 = $2400 + // g(x) = >((( 1 - x ) * ( 1 - x ))) .label mulf_sqr2 = $2600 + // A single sprite .label SPRITE = $3000 + // Perspective multiplication table containing (d/(z0-z)[z] for each z-value .label PERSP_Z = $2800 + // Sine and Cosine Tables + // Angles: $00=0, $80=PI,$100=2*PI + // Half Sine/Cosine: signed fixed [-$20;20] .label SINH = $2000 + // sin(x) = cos(x+PI/2) + // Quarter Sine/Cosine: signed fixed [-$10,$10] .label SINQ = $2200 + // 16 bit Sine and Cosine Tables + // Angles: $00=0, $80=PI,$100=2*PI + // Half Sine/Cosine: signed fixed [-$1f,$1f] .label SINH_LO = $4000 + // sin(x) = cos(x+PI/2) .label SINH_HI = $4200 + // sin(x) = cos(x+PI/2) + // Quarter Sine/Cosine: signed fixed [-$0f,$0f] .label SINQ_LO = $4400 + // sin(x) = cos(x+PI/2) .label SINQ_HI = $4600 .label COSH = SINH+$40 .label COSQ = SINQ+$40 diff --git a/src/test/ref/examples/3d/3d.log b/src/test/ref/examples/3d/3d.log index 562f39eca..28f705ae6 100644 --- a/src/test/ref/examples/3d/3d.log +++ b/src/test/ref/examples/3d/3d.log @@ -5676,25 +5676,45 @@ INITIAL ASM .const LIGHT_BLUE = $e .const LIGHT_GREY = $f .label print_line_cursor = $400 + // The rotated point - updated by calling rotate_matrix() .label xr = $f0 .label yr = $f1 .label zr = $f2 + // The rotated point with perspective .label pp = $f3 .label xp = $f4 .label yp = $f5 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2 .label psp1 = $f6 .label psp2 = $f8 .label SCREEN = $400 .const sz = 0 + // mulf_sqr tables will contain f(x)=int(x*x) and g(x) = f(1-x). + // f(x) = >(( x * x )) .label mulf_sqr1 = $2400 + // g(x) = >((( 1 - x ) * ( 1 - x ))) .label mulf_sqr2 = $2600 + // A single sprite .label SPRITE = $3000 + // Perspective multiplication table containing (d/(z0-z)[z] for each z-value .label PERSP_Z = $2800 + // Sine and Cosine Tables + // Angles: $00=0, $80=PI,$100=2*PI + // Half Sine/Cosine: signed fixed [-$20;20] .label SINH = $2000 + // sin(x) = cos(x+PI/2) + // Quarter Sine/Cosine: signed fixed [-$10,$10] .label SINQ = $2200 + // 16 bit Sine and Cosine Tables + // Angles: $00=0, $80=PI,$100=2*PI + // Half Sine/Cosine: signed fixed [-$1f,$1f] .label SINH_LO = $4000 + // sin(x) = cos(x+PI/2) .label SINH_HI = $4200 + // sin(x) = cos(x+PI/2) + // Quarter Sine/Cosine: signed fixed [-$0f,$0f] .label SINQ_LO = $4400 + // sin(x) = cos(x+PI/2) .label SINQ_HI = $4600 .label COSH = SINH+$40 .label COSQ = SINQ+$40 @@ -8462,25 +8482,45 @@ ASSEMBLER BEFORE OPTIMIZATION .const LIGHT_BLUE = $e .const LIGHT_GREY = $f .label print_line_cursor = $400 + // The rotated point - updated by calling rotate_matrix() .label xr = $f0 .label yr = $f1 .label zr = $f2 + // The rotated point with perspective .label pp = $f3 .label xp = $f4 .label yp = $f5 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2 .label psp1 = $f6 .label psp2 = $f8 .label SCREEN = $400 .const sz = 0 + // mulf_sqr tables will contain f(x)=int(x*x) and g(x) = f(1-x). + // f(x) = >(( x * x )) .label mulf_sqr1 = $2400 + // g(x) = >((( 1 - x ) * ( 1 - x ))) .label mulf_sqr2 = $2600 + // A single sprite .label SPRITE = $3000 + // Perspective multiplication table containing (d/(z0-z)[z] for each z-value .label PERSP_Z = $2800 + // Sine and Cosine Tables + // Angles: $00=0, $80=PI,$100=2*PI + // Half Sine/Cosine: signed fixed [-$20;20] .label SINH = $2000 + // sin(x) = cos(x+PI/2) + // Quarter Sine/Cosine: signed fixed [-$10,$10] .label SINQ = $2200 + // 16 bit Sine and Cosine Tables + // Angles: $00=0, $80=PI,$100=2*PI + // Half Sine/Cosine: signed fixed [-$1f,$1f] .label SINH_LO = $4000 + // sin(x) = cos(x+PI/2) .label SINH_HI = $4200 + // sin(x) = cos(x+PI/2) + // Quarter Sine/Cosine: signed fixed [-$0f,$0f] .label SINQ_LO = $4400 + // sin(x) = cos(x+PI/2) .label SINQ_HI = $4600 .label COSH = SINH+$40 .label COSQ = SINQ+$40 @@ -10687,9 +10727,9 @@ Removing instruction jmp b1 Succesful ASM optimization Pass5NextJumpElimination Removing instruction bbegin: Succesful ASM optimization Pass5UnusedLabelElimination -Fixing long branch [318] bne b1 to beq -Fixing long branch [1005] bne b2 to beq -Fixing long branch [1015] bne b1 to beq +Fixing long branch [338] bne b1 to beq +Fixing long branch [1025] bne b2 to beq +Fixing long branch [1035] bne b1 to beq FINAL SYMBOL TABLE (label) @33 @@ -11335,25 +11375,45 @@ Score: 85538 .const LIGHT_BLUE = $e .const LIGHT_GREY = $f .label print_line_cursor = $400 + // The rotated point - updated by calling rotate_matrix() .label xr = $f0 .label yr = $f1 .label zr = $f2 + // The rotated point with perspective .label pp = $f3 .label xp = $f4 .label yp = $f5 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2 .label psp1 = $f6 .label psp2 = $f8 .label SCREEN = $400 .const sz = 0 + // mulf_sqr tables will contain f(x)=int(x*x) and g(x) = f(1-x). + // f(x) = >(( x * x )) .label mulf_sqr1 = $2400 + // g(x) = >((( 1 - x ) * ( 1 - x ))) .label mulf_sqr2 = $2600 + // A single sprite .label SPRITE = $3000 + // Perspective multiplication table containing (d/(z0-z)[z] for each z-value .label PERSP_Z = $2800 + // Sine and Cosine Tables + // Angles: $00=0, $80=PI,$100=2*PI + // Half Sine/Cosine: signed fixed [-$20;20] .label SINH = $2000 + // sin(x) = cos(x+PI/2) + // Quarter Sine/Cosine: signed fixed [-$10,$10] .label SINQ = $2200 + // 16 bit Sine and Cosine Tables + // Angles: $00=0, $80=PI,$100=2*PI + // Half Sine/Cosine: signed fixed [-$1f,$1f] .label SINH_LO = $4000 + // sin(x) = cos(x+PI/2) .label SINH_HI = $4200 + // sin(x) = cos(x+PI/2) + // Quarter Sine/Cosine: signed fixed [-$0f,$0f] .label SINQ_LO = $4400 + // sin(x) = cos(x+PI/2) .label SINQ_HI = $4600 .label COSH = SINH+$40 .label COSQ = SINQ+$40 diff --git a/src/test/ref/examples/3d/perspective.asm b/src/test/ref/examples/3d/perspective.asm index 5ba771fe6..b87d9d392 100644 --- a/src/test/ref/examples/3d/perspective.asm +++ b/src/test/ref/examples/3d/perspective.asm @@ -5,11 +5,14 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + // The rotated point - updated by calling rotate() .label xr = $f0 .label yr = $f1 .label zr = $f2 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2. .label psp1 = $f3 .label psp2 = $f5 + // Perspective multiplication table containing (d/(z0-z)[z] for each z-value .label PERSP_Z = $2400 .label print_char_cursor = 4 .label print_line_cursor = 2 diff --git a/src/test/ref/examples/3d/perspective.log b/src/test/ref/examples/3d/perspective.log index c8751d300..f9758db77 100644 --- a/src/test/ref/examples/3d/perspective.log +++ b/src/test/ref/examples/3d/perspective.log @@ -1937,11 +1937,14 @@ INITIAL ASM :BasicUpstart(bbegin) .pc = $80d "Program" //SEG2 Global Constants & labels + // The rotated point - updated by calling rotate() .label xr = $f0 .label yr = $f1 .label zr = $f2 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2. .label psp1 = $f3 .label psp2 = $f5 + // Perspective multiplication table containing (d/(z0-z)[z] for each z-value .label PERSP_Z = $2400 .label print_char_cursor = 8 .label print_line_cursor = 2 @@ -2751,11 +2754,14 @@ ASSEMBLER BEFORE OPTIMIZATION :BasicUpstart(bbegin) .pc = $80d "Program" //SEG2 Global Constants & labels + // The rotated point - updated by calling rotate() .label xr = $f0 .label yr = $f1 .label zr = $f2 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2. .label psp1 = $f3 .label psp2 = $f5 + // Perspective multiplication table containing (d/(z0-z)[z] for each z-value .label PERSP_Z = $2400 .label print_char_cursor = 4 .label print_line_cursor = 2 @@ -3779,11 +3785,14 @@ Score: 3781 :BasicUpstart(main) .pc = $80d "Program" //SEG2 Global Constants & labels + // The rotated point - updated by calling rotate() .label xr = $f0 .label yr = $f1 .label zr = $f2 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2. .label psp1 = $f3 .label psp2 = $f5 + // Perspective multiplication table containing (d/(z0-z)[z] for each z-value .label PERSP_Z = $2400 .label print_char_cursor = 4 .label print_line_cursor = 2 diff --git a/src/test/ref/examples/fastmultiply/fastmultiply8.asm b/src/test/ref/examples/fastmultiply/fastmultiply8.asm index d3e4982d3..2ea2a7790 100644 --- a/src/test/ref/examples/fastmultiply/fastmultiply8.asm +++ b/src/test/ref/examples/fastmultiply/fastmultiply8.asm @@ -9,10 +9,14 @@ :BasicUpstart(main) .pc = $80d "Program" .label print_line_cursor = $400 + // Pointers to a, b and c=a*b .label ap = $fd .label bp = $fe .label cp = $ff + // mulf_sqr tables will contain f(x)=int(x*x) and g(x) = f(1-x). + // f(x) = >(( x * x )) .label mulf_sqr1 = $2000 + // g(x) = >((( 1 - x ) * ( 1 - x ))) .label mulf_sqr2 = $2200 main: { .label at = 2 diff --git a/src/test/ref/examples/fastmultiply/fastmultiply8.log b/src/test/ref/examples/fastmultiply/fastmultiply8.log index 407866480..ae17de7ec 100644 --- a/src/test/ref/examples/fastmultiply/fastmultiply8.log +++ b/src/test/ref/examples/fastmultiply/fastmultiply8.log @@ -1317,10 +1317,14 @@ INITIAL ASM .pc = $80d "Program" //SEG2 Global Constants & labels .label print_line_cursor = $400 + // Pointers to a, b and c=a*b .label ap = $fd .label bp = $fe .label cp = $ff + // mulf_sqr tables will contain f(x)=int(x*x) and g(x) = f(1-x). + // f(x) = >(( x * x )) .label mulf_sqr1 = $2000 + // g(x) = >((( 1 - x ) * ( 1 - x ))) .label mulf_sqr2 = $2200 //SEG3 @begin bbegin: @@ -2001,10 +2005,14 @@ ASSEMBLER BEFORE OPTIMIZATION .pc = $80d "Program" //SEG2 Global Constants & labels .label print_line_cursor = $400 + // Pointers to a, b and c=a*b .label ap = $fd .label bp = $fe .label cp = $ff + // mulf_sqr tables will contain f(x)=int(x*x) and g(x) = f(1-x). + // f(x) = >(( x * x )) .label mulf_sqr1 = $2000 + // g(x) = >((( 1 - x ) * ( 1 - x ))) .label mulf_sqr2 = $2200 //SEG3 @begin bbegin: @@ -2737,10 +2745,14 @@ Score: 10536 .pc = $80d "Program" //SEG2 Global Constants & labels .label print_line_cursor = $400 + // Pointers to a, b and c=a*b .label ap = $fd .label bp = $fe .label cp = $ff + // mulf_sqr tables will contain f(x)=int(x*x) and g(x) = f(1-x). + // f(x) = >(( x * x )) .label mulf_sqr1 = $2000 + // g(x) = >((( 1 - x ) * ( 1 - x ))) .label mulf_sqr2 = $2200 //SEG3 @begin //SEG4 @22 diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.asm b/src/test/ref/examples/multiplexer/simple-multiplexer.asm index f4775ae58..bfd30d31c 100644 --- a/src/test/ref/examples/multiplexer/simple-multiplexer.asm +++ b/src/test/ref/examples/multiplexer/simple-multiplexer.asm @@ -18,6 +18,7 @@ .const GREEN = 5 // The number of sprites in the multiplexer .const PLEX_COUNT = $20 + // Location of screen & sprites .label SCREEN = $400 .label SPRITE = $2000 .label YSIN = $2100 diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.log b/src/test/ref/examples/multiplexer/simple-multiplexer.log index 4436f2a67..8bb307671 100644 --- a/src/test/ref/examples/multiplexer/simple-multiplexer.log +++ b/src/test/ref/examples/multiplexer/simple-multiplexer.log @@ -2475,6 +2475,7 @@ INITIAL ASM .const GREEN = 5 // The number of sprites in the multiplexer .const PLEX_COUNT = $20 + // Location of screen & sprites .label SCREEN = $400 .label SPRITE = $2000 .label YSIN = $2100 @@ -3314,6 +3315,7 @@ ASSEMBLER BEFORE OPTIMIZATION .const GREEN = 5 // The number of sprites in the multiplexer .const PLEX_COUNT = $20 + // Location of screen & sprites .label SCREEN = $400 .label SPRITE = $2000 .label YSIN = $2100 @@ -4310,6 +4312,7 @@ Score: 63460 .const GREEN = 5 // The number of sprites in the multiplexer .const PLEX_COUNT = $20 + // Location of screen & sprites .label SCREEN = $400 .label SPRITE = $2000 .label YSIN = $2100 diff --git a/src/test/ref/examples/rotate/rotate.asm b/src/test/ref/examples/rotate/rotate.asm index ad63c782b..8907bf053 100644 --- a/src/test/ref/examples/rotate/rotate.asm +++ b/src/test/ref/examples/rotate/rotate.asm @@ -12,7 +12,11 @@ .const GREEN = 5 .const LIGHT_BLUE = $e .label SCREEN = $400 + // Sine and Cosine tables + // Angles: $00=0, $80=PI,$100=2*PI + // Sine/Cosine: signed fixed [-$7f,$7f] .label COS = $2000 + // A single sprite .label SPRITE = $3000 .label SIN = COS+$40 // sin(x) = cos(x+PI/2) diff --git a/src/test/ref/examples/rotate/rotate.log b/src/test/ref/examples/rotate/rotate.log index 738ac0b48..40c166c24 100644 --- a/src/test/ref/examples/rotate/rotate.log +++ b/src/test/ref/examples/rotate/rotate.log @@ -2289,7 +2289,11 @@ INITIAL ASM .const GREEN = 5 .const LIGHT_BLUE = $e .label SCREEN = $400 + // Sine and Cosine tables + // Angles: $00=0, $80=PI,$100=2*PI + // Sine/Cosine: signed fixed [-$7f,$7f] .label COS = $2000 + // A single sprite .label SPRITE = $3000 .label SIN = COS+$40 //SEG3 @begin @@ -3376,7 +3380,11 @@ ASSEMBLER BEFORE OPTIMIZATION .const GREEN = 5 .const LIGHT_BLUE = $e .label SCREEN = $400 + // Sine and Cosine tables + // Angles: $00=0, $80=PI,$100=2*PI + // Sine/Cosine: signed fixed [-$7f,$7f] .label COS = $2000 + // A single sprite .label SPRITE = $3000 .label SIN = COS+$40 //SEG3 @begin @@ -4202,7 +4210,7 @@ Removing instruction b12: Succesful ASM optimization Pass5UnusedLabelElimination Removing unreachable instruction jmp b4 Succesful ASM optimization Pass5UnreachableCodeElimination -Fixing long branch [136] bne b7 to beq +Fixing long branch [140] bne b7 to beq FINAL SYMBOL TABLE (label) @13 @@ -4533,7 +4541,11 @@ Score: 34700 .const GREEN = 5 .const LIGHT_BLUE = $e .label SCREEN = $400 + // Sine and Cosine tables + // Angles: $00=0, $80=PI,$100=2*PI + // Sine/Cosine: signed fixed [-$7f,$7f] .label COS = $2000 + // A single sprite .label SPRITE = $3000 .label SIN = COS+$40 //SEG3 @begin diff --git a/src/test/ref/examples/sinsprites/sinus-sprites.asm b/src/test/ref/examples/sinsprites/sinus-sprites.asm index cbdda9781..936393a37 100644 --- a/src/test/ref/examples/sinsprites/sinus-sprites.asm +++ b/src/test/ref/examples/sinsprites/sinus-sprites.asm @@ -195,6 +195,7 @@ clear_screen: { // - min is the minimum value of the generated sinus // - max is the maximum value of the generated sinus gen_sintab: { + // amplitude/2 .label f_2pi = $e2e5 .label _23 = $c .label i = 2 diff --git a/src/test/ref/examples/sinsprites/sinus-sprites.log b/src/test/ref/examples/sinsprites/sinus-sprites.log index 6f7ea7593..98e4d7603 100644 --- a/src/test/ref/examples/sinsprites/sinus-sprites.log +++ b/src/test/ref/examples/sinsprites/sinus-sprites.log @@ -3961,6 +3961,7 @@ clear_screen: { // - min is the minimum value of the generated sinus // - max is the maximum value of the generated sinus gen_sintab: { + // amplitude/2 .label f_2pi = $e2e5 .label _23 = $37 .label _24 = $39 @@ -5724,6 +5725,7 @@ clear_screen: { // - min is the minimum value of the generated sinus // - max is the maximum value of the generated sinus gen_sintab: { + // amplitude/2 .label f_2pi = $e2e5 .label _23 = $c .label i = 2 @@ -7711,6 +7713,7 @@ clear_screen: { // - min is the minimum value of the generated sinus // - max is the maximum value of the generated sinus gen_sintab: { + // amplitude/2 .label f_2pi = $e2e5 .label _23 = $c .label i = 2 diff --git a/src/test/ref/ptr-complex.asm b/src/test/ref/ptr-complex.asm index 3ceaad9dd..a7954f252 100644 --- a/src/test/ref/ptr-complex.asm +++ b/src/test/ref/ptr-complex.asm @@ -3,7 +3,9 @@ :BasicUpstart(main) .pc = $80d "Program" main: { + // RValue pointer expression (constant) .label screen = $400 + // Increment on a const named pointer .label BGCOL = $d020 .label sc2 = screen+$51 .label _2 = 2 diff --git a/src/test/ref/ptr-complex.log b/src/test/ref/ptr-complex.log index 53718cc5e..2a41ecacc 100644 --- a/src/test/ref/ptr-complex.log +++ b/src/test/ref/ptr-complex.log @@ -299,7 +299,9 @@ bend_from_b1: bend: //SEG9 main main: { + // RValue pointer expression (constant) .label screen = $400 + // Increment on a const named pointer .label BGCOL = $d020 .label sc2 = screen+$51 .label _2 = 5 @@ -469,7 +471,9 @@ bend_from_b1: bend: //SEG9 main main: { + // RValue pointer expression (constant) .label screen = $400 + // Increment on a const named pointer .label BGCOL = $d020 .label sc2 = screen+$51 .label _2 = 2 @@ -658,7 +662,9 @@ Score: 954 //SEG8 @end //SEG9 main main: { + // RValue pointer expression (constant) .label screen = $400 + // Increment on a const named pointer .label BGCOL = $d020 .label sc2 = screen+$51 .label _2 = 2 diff --git a/src/test/ref/ptrtest.asm b/src/test/ref/ptrtest.asm index c65ba8ab3..7208b9351 100644 --- a/src/test/ref/ptrtest.asm +++ b/src/test/ref/ptrtest.asm @@ -10,6 +10,7 @@ main: { rts } lvaluevar: { + // LValue Variable pointer dereference .const b = 4 .label screen = 2 lda #<$400 diff --git a/src/test/ref/ptrtest.log b/src/test/ref/ptrtest.log index 7157ff7f8..a015753ef 100644 --- a/src/test/ref/ptrtest.log +++ b/src/test/ref/ptrtest.log @@ -481,6 +481,7 @@ main: { } //SEG25 lvaluevar lvaluevar: { + // LValue Variable pointer dereference .const b = 4 .label screen = 3 .label i = 2 @@ -767,6 +768,7 @@ main: { } //SEG25 lvaluevar lvaluevar: { + // LValue Variable pointer dereference .const b = 4 .label screen = 2 //SEG26 [14] phi from lvaluevar to lvaluevar::@1 [phi:lvaluevar->lvaluevar::@1] @@ -1084,6 +1086,7 @@ main: { } //SEG25 lvaluevar lvaluevar: { + // LValue Variable pointer dereference .const b = 4 .label screen = 2 //SEG26 [14] phi from lvaluevar to lvaluevar::@1 [phi:lvaluevar->lvaluevar::@1] diff --git a/src/test/ref/test-comments-single.asm b/src/test/ref/test-comments-single.asm index f3ac2f2cc..94e113883 100644 --- a/src/test/ref/test-comments-single.asm +++ b/src/test/ref/test-comments-single.asm @@ -5,6 +5,7 @@ .pc = $80d "Program" // The C64 screen .label SCREEN = $400 + // One of the bytes used for addition .const a = 'a' // The program entry point main: { diff --git a/src/test/ref/test-comments-single.log b/src/test/ref/test-comments-single.log index 77053d2a8..2a148e8a2 100644 --- a/src/test/ref/test-comments-single.log +++ b/src/test/ref/test-comments-single.log @@ -242,6 +242,7 @@ INITIAL ASM //SEG2 Global Constants & labels // The C64 screen .label SCREEN = $400 + // One of the bytes used for addition .const a = 'a' //SEG3 @begin bbegin: @@ -368,6 +369,7 @@ ASSEMBLER BEFORE OPTIMIZATION //SEG2 Global Constants & labels // The C64 screen .label SCREEN = $400 + // One of the bytes used for addition .const a = 'a' //SEG3 @begin bbegin: @@ -523,6 +525,7 @@ Score: 253 //SEG2 Global Constants & labels // The C64 screen .label SCREEN = $400 + // One of the bytes used for addition .const a = 'a' //SEG3 @begin //SEG4 [1] phi from @begin to @2 [phi:@begin->@2] diff --git a/src/test/ref/test-multiply-8bit.asm b/src/test/ref/test-multiply-8bit.asm index a9c4252fe..2ad726b6e 100644 --- a/src/test/ref/test-multiply-8bit.asm +++ b/src/test/ref/test-multiply-8bit.asm @@ -706,6 +706,7 @@ mulf_tables_cmp: { // Initialize the multiplication tables using ASM code from // http://codebase64.org/doku.php?id=base:seriously_fast_multiplication mulf_init_asm: { + // Ensure the ASM tables are not detected as unused by the optimizer .label mem = $ff ldx #0 txa diff --git a/src/test/ref/test-multiply-8bit.log b/src/test/ref/test-multiply-8bit.log index 83ddd0e77..495a1ce12 100644 --- a/src/test/ref/test-multiply-8bit.log +++ b/src/test/ref/test-multiply-8bit.log @@ -6919,6 +6919,7 @@ mulf_tables_cmp: { // Initialize the multiplication tables using ASM code from // http://codebase64.org/doku.php?id=base:seriously_fast_multiplication mulf_init_asm: { + // Ensure the ASM tables are not detected as unused by the optimizer .label mem = $ff //SEG650 asm { ldx#$00 txa .byte$c9 lb1: tya adc#$00 ml1: stamula_sqr1_hi,x tay cmp#$40 txa ror ml9: adc#$00 staml9+1 inx ml0: stamula_sqr1_lo,x bnelb1 incml0+2 incml1+2 clc iny bnelb1 ldx#$00 ldy#$ff !: ldamula_sqr1_hi+1,x stamula_sqr2_hi+$100,x ldamula_sqr1_hi,x stamula_sqr2_hi,y ldamula_sqr1_lo+1,x stamula_sqr2_lo+$100,x ldamula_sqr1_lo,x stamula_sqr2_lo,y dey inx bne!- } ldx #0 @@ -9479,6 +9480,7 @@ mulf_tables_cmp: { // Initialize the multiplication tables using ASM code from // http://codebase64.org/doku.php?id=base:seriously_fast_multiplication mulf_init_asm: { + // Ensure the ASM tables are not detected as unused by the optimizer .label mem = $ff //SEG650 asm { ldx#$00 txa .byte$c9 lb1: tya adc#$00 ml1: stamula_sqr1_hi,x tay cmp#$40 txa ror ml9: adc#$00 staml9+1 inx ml0: stamula_sqr1_lo,x bnelb1 incml0+2 incml1+2 clc iny bnelb1 ldx#$00 ldy#$ff !: ldamula_sqr1_hi+1,x stamula_sqr2_hi+$100,x ldamula_sqr1_hi,x stamula_sqr2_hi,y ldamula_sqr1_lo+1,x stamula_sqr2_lo+$100,x ldamula_sqr1_lo,x stamula_sqr2_lo,y dey inx bne!- } ldx #0 @@ -12142,6 +12144,7 @@ mulf_tables_cmp: { // Initialize the multiplication tables using ASM code from // http://codebase64.org/doku.php?id=base:seriously_fast_multiplication mulf_init_asm: { + // Ensure the ASM tables are not detected as unused by the optimizer .label mem = $ff //SEG650 asm { ldx#$00 txa .byte$c9 lb1: tya adc#$00 ml1: stamula_sqr1_hi,x tay cmp#$40 txa ror ml9: adc#$00 staml9+1 inx ml0: stamula_sqr1_lo,x bnelb1 incml0+2 incml1+2 clc iny bnelb1 ldx#$00 ldy#$ff !: ldamula_sqr1_hi+1,x stamula_sqr2_hi+$100,x ldamula_sqr1_hi,x stamula_sqr2_hi,y ldamula_sqr1_lo+1,x stamula_sqr2_lo+$100,x ldamula_sqr1_lo,x stamula_sqr2_lo,y dey inx bne!- } ldx #0 diff --git a/src/test/ref/true-inline-words.asm b/src/test/ref/true-inline-words.asm index d4d80700a..054deca64 100644 --- a/src/test/ref/true-inline-words.asm +++ b/src/test/ref/true-inline-words.asm @@ -2,7 +2,9 @@ :BasicUpstart(main) .pc = $80d "Program" main: { + // constant byte array .const b = 4 + // Test the result .label pos = $501 .label bgcol = $d021 .const w = b*$100 diff --git a/src/test/ref/true-inline-words.log b/src/test/ref/true-inline-words.log index 9b6e314a7..903c27a93 100644 --- a/src/test/ref/true-inline-words.log +++ b/src/test/ref/true-inline-words.log @@ -177,7 +177,9 @@ bend_from_b1: bend: //SEG9 main main: { + // constant byte array .const b = 4 + // Test the result .label pos = $501 .label bgcol = $d021 .const w = b*$100 @@ -246,7 +248,9 @@ bend_from_b1: bend: //SEG9 main main: { + // constant byte array .const b = 4 + // Test the result .label pos = $501 .label bgcol = $d021 .const w = b*$100 @@ -339,7 +343,9 @@ Score: 37 //SEG8 @end //SEG9 main main: { + // constant byte array .const b = 4 + // Test the result .label pos = $501 .label bgcol = $d021 .const w = b*$100 diff --git a/src/test/ref/unused-vars.asm b/src/test/ref/unused-vars.asm index 3c1207f70..a05697471 100644 --- a/src/test/ref/unused-vars.asm +++ b/src/test/ref/unused-vars.asm @@ -4,6 +4,7 @@ .pc = $80d "Program" .label SCREEN = $400 main: { + // used vars .const col = 2 .label COLS = $d800 jsr s diff --git a/src/test/ref/unused-vars.log b/src/test/ref/unused-vars.log index 8c9a9d0c2..7241316cc 100644 --- a/src/test/ref/unused-vars.log +++ b/src/test/ref/unused-vars.log @@ -351,6 +351,7 @@ bend_from_b2: bend: //SEG10 main main: { + // used vars .const col = 2 .label COLS = $d800 .label i = 2 @@ -443,6 +444,7 @@ bend_from_b2: bend: //SEG10 main main: { + // used vars .const col = 2 .label COLS = $d800 //SEG11 [5] call s @@ -569,6 +571,7 @@ Score: 243 //SEG9 @end //SEG10 main main: { + // used vars .const col = 2 .label COLS = $d800 //SEG11 [5] call s diff --git a/src/test/ref/voronoi.asm b/src/test/ref/voronoi.asm index 76354b30b..175416dd7 100644 --- a/src/test/ref/voronoi.asm +++ b/src/test/ref/voronoi.asm @@ -5,6 +5,7 @@ .label SCREEN = $400 .label COLORS = $d800 .const FILL = $e6 + // The total number of voronoi points .const numpoints = 6 main: { jsr initscreen diff --git a/src/test/ref/voronoi.log b/src/test/ref/voronoi.log index 4ceda3a3d..160a1dde7 100644 --- a/src/test/ref/voronoi.log +++ b/src/test/ref/voronoi.log @@ -1208,6 +1208,7 @@ INITIAL ASM .label SCREEN = $400 .label COLORS = $d800 .const FILL = $e6 + // The total number of voronoi points .const numpoints = 6 //SEG3 @begin bbegin: @@ -1834,6 +1835,7 @@ ASSEMBLER BEFORE OPTIMIZATION .label SCREEN = $400 .label COLORS = $d800 .const FILL = $e6 + // The total number of voronoi points .const numpoints = 6 //SEG3 @begin bbegin: @@ -2529,6 +2531,7 @@ Score: 1628771 .label SCREEN = $400 .label COLORS = $d800 .const FILL = $e6 + // The total number of voronoi points .const numpoints = 6 //SEG3 @begin //SEG4 [1] phi from @begin to @5 [phi:@begin->@5]