diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFormat.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFormat.java index a42d039fe..df441531b 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFormat.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFormat.java @@ -78,7 +78,7 @@ public class AsmFormat { } } else if(Operators.CAST_WORD.equals(operator) || Operators.CAST_SWORD.equals(operator) || Operators.CAST_PTRBY.equals(operator)) { SymbolType operandType = SymbolTypeInference.inferType(program.getScope(), operand); - if(SymbolType.isWord(operandType) || SymbolType.isSWord(operandType)) { + if(SymbolType.isWord(operandType) || SymbolType.isSWord(operandType) || SymbolType.isByte(operandType) || SymbolType.isSByte(operandType) || operandType instanceof SymbolTypePointer) { // No cast needed return getAsmConstant(program, operand, outerPrecedence, codeScope); } else { diff --git a/src/main/java/dk/camelot64/kickc/model/operators/Operator.java b/src/main/java/dk/camelot64/kickc/model/operators/Operator.java index f12206fdf..9e54fb4b4 100644 --- a/src/main/java/dk/camelot64/kickc/model/operators/Operator.java +++ b/src/main/java/dk/camelot64/kickc/model/operators/Operator.java @@ -17,14 +17,8 @@ public class Operator { this.asmOperator = asmOperator; } - // Constant Evaluation / Calculation (ParseTreeConstantEvaluator / Pass2ConstantIdentification / ConstantValueCalculator) - - // Type Inference (SymbolTypeInference) - // Constant ASM formatting (AsmFormat) - - public String getOperator() { return operator; } diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm index 960864388..115fdc60f 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm @@ -18,7 +18,7 @@ main: { sta FGCOL lda #BMM|DEN|RSEL|3 sta D011 - lda #($ffff&SCREEN)/$40|($ffff&BITMAP)/$400 + lda #SCREEN/$40|BITMAP/$400 sta D018 jsr init_screen jsr init_plot_tables diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log index ea73aea4d..d4bad7e21 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log @@ -4290,7 +4290,7 @@ main: { lda #BMM|DEN|RSEL|3 sta D011 //SEG12 [7] *((const byte*) D018#0) ← ((byte))((word))(const byte*) SCREEN#0/(byte/signed byte/word/signed word/dword/signed dword) 64|((word))(const byte*) BITMAP#0/(word/signed word/dword/signed dword) 1024 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 - lda #($ffff&SCREEN)/$40|($ffff&BITMAP)/$400 + lda #SCREEN/$40|BITMAP/$400 sta D018 //SEG13 [8] call init_screen param-assignment [ ] ( main:2 [ ] ) //SEG14 [180] phi from main to init_screen [phi:main->init_screen] @@ -5641,7 +5641,7 @@ main: { lda #BMM|DEN|RSEL|3 sta D011 //SEG12 [7] *((const byte*) D018#0) ← ((byte))((word))(const byte*) SCREEN#0/(byte/signed byte/word/signed word/dword/signed dword) 64|((word))(const byte*) BITMAP#0/(word/signed word/dword/signed dword) 1024 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 - lda #($ffff&SCREEN)/$40|($ffff&BITMAP)/$400 + lda #SCREEN/$40|BITMAP/$400 sta D018 //SEG13 [8] call init_screen param-assignment [ ] ( main:2 [ ] ) //SEG14 [180] phi from main to init_screen [phi:main->init_screen] @@ -7072,7 +7072,7 @@ main: { lda #BMM|DEN|RSEL|3 sta D011 //SEG12 [7] *((const byte*) D018#0) ← ((byte))((word))(const byte*) SCREEN#0/(byte/signed byte/word/signed word/dword/signed dword) 64|((word))(const byte*) BITMAP#0/(word/signed word/dword/signed dword) 1024 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 - lda #($ffff&SCREEN)/$40|($ffff&BITMAP)/$400 + lda #SCREEN/$40|BITMAP/$400 sta D018 //SEG13 [8] call init_screen param-assignment [ ] ( main:2 [ ] ) //SEG14 [180] phi from main to init_screen [phi:main->init_screen] diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm index 587900dde..4fa32cba9 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm @@ -19,7 +19,7 @@ main: { sta FGCOL lda #BMM|DEN|RSEL|3 sta D011 - lda #($ffff&SCREEN)/$40|($ffff&BITMAP)/$400 + lda #SCREEN/$40|BITMAP/$400 sta D018 jsr init_screen jsr init_plot_tables diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log index b5167baed..dc9eea742 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log @@ -1783,7 +1783,7 @@ main: { lda #BMM|DEN|RSEL|3 sta D011 //SEG12 [7] *((const byte*) D018#0) ← ((byte))((word))(const byte*) SCREEN#0/(byte/signed byte/word/signed word/dword/signed dword) 64|((word))(const byte*) BITMAP#0/(word/signed word/dword/signed dword) 1024 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 - lda #($ffff&SCREEN)/$40|($ffff&BITMAP)/$400 + lda #SCREEN/$40|BITMAP/$400 sta D018 //SEG13 [8] call init_screen param-assignment [ ] ( main:2 [ ] ) //SEG14 [63] phi from main to init_screen [phi:main->init_screen] @@ -2321,7 +2321,7 @@ main: { lda #BMM|DEN|RSEL|3 sta D011 //SEG12 [7] *((const byte*) D018#0) ← ((byte))((word))(const byte*) SCREEN#0/(byte/signed byte/word/signed word/dword/signed dword) 64|((word))(const byte*) BITMAP#0/(word/signed word/dword/signed dword) 1024 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 - lda #($ffff&SCREEN)/$40|($ffff&BITMAP)/$400 + lda #SCREEN/$40|BITMAP/$400 sta D018 //SEG13 [8] call init_screen param-assignment [ ] ( main:2 [ ] ) //SEG14 [63] phi from main to init_screen [phi:main->init_screen] @@ -2912,7 +2912,7 @@ main: { lda #BMM|DEN|RSEL|3 sta D011 //SEG12 [7] *((const byte*) D018#0) ← ((byte))((word))(const byte*) SCREEN#0/(byte/signed byte/word/signed word/dword/signed dword) 64|((word))(const byte*) BITMAP#0/(word/signed word/dword/signed dword) 1024 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 - lda #($ffff&SCREEN)/$40|($ffff&BITMAP)/$400 + lda #SCREEN/$40|BITMAP/$400 sta D018 //SEG13 [8] call init_screen param-assignment [ ] ( main:2 [ ] ) //SEG14 [63] phi from main to init_screen [phi:main->init_screen] diff --git a/src/test/java/dk/camelot64/kickc/test/ref/sinusgenscale8.asm b/src/test/java/dk/camelot64/kickc/test/ref/sinusgenscale8.asm index 9302efcab..cfe9bae96 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/sinusgenscale8.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/sinusgenscale8.asm @@ -19,7 +19,7 @@ sin8u_table: { .const min = $a .const max = $ff .label amplitude = max-min - .const sum = ($ffff&min)+max + .const sum = min+max .const mid = (sum>>1)+1 .label step = $12 .label sinx = $11 diff --git a/src/test/java/dk/camelot64/kickc/test/ref/sinusgenscale8.log b/src/test/java/dk/camelot64/kickc/test/ref/sinusgenscale8.log index 0a87262ce..50daf67f6 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/sinusgenscale8.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/sinusgenscale8.log @@ -7071,7 +7071,7 @@ sin8u_table: { .const min = $a .const max = $ff .label amplitude = max-min - .const sum = ($ffff&min)+max + .const sum = min+max .const mid = (sum>>1)+1 .label _21 = $39 .label step = $30 @@ -8770,7 +8770,7 @@ sin8u_table: { .const min = $a .const max = $ff .label amplitude = max-min - .const sum = ($ffff&min)+max + .const sum = min+max .const mid = (sum>>1)+1 .label step = $12 .label sinx = $11 @@ -10674,7 +10674,7 @@ sin8u_table: { .const min = $a .const max = $ff .label amplitude = max-min - .const sum = ($ffff&min)+max + .const sum = min+max .const mid = (sum>>1)+1 .label step = $12 .label sinx = $11