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

Fixed const casting problem

This commit is contained in:
jespergravgaard 2018-03-11 21:45:26 +01:00
parent 979cb91eeb
commit f212c55c02
8 changed files with 13 additions and 19 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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