1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-23 23:32:55 +00:00

Added comments to variables identified as constants.

This commit is contained in:
jespergravgaard 2019-02-17 18:21:16 +01:00
parent b8ab7c6c49
commit f0d77acb29
37 changed files with 262 additions and 29 deletions

View File

@ -38,7 +38,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization {
*/
@Override
public boolean step() {
Map<VariableRef, ConstantValue> constants = findConstantVariables();
Map<VariableRef, ConstantVariableValue> constants = findConstantVariables();
LinkedHashMap<VariableRef, RValue> constAliases = new LinkedHashMap<>();
// Update symbol table with the constant value
Set<VariableRef> 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<VariableRef, ConstantValue> findConstantVariables() {
final Map<VariableRef, ConstantValue> constants = new LinkedHashMap<>();
private Map<VariableRef, ConstantVariableValue> findConstantVariables() {
final Map<VariableRef, ConstantVariableValue> 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<VariableRef, ConstantValue> constants, StatementPhiBlock phi) {
private void findConstantsPhi(Map<VariableRef, ConstantVariableValue> 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<VariableRef, ConstantValue> constants, StatementAssignment assignment) {
private void findConstantsAssignment(Map<VariableRef, ConstantVariableValue> 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));
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -10,6 +10,7 @@ main: {
rts
}
lvaluevar: {
// LValue Variable pointer dereference
.const b = 4
.label screen = 2
lda #<$400

View File

@ -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]

View File

@ -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: {

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -4,6 +4,7 @@
.pc = $80d "Program"
.label SCREEN = $400
main: {
// used vars
.const col = 2
.label COLS = $d800
jsr s

View File

@ -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

View File

@ -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

View File

@ -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]