diff --git a/src/main/java/dk/camelot64/kickc/model/DirectiveParserContext.java b/src/main/java/dk/camelot64/kickc/model/DirectiveParserContext.java index 7184f7124..e87293901 100644 --- a/src/main/java/dk/camelot64/kickc/model/DirectiveParserContext.java +++ b/src/main/java/dk/camelot64/kickc/model/DirectiveParserContext.java @@ -129,17 +129,26 @@ public class DirectiveParserContext { public DirectiveParserContext() { this.statementDirectives = null; // Setup default directives - this.defaultDirectives = new ArrayList<>(); - this.defaultDirectives.add(new Directive.MemoryArea(SymbolVariable.MemoryArea.ZEROPAGE_MEMORY, null)); - this.defaultDirectives.add(new Directive.FormSsa(true)); - this.defaultDirectives.add(new Directive.Const(SymbolVariable.ConstantDeclaration.MAYBE_CONST)); + this.defaultDirectives = Arrays.asList( + new Directive.MemoryArea(SymbolVariable.MemoryArea.ZEROPAGE_MEMORY, null), + new Directive.FormSsa(true), + new Directive.Const(SymbolVariable.ConstantDeclaration.MAYBE_CONST) + ); this.registerImpliesDirectives = new ArrayList<>(); this.typeDirectives = new HashMap<>(); - this.typeDirectives.put(DirectiveType.ARRAY, Arrays.asList(new Directive.Const(SymbolVariable.ConstantDeclaration.CONST), new Directive.MemoryArea(SymbolVariable.MemoryArea.MAIN_MEMORY, null))); - //this.typeDirectives.put(DirectiveType.POINTER, Arrays.asList(new Directive.MemoryArea(SymbolVariable.MemoryArea.ZEROPAGE_MEMORY, null))); + this.typeDirectives.put(DirectiveType.ARRAY, Arrays.asList( + new Directive.Const(SymbolVariable.ConstantDeclaration.CONST), + new Directive.MemoryArea(SymbolVariable.MemoryArea.MAIN_MEMORY, null) + )); + this.typeDirectives.put(DirectiveType.POINTER, Arrays.asList( + new Directive.MemoryArea(SymbolVariable.MemoryArea.ZEROPAGE_MEMORY, null) + )); this.scopeDirectives = new HashMap<>(); + //this.scopeDirectives.put(DirectiveScope.GLOBAL, Arrays.asList( + // new Directive.MemoryArea(SymbolVariable.MemoryArea.MAIN_MEMORY, null), + // new Directive.FormSsa(false) + //)); this.scopeTypeDirectives = new HashMap<>(); - //this.scopeDirectives.put(DirectiveScope.GLOBAL, Arrays.asList(new Directive.MemoryArea(SymbolVariable.MemoryArea.MAIN_MEMORY, null), new Directive.FormSsa(false))); } /** @@ -158,7 +167,7 @@ public class DirectiveParserContext { if(ssaDirective != null) { if(ssaDirective.ssa) { lValue.setStorageStrategy(SymbolVariable.StorageStrategy.PHI_MASTER); - } else { + } else { lValue.setStorageStrategy(SymbolVariable.StorageStrategy.LOAD_STORE); } } @@ -201,7 +210,7 @@ public class DirectiveParserContext { Registers.Register register = new Registers.RegisterZpMem(memoryAreaDirective.address.intValue(), -1, true); lValue.setDeclaredRegister(register); } else { - Registers.Register register = new Registers.RegisterMainMem((VariableRef)lValue.getRef(), -1, memoryAreaDirective.address); + Registers.Register register = new Registers.RegisterMainMem((VariableRef) lValue.getRef(), -1, memoryAreaDirective.address); lValue.setDeclaredRegister(register); } } diff --git a/src/test/kc/sinusgen8.kc b/src/test/kc/sinusgen8.kc index d1ec8c014..945572ea2 100644 --- a/src/test/kc/sinusgen8.kc +++ b/src/test/kc/sinusgen8.kc @@ -1,24 +1,25 @@ import "sinus.kc" import "print.kc" +word wavelength = 192; +signed byte[192] sintab2; +// .fill $c0, round(127.5*sin(i*2*PI/$c0)) +byte[] sintabref = { + $00, $04, $08, $0c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, + $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, + $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, + $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, + $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, + $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $0c, $08, $04, + $00, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, + $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, + $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, + $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, + $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, + $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc +}; + void main() { - word wavelength = 192; - signed byte[192] sintab2; - // .fill $c0, round(127.5*sin(i*2*PI/$c0)) - byte[] sintabref = { - $00, $04, $08, $0c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, - $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, - $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, - $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, - $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, - $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $0c, $08, $04, - $00, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, - $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, - $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, - $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, - $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, - $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc - }; sin8s_gen(sintab2, wavelength); print_cls(); for(byte i: 0..191) { diff --git a/src/test/ref/sinusgen8.asm b/src/test/ref/sinusgen8.asm index 3b374bd90..efe67d521 100644 --- a/src/test/ref/sinusgen8.asm +++ b/src/test/ref/sinusgen8.asm @@ -8,9 +8,9 @@ // PI/2 in u[4.12] format .const PI_HALF_u4f12 = $1922 .label print_line_cursor = $400 + .const wavelength = $c0 .label print_char_cursor = 2 main: { - .label wavelength = $c0 jsr sin8s_gen jsr print_cls lda #main.sintab2 + lda #>sintab2 sta.z sintab+1 lda #<0 sta.z x @@ -170,11 +167,11 @@ sin8s_gen: { // u[4.12] __b1: lda.z i+1 - cmp #>main.wavelength + cmp #>wavelength bcc __b2 bne !+ lda.z i - cmp #main.wavelength + cmp #>wavelength bcc __b3 bne !+ lda.z rem - cmp #main.wavelength + sbc #>wavelength sta.z rem+1 __b3: inx @@ -441,3 +438,6 @@ divr16u: { rts } print_hextab: .text "0123456789abcdef" + sintab2: .fill $c0, 0 + // .fill $c0, round(127.5*sin(i*2*PI/$c0)) + sintabref: .byte 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc diff --git a/src/test/ref/sinusgen8.cfg b/src/test/ref/sinusgen8.cfg index 6e67474ca..66ebf8937 100644 --- a/src/test/ref/sinusgen8.cfg +++ b/src/test/ref/sinusgen8.cfg @@ -20,7 +20,7 @@ main::@2: scope:[main] from main main::@1: scope:[main] from main::@2 main::@4 [8] (byte*) print_char_cursor#42 ← phi( main::@2/(const byte*) print_line_cursor#0 main::@4/(byte*) print_char_cursor#19 ) [8] (byte) main::i#2 ← phi( main::@2/(byte) 0 main::@4/(byte) main::i#1 ) - [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) main::sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) main::sintabref + (byte) main::i#2) + [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) sintabref + (byte) main::i#2) [10] (signed byte) print_sbyte::b#1 ← (signed byte) main::sb#0 [11] call print_sbyte to:main::@3 @@ -139,10 +139,10 @@ sin8s_gen::@3: scope:[sin8s_gen] from sin8s_gen [57] (word) sin8s_gen::step#0 ← (word) div16u::return#2 to:sin8s_gen::@1 sin8s_gen::@1: scope:[sin8s_gen] from sin8s_gen::@3 sin8s_gen::@4 - [58] (signed byte*) sin8s_gen::sintab#2 ← phi( sin8s_gen::@3/(const signed byte[$c0]) main::sintab2 sin8s_gen::@4/(signed byte*) sin8s_gen::sintab#0 ) + [58] (signed byte*) sin8s_gen::sintab#2 ← phi( sin8s_gen::@3/(const signed byte[$c0]) sintab2 sin8s_gen::@4/(signed byte*) sin8s_gen::sintab#0 ) [58] (word) sin8s_gen::x#2 ← phi( sin8s_gen::@3/(byte) 0 sin8s_gen::@4/(word) sin8s_gen::x#1 ) [58] (word) sin8s_gen::i#2 ← phi( sin8s_gen::@3/(byte) 0 sin8s_gen::@4/(word) sin8s_gen::i#1 ) - [59] if((word) sin8s_gen::i#2<(const word) main::wavelength) goto sin8s_gen::@2 + [59] if((word) sin8s_gen::i#2<(const word) wavelength) goto sin8s_gen::@2 to:sin8s_gen::@return sin8s_gen::@return: scope:[sin8s_gen] from sin8s_gen::@1 [60] return @@ -317,11 +317,11 @@ divr16u::@2: scope:[divr16u] from divr16u::@1 divr16u::@4 [143] (word) divr16u::rem#5 ← phi( divr16u::@1/(word) divr16u::rem#0 divr16u::@4/(word) divr16u::rem#1 ) [144] (word) divr16u::dividend#0 ← (word) divr16u::dividend#2 << (byte) 1 [145] (word) divr16u::quotient#1 ← (word) divr16u::quotient#3 << (byte) 1 - [146] if((word) divr16u::rem#5<(const word) main::wavelength) goto divr16u::@3 + [146] if((word) divr16u::rem#5<(const word) wavelength) goto divr16u::@3 to:divr16u::@5 divr16u::@5: scope:[divr16u] from divr16u::@2 [147] (word) divr16u::quotient#2 ← ++ (word) divr16u::quotient#1 - [148] (word) divr16u::rem#2 ← (word) divr16u::rem#5 - (const word) main::wavelength + [148] (word) divr16u::rem#2 ← (word) divr16u::rem#5 - (const word) wavelength to:divr16u::@3 divr16u::@3: scope:[divr16u] from divr16u::@2 divr16u::@5 [149] (word) divr16u::return#0 ← phi( divr16u::@2/(word) divr16u::quotient#1 divr16u::@5/(word) divr16u::quotient#2 ) diff --git a/src/test/ref/sinusgen8.log b/src/test/ref/sinusgen8.log index 2afb91557..03e3327ac 100644 --- a/src/test/ref/sinusgen8.log +++ b/src/test/ref/sinusgen8.log @@ -12,7 +12,7 @@ Warning! Adding boolean cast to non-boolean condition *((byte*) print_str::str) Warning! Adding boolean cast to non-boolean condition *((byte*) print_str_at::str) Warning! Adding boolean cast to non-boolean sub-expression (byte) print_str_lines::ch Identified constant variable (byte*) HEAP_TOP -Identified constant variable (word) main::wavelength +Identified constant variable (word) wavelength Culled Empty Block (label) @1 Culled Empty Block (label) @2 Culled Empty Block (label) divr16u::@7 @@ -87,7 +87,6 @@ Culled Empty Block (label) @52 Culled Empty Block (label) @53 Culled Empty Block (label) @54 Culled Empty Block (label) @55 -Culled Empty Block (label) @56 Culled Empty Block (label) main::@2 CONTROL FLOW GRAPH SSA @@ -580,11 +579,11 @@ print_sbyte::@return: scope:[print_sbyte] from print_sbyte::@7 return to:@return @49: scope:[] from @32 - (byte*) print_screen#6 ← phi( @32/(byte*) print_screen#0 ) - (byte*) print_char_cursor#47 ← phi( @32/(byte*) print_char_cursor#0 ) - (byte*) print_line_cursor#15 ← phi( @32/(byte*) print_line_cursor#0 ) + (byte*) print_screen#7 ← phi( @32/(byte*) print_screen#0 ) + (byte*) print_char_cursor#48 ← phi( @32/(byte*) print_char_cursor#0 ) + (byte*) print_line_cursor#16 ← phi( @32/(byte*) print_line_cursor#0 ) (byte[]) print_hextab ← (const string) $0 - to:@57 + to:@56 (void()) print_byte((byte) print_byte::b) print_byte: scope:[print_byte] from print_sbyte::@2 @@ -646,17 +645,22 @@ print_cls::@return: scope:[print_cls] from print_cls::@1 (byte*) print_char_cursor#13 ← (byte*) print_char_cursor#30 return to:@return +@56: scope:[] from @49 + (byte*) print_screen#6 ← phi( @49/(byte*) print_screen#7 ) + (byte*) print_char_cursor#47 ← phi( @49/(byte*) print_char_cursor#48 ) + (byte*) print_line_cursor#15 ← phi( @49/(byte*) print_line_cursor#16 ) + (word) wavelength ← (number) $c0 + (signed byte[$c0]) sintab2 ← { fill( $c0, 0) } + (byte[]) sintabref ← { (number) 0, (number) 4, (number) 8, (number) $c, (number) $11, (number) $15, (number) $19, (number) $1d, (number) $21, (number) $25, (number) $29, (number) $2d, (number) $31, (number) $35, (number) $38, (number) $3c, (number) $40, (number) $43, (number) $47, (number) $4a, (number) $4e, (number) $51, (number) $54, (number) $57, (number) $5a, (number) $5d, (number) $60, (number) $63, (number) $65, (number) $68, (number) $6a, (number) $6c, (number) $6e, (number) $70, (number) $72, (number) $74, (number) $76, (number) $77, (number) $79, (number) $7a, (number) $7b, (number) $7c, (number) $7d, (number) $7e, (number) $7e, (number) $7f, (number) $7f, (number) $7f, (number) $80, (number) $7f, (number) $7f, (number) $7f, (number) $7e, (number) $7e, (number) $7d, (number) $7c, (number) $7b, (number) $7a, (number) $79, (number) $77, (number) $76, (number) $74, (number) $72, (number) $70, (number) $6e, (number) $6c, (number) $6a, (number) $68, (number) $65, (number) $63, (number) $60, (number) $5d, (number) $5a, (number) $57, (number) $54, (number) $51, (number) $4e, (number) $4a, (number) $47, (number) $43, (number) $40, (number) $3c, (number) $38, (number) $35, (number) $31, (number) $2d, (number) $29, (number) $25, (number) $21, (number) $1d, (number) $19, (number) $15, (number) $11, (number) $c, (number) 8, (number) 4, (number) 0, (number) $fc, (number) $f8, (number) $f4, (number) $ef, (number) $eb, (number) $e7, (number) $e3, (number) $df, (number) $db, (number) $d7, (number) $d3, (number) $cf, (number) $cb, (number) $c8, (number) $c4, (number) $c0, (number) $bd, (number) $b9, (number) $b6, (number) $b2, (number) $af, (number) $ac, (number) $a9, (number) $a6, (number) $a3, (number) $a0, (number) $9d, (number) $9b, (number) $98, (number) $96, (number) $94, (number) $92, (number) $90, (number) $8e, (number) $8c, (number) $8a, (number) $89, (number) $87, (number) $86, (number) $85, (number) $84, (number) $83, (number) $82, (number) $82, (number) $81, (number) $81, (number) $81, (number) $81, (number) $81, (number) $81, (number) $81, (number) $82, (number) $82, (number) $83, (number) $84, (number) $85, (number) $86, (number) $87, (number) $89, (number) $8a, (number) $8c, (number) $8e, (number) $90, (number) $92, (number) $94, (number) $96, (number) $98, (number) $9b, (number) $9d, (number) $a0, (number) $a3, (number) $a6, (number) $a9, (number) $ac, (number) $af, (number) $b2, (number) $b6, (number) $b9, (number) $bd, (number) $c0, (number) $c4, (number) $c8, (number) $cb, (number) $cf, (number) $d3, (number) $d7, (number) $db, (number) $df, (number) $e3, (number) $e7, (number) $eb, (number) $ef, (number) $f4, (number) $f8, (number) $fc } + to:@57 (void()) main() main: scope:[main] from @57 (byte*) print_char_cursor#46 ← phi( @57/(byte*) print_char_cursor#43 ) (byte*) print_line_cursor#13 ← phi( @57/(byte*) print_line_cursor#12 ) (byte*) print_screen#4 ← phi( @57/(byte*) print_screen#5 ) - (word) main::wavelength ← (number) $c0 - (signed byte[$c0]) main::sintab2 ← { fill( $c0, 0) } - (byte[]) main::sintabref ← { (number) 0, (number) 4, (number) 8, (number) $c, (number) $11, (number) $15, (number) $19, (number) $1d, (number) $21, (number) $25, (number) $29, (number) $2d, (number) $31, (number) $35, (number) $38, (number) $3c, (number) $40, (number) $43, (number) $47, (number) $4a, (number) $4e, (number) $51, (number) $54, (number) $57, (number) $5a, (number) $5d, (number) $60, (number) $63, (number) $65, (number) $68, (number) $6a, (number) $6c, (number) $6e, (number) $70, (number) $72, (number) $74, (number) $76, (number) $77, (number) $79, (number) $7a, (number) $7b, (number) $7c, (number) $7d, (number) $7e, (number) $7e, (number) $7f, (number) $7f, (number) $7f, (number) $80, (number) $7f, (number) $7f, (number) $7f, (number) $7e, (number) $7e, (number) $7d, (number) $7c, (number) $7b, (number) $7a, (number) $79, (number) $77, (number) $76, (number) $74, (number) $72, (number) $70, (number) $6e, (number) $6c, (number) $6a, (number) $68, (number) $65, (number) $63, (number) $60, (number) $5d, (number) $5a, (number) $57, (number) $54, (number) $51, (number) $4e, (number) $4a, (number) $47, (number) $43, (number) $40, (number) $3c, (number) $38, (number) $35, (number) $31, (number) $2d, (number) $29, (number) $25, (number) $21, (number) $1d, (number) $19, (number) $15, (number) $11, (number) $c, (number) 8, (number) 4, (number) 0, (number) $fc, (number) $f8, (number) $f4, (number) $ef, (number) $eb, (number) $e7, (number) $e3, (number) $df, (number) $db, (number) $d7, (number) $d3, (number) $cf, (number) $cb, (number) $c8, (number) $c4, (number) $c0, (number) $bd, (number) $b9, (number) $b6, (number) $b2, (number) $af, (number) $ac, (number) $a9, (number) $a6, (number) $a3, (number) $a0, (number) $9d, (number) $9b, (number) $98, (number) $96, (number) $94, (number) $92, (number) $90, (number) $8e, (number) $8c, (number) $8a, (number) $89, (number) $87, (number) $86, (number) $85, (number) $84, (number) $83, (number) $82, (number) $82, (number) $81, (number) $81, (number) $81, (number) $81, (number) $81, (number) $81, (number) $81, (number) $82, (number) $82, (number) $83, (number) $84, (number) $85, (number) $86, (number) $87, (number) $89, (number) $8a, (number) $8c, (number) $8e, (number) $90, (number) $92, (number) $94, (number) $96, (number) $98, (number) $9b, (number) $9d, (number) $a0, (number) $a3, (number) $a6, (number) $a9, (number) $ac, (number) $af, (number) $b2, (number) $b6, (number) $b9, (number) $bd, (number) $c0, (number) $c4, (number) $c8, (number) $cb, (number) $cf, (number) $d3, (number) $d7, (number) $db, (number) $df, (number) $e3, (number) $e7, (number) $eb, (number) $ef, (number) $f4, (number) $f8, (number) $fc } - (signed byte*) sin8s_gen::sintab#1 ← (signed byte[$c0]) main::sintab2 - (word) sin8s_gen::wavelength#0 ← (word) main::wavelength + (signed byte*) sin8s_gen::sintab#1 ← (signed byte[$c0]) sintab2 + (word) sin8s_gen::wavelength#0 ← (word) wavelength call sin8s_gen to:main::@3 main::@3: scope:[main] from main @@ -673,17 +677,17 @@ main::@4: scope:[main] from main::@3 (byte) main::i#0 ← (byte) 0 to:main::@1 main::@1: scope:[main] from main::@4 main::@6 - (byte*) print_line_cursor#16 ← phi( main::@4/(byte*) print_line_cursor#3 main::@6/(byte*) print_line_cursor#11 ) + (byte*) print_line_cursor#17 ← phi( main::@4/(byte*) print_line_cursor#3 main::@6/(byte*) print_line_cursor#11 ) (byte*) print_char_cursor#42 ← phi( main::@4/(byte*) print_char_cursor#14 main::@6/(byte*) print_char_cursor#16 ) (byte) main::i#2 ← phi( main::@4/(byte) main::i#0 main::@6/(byte) main::i#1 ) - (signed byte~) main::$2 ← ((signed byte)) *((byte[]) main::sintabref + (byte) main::i#2) - (signed byte~) main::$3 ← *((signed byte[$c0]) main::sintab2 + (byte) main::i#2) - (signed byte~) main::$2 + (signed byte~) main::$2 ← ((signed byte)) *((byte[]) sintabref + (byte) main::i#2) + (signed byte~) main::$3 ← *((signed byte[$c0]) sintab2 + (byte) main::i#2) - (signed byte~) main::$2 (signed byte) main::sb#0 ← (signed byte~) main::$3 (signed byte) print_sbyte::b#1 ← (signed byte) main::sb#0 call print_sbyte to:main::@5 main::@5: scope:[main] from main::@1 - (byte*) print_line_cursor#14 ← phi( main::@1/(byte*) print_line_cursor#16 ) + (byte*) print_line_cursor#14 ← phi( main::@1/(byte*) print_line_cursor#17 ) (byte) main::i#4 ← phi( main::@1/(byte) main::i#2 ) (byte*) print_char_cursor#32 ← phi( main::@1/(byte*) print_char_cursor#6 ) (byte*) print_char_cursor#15 ← (byte*) print_char_cursor#32 @@ -706,10 +710,10 @@ main::@return: scope:[main] from main::@6 (byte*) print_char_cursor#17 ← (byte*) print_char_cursor#34 return to:@return -@57: scope:[] from @49 - (byte*) print_screen#5 ← phi( @49/(byte*) print_screen#6 ) - (byte*) print_char_cursor#43 ← phi( @49/(byte*) print_char_cursor#47 ) - (byte*) print_line_cursor#12 ← phi( @49/(byte*) print_line_cursor#15 ) +@57: scope:[] from @56 + (byte*) print_screen#5 ← phi( @56/(byte*) print_screen#6 ) + (byte*) print_char_cursor#43 ← phi( @56/(byte*) print_char_cursor#47 ) + (byte*) print_line_cursor#12 ← phi( @56/(byte*) print_line_cursor#15 ) call main to:@58 @58: scope:[] from @57 @@ -725,6 +729,7 @@ SYMBOL TABLE SSA (label) @13 (label) @32 (label) @49 +(label) @56 (label) @57 (label) @58 (label) @begin @@ -842,10 +847,7 @@ SYMBOL TABLE SSA (byte) main::i#4 (signed byte) main::sb (signed byte) main::sb#0 -(signed byte[$c0]) main::sintab2 -(byte[]) main::sintabref (const string) main::str = (string) " " -(word) main::wavelength (void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num) (bool~) memset::$0 (bool~) memset::$1 @@ -1038,6 +1040,7 @@ SYMBOL TABLE SSA (byte*) print_char_cursor#45 (byte*) print_char_cursor#46 (byte*) print_char_cursor#47 +(byte*) print_char_cursor#48 (byte*) print_char_cursor#5 (byte*) print_char_cursor#6 (byte*) print_char_cursor#7 @@ -1057,6 +1060,7 @@ SYMBOL TABLE SSA (byte*) print_line_cursor#14 (byte*) print_line_cursor#15 (byte*) print_line_cursor#16 +(byte*) print_line_cursor#17 (byte*) print_line_cursor#2 (byte*) print_line_cursor#3 (byte*) print_line_cursor#4 @@ -1093,6 +1097,7 @@ SYMBOL TABLE SSA (byte*) print_screen#4 (byte*) print_screen#5 (byte*) print_screen#6 +(byte*) print_screen#7 (void()) print_str((byte*) print_str::str) (bool~) print_str::$0 (label) print_str::@1 @@ -1245,6 +1250,9 @@ SYMBOL TABLE SSA (word) sin8s_gen::x#2 (word) sin8s_gen::x#3 (word) sin8s_gen::x#4 +(signed byte[$c0]) sintab2 +(byte[]) sintabref +(word) wavelength Adding number conversion cast (unumber) 0 in (word) divr16u::quotient#0 ← (number) 0 Adding number conversion cast (unumber) 1 in (word~) divr16u::$0 ← (word) divr16u::rem#4 << (number) 1 @@ -1287,9 +1295,9 @@ Adding number conversion cast (unumber) 4 in (byte~) print_byte::$0 ← (byte) p Adding number conversion cast (unumber) $f in (number~) print_byte::$2 ← (byte) print_byte::b#2 & (number) $f Adding number conversion cast (unumber) print_byte::$2 in (number~) print_byte::$2 ← (byte) print_byte::b#2 & (unumber)(number) $f Adding number conversion cast (unumber) $3e8 in (word) memset::num#0 ← (number) $3e8 -Adding number conversion cast (unumber) $c0 in (word) main::wavelength ← (number) $c0 +Adding number conversion cast (unumber) $c0 in (word) wavelength ← (number) $c0 Successful SSA optimization PassNAddNumberTypeConversions -Added casts to value list in (byte[]) main::sintabref ← (byte[]){ (byte)(number) 0, (byte)(number) 4, (byte)(number) 8, (byte)(number) $c, (byte)(number) $11, (byte)(number) $15, (byte)(number) $19, (byte)(number) $1d, (byte)(number) $21, (byte)(number) $25, (byte)(number) $29, (byte)(number) $2d, (byte)(number) $31, (byte)(number) $35, (byte)(number) $38, (byte)(number) $3c, (byte)(number) $40, (byte)(number) $43, (byte)(number) $47, (byte)(number) $4a, (byte)(number) $4e, (byte)(number) $51, (byte)(number) $54, (byte)(number) $57, (byte)(number) $5a, (byte)(number) $5d, (byte)(number) $60, (byte)(number) $63, (byte)(number) $65, (byte)(number) $68, (byte)(number) $6a, (byte)(number) $6c, (byte)(number) $6e, (byte)(number) $70, (byte)(number) $72, (byte)(number) $74, (byte)(number) $76, (byte)(number) $77, (byte)(number) $79, (byte)(number) $7a, (byte)(number) $7b, (byte)(number) $7c, (byte)(number) $7d, (byte)(number) $7e, (byte)(number) $7e, (byte)(number) $7f, (byte)(number) $7f, (byte)(number) $7f, (byte)(number) $80, (byte)(number) $7f, (byte)(number) $7f, (byte)(number) $7f, (byte)(number) $7e, (byte)(number) $7e, (byte)(number) $7d, (byte)(number) $7c, (byte)(number) $7b, (byte)(number) $7a, (byte)(number) $79, (byte)(number) $77, (byte)(number) $76, (byte)(number) $74, (byte)(number) $72, (byte)(number) $70, (byte)(number) $6e, (byte)(number) $6c, (byte)(number) $6a, (byte)(number) $68, (byte)(number) $65, (byte)(number) $63, (byte)(number) $60, (byte)(number) $5d, (byte)(number) $5a, (byte)(number) $57, (byte)(number) $54, (byte)(number) $51, (byte)(number) $4e, (byte)(number) $4a, (byte)(number) $47, (byte)(number) $43, (byte)(number) $40, (byte)(number) $3c, (byte)(number) $38, (byte)(number) $35, (byte)(number) $31, (byte)(number) $2d, (byte)(number) $29, (byte)(number) $25, (byte)(number) $21, (byte)(number) $1d, (byte)(number) $19, (byte)(number) $15, (byte)(number) $11, (byte)(number) $c, (byte)(number) 8, (byte)(number) 4, (byte)(number) 0, (byte)(number) $fc, (byte)(number) $f8, (byte)(number) $f4, (byte)(number) $ef, (byte)(number) $eb, (byte)(number) $e7, (byte)(number) $e3, (byte)(number) $df, (byte)(number) $db, (byte)(number) $d7, (byte)(number) $d3, (byte)(number) $cf, (byte)(number) $cb, (byte)(number) $c8, (byte)(number) $c4, (byte)(number) $c0, (byte)(number) $bd, (byte)(number) $b9, (byte)(number) $b6, (byte)(number) $b2, (byte)(number) $af, (byte)(number) $ac, (byte)(number) $a9, (byte)(number) $a6, (byte)(number) $a3, (byte)(number) $a0, (byte)(number) $9d, (byte)(number) $9b, (byte)(number) $98, (byte)(number) $96, (byte)(number) $94, (byte)(number) $92, (byte)(number) $90, (byte)(number) $8e, (byte)(number) $8c, (byte)(number) $8a, (byte)(number) $89, (byte)(number) $87, (byte)(number) $86, (byte)(number) $85, (byte)(number) $84, (byte)(number) $83, (byte)(number) $82, (byte)(number) $82, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $82, (byte)(number) $82, (byte)(number) $83, (byte)(number) $84, (byte)(number) $85, (byte)(number) $86, (byte)(number) $87, (byte)(number) $89, (byte)(number) $8a, (byte)(number) $8c, (byte)(number) $8e, (byte)(number) $90, (byte)(number) $92, (byte)(number) $94, (byte)(number) $96, (byte)(number) $98, (byte)(number) $9b, (byte)(number) $9d, (byte)(number) $a0, (byte)(number) $a3, (byte)(number) $a6, (byte)(number) $a9, (byte)(number) $ac, (byte)(number) $af, (byte)(number) $b2, (byte)(number) $b6, (byte)(number) $b9, (byte)(number) $bd, (byte)(number) $c0, (byte)(number) $c4, (byte)(number) $c8, (byte)(number) $cb, (byte)(number) $cf, (byte)(number) $d3, (byte)(number) $d7, (byte)(number) $db, (byte)(number) $df, (byte)(number) $e3, (byte)(number) $e7, (byte)(number) $eb, (byte)(number) $ef, (byte)(number) $f4, (byte)(number) $f8, (byte)(number) $fc } +Added casts to value list in (byte[]) sintabref ← (byte[]){ (byte)(number) 0, (byte)(number) 4, (byte)(number) 8, (byte)(number) $c, (byte)(number) $11, (byte)(number) $15, (byte)(number) $19, (byte)(number) $1d, (byte)(number) $21, (byte)(number) $25, (byte)(number) $29, (byte)(number) $2d, (byte)(number) $31, (byte)(number) $35, (byte)(number) $38, (byte)(number) $3c, (byte)(number) $40, (byte)(number) $43, (byte)(number) $47, (byte)(number) $4a, (byte)(number) $4e, (byte)(number) $51, (byte)(number) $54, (byte)(number) $57, (byte)(number) $5a, (byte)(number) $5d, (byte)(number) $60, (byte)(number) $63, (byte)(number) $65, (byte)(number) $68, (byte)(number) $6a, (byte)(number) $6c, (byte)(number) $6e, (byte)(number) $70, (byte)(number) $72, (byte)(number) $74, (byte)(number) $76, (byte)(number) $77, (byte)(number) $79, (byte)(number) $7a, (byte)(number) $7b, (byte)(number) $7c, (byte)(number) $7d, (byte)(number) $7e, (byte)(number) $7e, (byte)(number) $7f, (byte)(number) $7f, (byte)(number) $7f, (byte)(number) $80, (byte)(number) $7f, (byte)(number) $7f, (byte)(number) $7f, (byte)(number) $7e, (byte)(number) $7e, (byte)(number) $7d, (byte)(number) $7c, (byte)(number) $7b, (byte)(number) $7a, (byte)(number) $79, (byte)(number) $77, (byte)(number) $76, (byte)(number) $74, (byte)(number) $72, (byte)(number) $70, (byte)(number) $6e, (byte)(number) $6c, (byte)(number) $6a, (byte)(number) $68, (byte)(number) $65, (byte)(number) $63, (byte)(number) $60, (byte)(number) $5d, (byte)(number) $5a, (byte)(number) $57, (byte)(number) $54, (byte)(number) $51, (byte)(number) $4e, (byte)(number) $4a, (byte)(number) $47, (byte)(number) $43, (byte)(number) $40, (byte)(number) $3c, (byte)(number) $38, (byte)(number) $35, (byte)(number) $31, (byte)(number) $2d, (byte)(number) $29, (byte)(number) $25, (byte)(number) $21, (byte)(number) $1d, (byte)(number) $19, (byte)(number) $15, (byte)(number) $11, (byte)(number) $c, (byte)(number) 8, (byte)(number) 4, (byte)(number) 0, (byte)(number) $fc, (byte)(number) $f8, (byte)(number) $f4, (byte)(number) $ef, (byte)(number) $eb, (byte)(number) $e7, (byte)(number) $e3, (byte)(number) $df, (byte)(number) $db, (byte)(number) $d7, (byte)(number) $d3, (byte)(number) $cf, (byte)(number) $cb, (byte)(number) $c8, (byte)(number) $c4, (byte)(number) $c0, (byte)(number) $bd, (byte)(number) $b9, (byte)(number) $b6, (byte)(number) $b2, (byte)(number) $af, (byte)(number) $ac, (byte)(number) $a9, (byte)(number) $a6, (byte)(number) $a3, (byte)(number) $a0, (byte)(number) $9d, (byte)(number) $9b, (byte)(number) $98, (byte)(number) $96, (byte)(number) $94, (byte)(number) $92, (byte)(number) $90, (byte)(number) $8e, (byte)(number) $8c, (byte)(number) $8a, (byte)(number) $89, (byte)(number) $87, (byte)(number) $86, (byte)(number) $85, (byte)(number) $84, (byte)(number) $83, (byte)(number) $82, (byte)(number) $82, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $81, (byte)(number) $82, (byte)(number) $82, (byte)(number) $83, (byte)(number) $84, (byte)(number) $85, (byte)(number) $86, (byte)(number) $87, (byte)(number) $89, (byte)(number) $8a, (byte)(number) $8c, (byte)(number) $8e, (byte)(number) $90, (byte)(number) $92, (byte)(number) $94, (byte)(number) $96, (byte)(number) $98, (byte)(number) $9b, (byte)(number) $9d, (byte)(number) $a0, (byte)(number) $a3, (byte)(number) $a6, (byte)(number) $a9, (byte)(number) $ac, (byte)(number) $af, (byte)(number) $b2, (byte)(number) $b6, (byte)(number) $b9, (byte)(number) $bd, (byte)(number) $c0, (byte)(number) $c4, (byte)(number) $c8, (byte)(number) $cb, (byte)(number) $cf, (byte)(number) $d3, (byte)(number) $d7, (byte)(number) $db, (byte)(number) $df, (byte)(number) $e3, (byte)(number) $e7, (byte)(number) $eb, (byte)(number) $ef, (byte)(number) $f4, (byte)(number) $f8, (byte)(number) $fc } Successful SSA optimization PassNAddInitializerValueListTypeCasts Inlining cast (word) divr16u::quotient#0 ← (unumber)(number) 0 Inlining cast (word) divr16u::rem#3 ← (unumber)(number) 0 @@ -1314,8 +1322,8 @@ Inlining cast (byte*) memset::dst#0 ← (byte*)(void*) memset::str#2 Inlining cast (byte*) print_screen#0 ← (byte*)(number) $400 Inlining cast (byte~) print_sbyte::$1 ← (byte)(signed byte) print_sbyte::b#4 Inlining cast (word) memset::num#0 ← (unumber)(number) $3e8 -Inlining cast (word) main::wavelength ← (unumber)(number) $c0 -Inlining cast (signed byte~) main::$2 ← (signed byte)*((byte[]) main::sintabref + (byte) main::i#2) +Inlining cast (word) wavelength ← (unumber)(number) $c0 +Inlining cast (signed byte~) main::$2 ← (signed byte)*((byte[]) sintabref + (byte) main::i#2) Successful SSA optimization Pass2InlineCast Simplifying constant integer cast 0 Simplifying constant integer cast 1 @@ -1670,7 +1678,7 @@ Alias (byte) memset::c#1 = (byte) memset::c#2 Alias (byte*) memset::dst#2 = (byte*) memset::dst#3 Alias (byte*) memset::end#1 = (byte*) memset::end#2 Alias (void*) memset::str#4 = (void*) memset::str#5 -Alias (byte*) print_line_cursor#0 = (byte*) print_screen#0 (byte*) print_char_cursor#0 (byte*) print_line_cursor#15 (byte*) print_char_cursor#47 (byte*) print_screen#6 (byte*) print_line_cursor#12 (byte*) print_char_cursor#43 (byte*) print_screen#5 +Alias (byte*) print_line_cursor#0 = (byte*) print_screen#0 (byte*) print_char_cursor#0 (byte*) print_line_cursor#16 (byte*) print_char_cursor#48 (byte*) print_screen#7 (byte*) print_line_cursor#15 (byte*) print_char_cursor#47 (byte*) print_screen#6 (byte*) print_line_cursor#12 (byte*) print_char_cursor#43 (byte*) print_screen#5 Alias (byte*) print_str::str#2 = (byte*) print_str::str#3 Alias (byte*) print_char_cursor#19 = (byte*) print_char_cursor#36 (byte*) print_char_cursor#20 (byte*) print_char_cursor#2 Alias (byte*) print_char_cursor#37 = (byte*) print_char_cursor#45 (byte*) print_char_cursor#38 @@ -1692,7 +1700,7 @@ Alias (byte*) print_line_cursor#3 = (byte*) print_line_cursor#7 Alias (byte*) print_char_cursor#14 = (byte*) print_char_cursor#31 Alias (signed byte) main::sb#0 = (signed byte~) main::$3 Alias (byte) main::i#2 = (byte) main::i#4 (byte) main::i#3 -Alias (byte*) print_line_cursor#11 = (byte*) print_line_cursor#14 (byte*) print_line_cursor#16 (byte*) print_line_cursor#8 (byte*) print_line_cursor#4 +Alias (byte*) print_line_cursor#11 = (byte*) print_line_cursor#14 (byte*) print_line_cursor#17 (byte*) print_line_cursor#8 (byte*) print_line_cursor#4 Alias (byte*) print_char_cursor#15 = (byte*) print_char_cursor#32 Alias (byte*) print_char_cursor#16 = (byte*) print_char_cursor#33 (byte*) print_char_cursor#34 (byte*) print_char_cursor#17 Alias (byte*) print_line_cursor#5 = (byte*) print_line_cursor#9 @@ -1766,9 +1774,9 @@ Simple Condition (bool~) memset::$1 [202] if((word) memset::num#0<=(byte) 0) got Simple Condition (bool~) memset::$4 [212] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@5 Simple Condition (bool~) print_str::$0 [225] if((byte) 0!=*((byte*) print_str::str#2)) goto print_str::@2 Simple Condition (bool~) print_sbyte::$0 [235] if((signed byte) print_sbyte::b#1<(signed byte) 0) goto print_sbyte::@1 -Simple Condition (bool~) main::$6 [319] if((byte) main::i#1!=rangelast(0,$bf)) goto main::@1 +Simple Condition (bool~) main::$6 [320] if((byte) main::i#1!=rangelast(0,$bf)) goto main::@1 Successful SSA optimization Pass2ConditionalJumpSimplification -Constant right-side identified [294] (signed byte[$c0]) main::sintab2 ← { fill( $c0, 0) } +Constant right-side identified [294] (signed byte[$c0]) sintab2 ← { fill( $c0, 0) } Successful SSA optimization Pass2ConstantRValueConsolidation Identified constant from value list (byte[]) { (byte) 0, (byte) 4, (byte) 8, (byte) $c, (byte) $11, (byte) $15, (byte) $19, (byte) $1d, (byte) $21, (byte) $25, (byte) $29, (byte) $2d, (byte) $31, (byte) $35, (byte) $38, (byte) $3c, (byte) $40, (byte) $43, (byte) $47, (byte) $4a, (byte) $4e, (byte) $51, (byte) $54, (byte) $57, (byte) $5a, (byte) $5d, (byte) $60, (byte) $63, (byte) $65, (byte) $68, (byte) $6a, (byte) $6c, (byte) $6e, (byte) $70, (byte) $72, (byte) $74, (byte) $76, (byte) $77, (byte) $79, (byte) $7a, (byte) $7b, (byte) $7c, (byte) $7d, (byte) $7e, (byte) $7e, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $80, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $7e, (byte) $7e, (byte) $7d, (byte) $7c, (byte) $7b, (byte) $7a, (byte) $79, (byte) $77, (byte) $76, (byte) $74, (byte) $72, (byte) $70, (byte) $6e, (byte) $6c, (byte) $6a, (byte) $68, (byte) $65, (byte) $63, (byte) $60, (byte) $5d, (byte) $5a, (byte) $57, (byte) $54, (byte) $51, (byte) $4e, (byte) $4a, (byte) $47, (byte) $43, (byte) $40, (byte) $3c, (byte) $38, (byte) $35, (byte) $31, (byte) $2d, (byte) $29, (byte) $25, (byte) $21, (byte) $1d, (byte) $19, (byte) $15, (byte) $11, (byte) $c, (byte) 8, (byte) 4, (byte) 0, (byte) $fc, (byte) $f8, (byte) $f4, (byte) $ef, (byte) $eb, (byte) $e7, (byte) $e3, (byte) $df, (byte) $db, (byte) $d7, (byte) $d3, (byte) $cf, (byte) $cb, (byte) $c8, (byte) $c4, (byte) $c0, (byte) $bd, (byte) $b9, (byte) $b6, (byte) $b2, (byte) $af, (byte) $ac, (byte) $a9, (byte) $a6, (byte) $a3, (byte) $a0, (byte) $9d, (byte) $9b, (byte) $98, (byte) $96, (byte) $94, (byte) $92, (byte) $90, (byte) $8e, (byte) $8c, (byte) $8a, (byte) $89, (byte) $87, (byte) $86, (byte) $85, (byte) $84, (byte) $83, (byte) $82, (byte) $82, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $82, (byte) $82, (byte) $83, (byte) $84, (byte) $85, (byte) $86, (byte) $87, (byte) $89, (byte) $8a, (byte) $8c, (byte) $8e, (byte) $90, (byte) $92, (byte) $94, (byte) $96, (byte) $98, (byte) $9b, (byte) $9d, (byte) $a0, (byte) $a3, (byte) $a6, (byte) $a9, (byte) $ac, (byte) $af, (byte) $b2, (byte) $b6, (byte) $b9, (byte) $bd, (byte) $c0, (byte) $c4, (byte) $c8, (byte) $cb, (byte) $cf, (byte) $d3, (byte) $d7, (byte) $db, (byte) $df, (byte) $e3, (byte) $e7, (byte) $eb, (byte) $ef, (byte) $f4, (byte) $f8, (byte) $fc } Successful SSA optimization Pass2ConstantInitializerValueLists @@ -1795,17 +1803,17 @@ Constant (const byte) print_char::ch#1 = ' ' Constant (const byte[]) print_hextab = $0 Constant (const byte) memset::c#0 = ' ' Constant (const word) memset::num#0 = $3e8 -Constant (const word) main::wavelength = $c0 -Constant (const signed byte[$c0]) main::sintab2 = { fill( $c0, 0) } -Constant (const byte[]) main::sintabref = { 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc } +Constant (const word) wavelength = $c0 +Constant (const signed byte[$c0]) sintab2 = { fill( $c0, 0) } +Constant (const byte[]) sintabref = { 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc } Constant (const byte) main::i#0 = 0 Constant (const byte*) print_str::str#1 = main::str Successful SSA optimization Pass2ConstantIdentification Constant (const word) div16u::dividend#0 = PI2_u4f12 Constant (const byte) mulu8_sel::v2#2 = sin8s::DIV_6 Constant (const void*) memset::str#0 = (void*)print_line_cursor#0 -Constant (const signed byte*) sin8s_gen::sintab#1 = main::sintab2 -Constant (const word) sin8s_gen::wavelength#0 = main::wavelength +Constant (const signed byte*) sin8s_gen::sintab#1 = sintab2 +Constant (const word) sin8s_gen::wavelength#0 = wavelength Successful SSA optimization Pass2ConstantIdentification Constant (const word) divr16u::dividend#1 = div16u::dividend#0 Constant (const word) div16u::divisor#0 = sin8s_gen::wavelength#0 @@ -1819,8 +1827,8 @@ if() condition always false - eliminating [202] if((const word) memset::num#0<=( Successful SSA optimization Pass2ConstantIfs Resolved ranged next value [23] divr16u::i#1 ← ++ divr16u::i#2 to ++ Resolved ranged comparison value [25] if(divr16u::i#1!=rangelast(0,$f)) goto divr16u::@1 to (number) $10 -Resolved ranged next value [317] main::i#1 ← ++ main::i#2 to ++ -Resolved ranged comparison value [319] if(main::i#1!=rangelast(0,$bf)) goto main::@1 to (number) $c0 +Resolved ranged next value [318] main::i#1 ← ++ main::i#2 to ++ +Resolved ranged comparison value [320] if(main::i#1!=rangelast(0,$bf)) goto main::@1 to (number) $c0 Eliminating unused constant (const void*) memset::return#2 Successful SSA optimization PassNEliminateUnusedVars Adding number conversion cast (unumber) $10 in if((byte) divr16u::i#1!=(number) $10) goto divr16u::@1 @@ -1838,7 +1846,7 @@ Constant (const byte*) memset::end#0 = memset::$2+memset::num#0 Successful SSA optimization Pass2ConstantIdentification Inlining Noop Cast [80] (signed byte) sin8s::sinx#0 ← (signed byte)(byte) sin8s::usinx#4 keeping sin8s::usinx#4 Inlining Noop Cast [84] (signed byte~) sin8s::$21 ← (signed byte)(byte) sin8s::usinx#4 keeping sin8s::usinx#4 -Inlining Noop Cast [131] (signed byte~) main::$2 ← (signed byte)*((const byte[]) main::sintabref + (byte) main::i#2) keeping *(main::sintabref + main::i#2) +Inlining Noop Cast [131] (signed byte~) main::$2 ← (signed byte)*((const byte[]) sintabref + (byte) main::i#2) keeping *(sintabref + main::i#2) Successful SSA optimization Pass2NopCastInlining Inlining constant with var siblings (const word) divr16u::quotient#0 Inlining constant with var siblings (const byte) divr16u::i#0 @@ -1869,12 +1877,12 @@ Constant inlined sin8s::isUpper#0 = (byte) 0 Constant inlined sin8s_gen::x#0 = (byte) 0 Constant inlined memset::$2 = (byte*)(const void*) memset::str#0 Constant inlined divr16u::quotient#0 = (byte) 0 -Constant inlined div16u::divisor#0 = (const word) main::wavelength +Constant inlined div16u::divisor#0 = (const word) wavelength Constant inlined main::i#0 = (byte) 0 Constant inlined mulu8_sel::select#0 = (byte) 0 Constant inlined div16u::dividend#0 = (const word) PI2_u4f12 Constant inlined mulu8_sel::select#2 = (byte) 1 -Constant inlined divr16u::divisor#0 = (const word) main::wavelength +Constant inlined divr16u::divisor#0 = (const word) wavelength Constant inlined mulu8_sel::select#1 = (byte) 1 Constant inlined mulu8_sel::select#4 = (byte) 0 Constant inlined mulu8_sel::select#3 = (byte) 0 @@ -1883,8 +1891,8 @@ Constant inlined mulu8_sel::v2#2 = (const byte) sin8s::DIV_6 Constant inlined mul8u::res#0 = (byte) 0 Constant inlined print_char::ch#1 = (byte) ' ' Constant inlined print_char::ch#0 = (byte) '-' -Constant inlined sin8s_gen::sintab#1 = (const signed byte[$c0]) main::sintab2 -Constant inlined sin8s_gen::wavelength#0 = (const word) main::wavelength +Constant inlined sin8s_gen::sintab#1 = (const signed byte[$c0]) sintab2 +Constant inlined sin8s_gen::wavelength#0 = (const word) wavelength Constant inlined memset::dst#0 = (byte*)(const void*) memset::str#0 Constant inlined print_str::str#1 = (const string) main::str Constant inlined sin8s_gen::i#0 = (byte) 0 @@ -1903,6 +1911,7 @@ Adding NOP phi() at start of @begin Adding NOP phi() at start of @13 Adding NOP phi() at start of @32 Adding NOP phi() at start of @49 +Adding NOP phi() at start of @56 Adding NOP phi() at start of @57 Adding NOP phi() at start of @58 Adding NOP phi() at start of @end @@ -1923,71 +1932,72 @@ Adding NOP phi() at start of div16u Adding NOP phi() at start of divr16u Adding NOP phi() at start of divr16u::@6 CALL GRAPH -Calls in [] to main:5 -Calls in [main] to sin8s_gen:9 print_cls:11 print_sbyte:16 print_str:18 -Calls in [print_sbyte] to print_char:35 print_byte:39 print_char:43 -Calls in [print_byte] to print_char:54 print_char:59 -Calls in [print_cls] to memset:63 -Calls in [sin8s_gen] to div16u:76 sin8s:83 -Calls in [sin8s] to mulu8_sel:107 mulu8_sel:114 mulu8_sel:119 mulu8_sel:127 mulu8_sel:134 -Calls in [mulu8_sel] to mul8u:155 -Calls in [div16u] to divr16u:179 +Calls in [] to main:6 +Calls in [main] to sin8s_gen:10 print_cls:12 print_sbyte:17 print_str:19 +Calls in [print_sbyte] to print_char:36 print_byte:40 print_char:44 +Calls in [print_byte] to print_char:55 print_char:60 +Calls in [print_cls] to memset:64 +Calls in [sin8s_gen] to div16u:77 sin8s:84 +Calls in [sin8s] to mulu8_sel:108 mulu8_sel:115 mulu8_sel:120 mulu8_sel:128 mulu8_sel:135 +Calls in [mulu8_sel] to mul8u:156 +Calls in [div16u] to divr16u:180 Created 30 initial phi equivalence classes -Coalesced [22] main::i#5 ← main::i#1 -Coalesced [23] print_char_cursor#54 ← print_char_cursor#19 -Coalesced [24] print_char_cursor#48 ← print_char_cursor#10 -Coalesced [31] print_str::str#5 ← print_str::str#0 -Coalesced [32] print_char_cursor#49 ← print_char_cursor#1 -Coalesced [34] print_char_cursor#53 ← print_char_cursor#42 -Coalesced [36] print_sbyte::b#9 ← print_sbyte::b#1 -Coalesced (already) [42] print_char_cursor#52 ← print_char_cursor#42 -Coalesced [45] print_sbyte::b#8 ← print_sbyte::b#0 -Coalesced [52] print_char::ch#5 ← print_char::ch#2 -Coalesced (already) [53] print_char_cursor#50 ← print_char_cursor#10 -Coalesced [57] print_char::ch#6 ← print_char::ch#3 -Coalesced (already) [58] print_char_cursor#51 ← print_char_cursor#10 -Coalesced [74] memset::dst#4 ← memset::dst#1 -Coalesced [90] sin8s_gen::i#5 ← sin8s_gen::i#1 -Coalesced [91] sin8s_gen::x#5 ← sin8s_gen::x#1 -Coalesced [92] sin8s_gen::sintab#7 ← sin8s_gen::sintab#0 -Coalesced [95] sin8s::x#9 ← sin8s::x#1 -Coalesced [99] sin8s::x#11 ← sin8s::x#2 -Coalesced [105] mulu8_sel::v1#10 ← mulu8_sel::v1#0 -Coalesced [106] mulu8_sel::v2#9 ← mulu8_sel::v2#0 -Coalesced [112] mulu8_sel::v1#6 ← mulu8_sel::v1#1 -Coalesced [113] mulu8_sel::v2#6 ← mulu8_sel::v2#1 -Coalesced [118] mulu8_sel::v1#7 ← mulu8_sel::v1#2 -Coalesced [125] mulu8_sel::v1#8 ← mulu8_sel::v1#3 -Coalesced [126] mulu8_sel::v2#7 ← mulu8_sel::v2#3 -Coalesced [132] mulu8_sel::v1#9 ← mulu8_sel::v1#4 -Coalesced [133] mulu8_sel::v2#8 ← mulu8_sel::v2#4 -Coalesced [141] sin8s::usinx#9 ← sin8s::usinx#2 -Coalesced [145] sin8s::return#6 ← sin8s::sinx#1 -Coalesced [149] sin8s::usinx#8 ← sin8s::usinx#1 -Coalesced [150] sin8s::x#10 ← sin8s::x#4 -Coalesced [151] sin8s::x#8 ← sin8s::x#0 -Coalesced [161] mul8u::a#7 ← mul8u::a#1 -Coalesced [162] mul8u::mb#6 ← mul8u::b#0 -Coalesced [170] mul8u::res#9 ← mul8u::res#1 -Coalesced [174] mul8u::a#8 ← mul8u::a#0 -Coalesced [175] mul8u::res#7 ← mul8u::res#6 -Coalesced [176] mul8u::mb#7 ← mul8u::mb#1 -Coalesced (already) [177] mul8u::res#8 ← mul8u::res#2 -Coalesced [190] divr16u::rem#12 ← divr16u::rem#1 -Coalesced [197] divr16u::rem#14 ← divr16u::rem#2 -Coalesced [198] divr16u::return#6 ← divr16u::quotient#2 -Coalesced [204] divr16u::rem#10 ← divr16u::rem#9 -Coalesced [205] divr16u::dividend#8 ← divr16u::dividend#0 -Coalesced [206] divr16u::quotient#9 ← divr16u::return#0 -Coalesced [207] divr16u::i#7 ← divr16u::i#1 -Coalesced [208] divr16u::rem#13 ← divr16u::rem#5 -Coalesced [209] divr16u::return#5 ← divr16u::quotient#1 -Coalesced [210] divr16u::rem#11 ← divr16u::rem#0 +Coalesced [23] main::i#5 ← main::i#1 +Coalesced [24] print_char_cursor#55 ← print_char_cursor#19 +Coalesced [25] print_char_cursor#49 ← print_char_cursor#10 +Coalesced [32] print_str::str#5 ← print_str::str#0 +Coalesced [33] print_char_cursor#50 ← print_char_cursor#1 +Coalesced [35] print_char_cursor#54 ← print_char_cursor#42 +Coalesced [37] print_sbyte::b#9 ← print_sbyte::b#1 +Coalesced (already) [43] print_char_cursor#53 ← print_char_cursor#42 +Coalesced [46] print_sbyte::b#8 ← print_sbyte::b#0 +Coalesced [53] print_char::ch#5 ← print_char::ch#2 +Coalesced (already) [54] print_char_cursor#51 ← print_char_cursor#10 +Coalesced [58] print_char::ch#6 ← print_char::ch#3 +Coalesced (already) [59] print_char_cursor#52 ← print_char_cursor#10 +Coalesced [75] memset::dst#4 ← memset::dst#1 +Coalesced [91] sin8s_gen::i#5 ← sin8s_gen::i#1 +Coalesced [92] sin8s_gen::x#5 ← sin8s_gen::x#1 +Coalesced [93] sin8s_gen::sintab#7 ← sin8s_gen::sintab#0 +Coalesced [96] sin8s::x#9 ← sin8s::x#1 +Coalesced [100] sin8s::x#11 ← sin8s::x#2 +Coalesced [106] mulu8_sel::v1#10 ← mulu8_sel::v1#0 +Coalesced [107] mulu8_sel::v2#9 ← mulu8_sel::v2#0 +Coalesced [113] mulu8_sel::v1#6 ← mulu8_sel::v1#1 +Coalesced [114] mulu8_sel::v2#6 ← mulu8_sel::v2#1 +Coalesced [119] mulu8_sel::v1#7 ← mulu8_sel::v1#2 +Coalesced [126] mulu8_sel::v1#8 ← mulu8_sel::v1#3 +Coalesced [127] mulu8_sel::v2#7 ← mulu8_sel::v2#3 +Coalesced [133] mulu8_sel::v1#9 ← mulu8_sel::v1#4 +Coalesced [134] mulu8_sel::v2#8 ← mulu8_sel::v2#4 +Coalesced [142] sin8s::usinx#9 ← sin8s::usinx#2 +Coalesced [146] sin8s::return#6 ← sin8s::sinx#1 +Coalesced [150] sin8s::usinx#8 ← sin8s::usinx#1 +Coalesced [151] sin8s::x#10 ← sin8s::x#4 +Coalesced [152] sin8s::x#8 ← sin8s::x#0 +Coalesced [162] mul8u::a#7 ← mul8u::a#1 +Coalesced [163] mul8u::mb#6 ← mul8u::b#0 +Coalesced [171] mul8u::res#9 ← mul8u::res#1 +Coalesced [175] mul8u::a#8 ← mul8u::a#0 +Coalesced [176] mul8u::res#7 ← mul8u::res#6 +Coalesced [177] mul8u::mb#7 ← mul8u::mb#1 +Coalesced (already) [178] mul8u::res#8 ← mul8u::res#2 +Coalesced [191] divr16u::rem#12 ← divr16u::rem#1 +Coalesced [198] divr16u::rem#14 ← divr16u::rem#2 +Coalesced [199] divr16u::return#6 ← divr16u::quotient#2 +Coalesced [205] divr16u::rem#10 ← divr16u::rem#9 +Coalesced [206] divr16u::dividend#8 ← divr16u::dividend#0 +Coalesced [207] divr16u::quotient#9 ← divr16u::return#0 +Coalesced [208] divr16u::i#7 ← divr16u::i#1 +Coalesced [209] divr16u::rem#13 ← divr16u::rem#5 +Coalesced [210] divr16u::return#5 ← divr16u::quotient#1 +Coalesced [211] divr16u::rem#11 ← divr16u::rem#0 Coalesced down to 23 phi equivalence classes Culled Empty Block (label) @13 Culled Empty Block (label) @32 Culled Empty Block (label) @49 +Culled Empty Block (label) @56 Culled Empty Block (label) @58 Culled Empty Block (label) main::@4 Culled Empty Block (label) main::@7 @@ -2064,7 +2074,7 @@ main::@2: scope:[main] from main main::@1: scope:[main] from main::@2 main::@4 [8] (byte*) print_char_cursor#42 ← phi( main::@2/(const byte*) print_line_cursor#0 main::@4/(byte*) print_char_cursor#19 ) [8] (byte) main::i#2 ← phi( main::@2/(byte) 0 main::@4/(byte) main::i#1 ) - [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) main::sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) main::sintabref + (byte) main::i#2) + [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) sintabref + (byte) main::i#2) [10] (signed byte) print_sbyte::b#1 ← (signed byte) main::sb#0 [11] call print_sbyte to:main::@3 @@ -2183,10 +2193,10 @@ sin8s_gen::@3: scope:[sin8s_gen] from sin8s_gen [57] (word) sin8s_gen::step#0 ← (word) div16u::return#2 to:sin8s_gen::@1 sin8s_gen::@1: scope:[sin8s_gen] from sin8s_gen::@3 sin8s_gen::@4 - [58] (signed byte*) sin8s_gen::sintab#2 ← phi( sin8s_gen::@3/(const signed byte[$c0]) main::sintab2 sin8s_gen::@4/(signed byte*) sin8s_gen::sintab#0 ) + [58] (signed byte*) sin8s_gen::sintab#2 ← phi( sin8s_gen::@3/(const signed byte[$c0]) sintab2 sin8s_gen::@4/(signed byte*) sin8s_gen::sintab#0 ) [58] (word) sin8s_gen::x#2 ← phi( sin8s_gen::@3/(byte) 0 sin8s_gen::@4/(word) sin8s_gen::x#1 ) [58] (word) sin8s_gen::i#2 ← phi( sin8s_gen::@3/(byte) 0 sin8s_gen::@4/(word) sin8s_gen::i#1 ) - [59] if((word) sin8s_gen::i#2<(const word) main::wavelength) goto sin8s_gen::@2 + [59] if((word) sin8s_gen::i#2<(const word) wavelength) goto sin8s_gen::@2 to:sin8s_gen::@return sin8s_gen::@return: scope:[sin8s_gen] from sin8s_gen::@1 [60] return @@ -2361,11 +2371,11 @@ divr16u::@2: scope:[divr16u] from divr16u::@1 divr16u::@4 [143] (word) divr16u::rem#5 ← phi( divr16u::@1/(word) divr16u::rem#0 divr16u::@4/(word) divr16u::rem#1 ) [144] (word) divr16u::dividend#0 ← (word) divr16u::dividend#2 << (byte) 1 [145] (word) divr16u::quotient#1 ← (word) divr16u::quotient#3 << (byte) 1 - [146] if((word) divr16u::rem#5<(const word) main::wavelength) goto divr16u::@3 + [146] if((word) divr16u::rem#5<(const word) wavelength) goto divr16u::@3 to:divr16u::@5 divr16u::@5: scope:[divr16u] from divr16u::@2 [147] (word) divr16u::quotient#2 ← ++ (word) divr16u::quotient#1 - [148] (word) divr16u::rem#2 ← (word) divr16u::rem#5 - (const word) main::wavelength + [148] (word) divr16u::rem#2 ← (word) divr16u::rem#5 - (const word) wavelength to:divr16u::@3 divr16u::@3: scope:[divr16u] from divr16u::@2 divr16u::@5 [149] (word) divr16u::return#0 ← phi( divr16u::@2/(word) divr16u::quotient#1 divr16u::@5/(word) divr16u::quotient#2 ) @@ -2728,6 +2738,7 @@ Target platform is c64basic / MOS6502X // PI/2 in u[4.12] format .const PI_HALF_u4f12 = $1922 .label print_line_cursor = $400 + .const wavelength = $c0 .label print_char_cursor = 7 // @begin __bbegin: @@ -2747,7 +2758,6 @@ __bend_from___b1: __bend: // main main: { - .label wavelength = $c0 .label sb = $26 .label i = 2 // [5] call sin8s_gen @@ -2781,7 +2791,7 @@ main: { jmp __b1 // main::@1 __b1: - // [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) main::sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) main::sintabref + (byte) main::i#2) -- vbsz1=pbsc1_derefidx_vbuz2_minus_pbsc2_derefidx_vbuz2 + // [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) sintabref + (byte) main::i#2) -- vbsz1=pbsc1_derefidx_vbuz2_minus_pbsc2_derefidx_vbuz2 ldy.z i lda sintab2,y sec @@ -2817,9 +2827,6 @@ main: { rts str: .text " " .byte 0 - sintab2: .fill $c0, 0 - // .fill $c0, round(127.5*sin(i*2*PI/$c0)) - sintabref: .byte 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc } // print_str // Print a zero-terminated string @@ -3088,10 +3095,10 @@ sin8s_gen: { sta.z step+1 // [58] phi from sin8s_gen::@3 to sin8s_gen::@1 [phi:sin8s_gen::@3->sin8s_gen::@1] __b1_from___b3: - // [58] phi (signed byte*) sin8s_gen::sintab#2 = (const signed byte[$c0]) main::sintab2 [phi:sin8s_gen::@3->sin8s_gen::@1#0] -- pbsz1=pbsc1 - lda #sin8s_gen::@1#0] -- pbsz1=pbsc1 + lda #main.sintab2 + lda #>sintab2 sta.z sintab+1 // [58] phi (word) sin8s_gen::x#2 = (byte) 0 [phi:sin8s_gen::@3->sin8s_gen::@1#1] -- vwuz1=vbuc1 lda #<0 @@ -3107,13 +3114,13 @@ sin8s_gen: { // u[4.12] // sin8s_gen::@1 __b1: - // [59] if((word) sin8s_gen::i#2<(const word) main::wavelength) goto sin8s_gen::@2 -- vwuz1_lt_vwuc1_then_la1 + // [59] if((word) sin8s_gen::i#2<(const word) wavelength) goto sin8s_gen::@2 -- vwuz1_lt_vwuc1_then_la1 lda.z i+1 - cmp #>main.wavelength + cmp #>wavelength bcc __b2 bne !+ lda.z i - cmp #main.wavelength + cmp #>wavelength bcc __b3_from___b2 bne !+ lda.z rem - cmp #main.wavelength + sbc #>wavelength sta.z rem+1 // [149] phi from divr16u::@2 divr16u::@5 to divr16u::@3 [phi:divr16u::@2/divr16u::@5->divr16u::@3] __b3_from___b2: @@ -3745,9 +3752,12 @@ divr16u: { } // File Data print_hextab: .text "0123456789abcdef" + sintab2: .fill $c0, 0 + // .fill $c0, round(127.5*sin(i*2*PI/$c0)) + sintabref: .byte 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc REGISTER UPLIFT POTENTIAL REGISTERS -Statement [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) main::sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) main::sintabref + (byte) main::i#2) [ main::i#2 print_char_cursor#42 main::sb#0 ] ( main:2 [ main::i#2 print_char_cursor#42 main::sb#0 ] ) always clobbers reg byte a +Statement [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) sintabref + (byte) main::i#2) [ main::i#2 print_char_cursor#42 main::sb#0 ] ( main:2 [ main::i#2 print_char_cursor#42 main::sb#0 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ] Statement [19] if((byte) 0!=*((byte*) print_str::str#2)) goto print_str::@2 [ print_char_cursor#19 print_str::str#2 ] ( main:2::print_str:13 [ main::i#2 print_char_cursor#19 print_str::str#2 ] ) always clobbers reg byte a reg byte y Removing always clobbered register reg byte y as potential for zp[1]:2 [ main::i#2 main::i#1 ] @@ -3763,7 +3773,7 @@ Statement [50] if((byte*) memset::dst#2!=(const byte*) memset::end#0) goto memse Statement [52] *((byte*) memset::dst#2) ← (const byte) memset::c#0 [ memset::dst#2 ] ( main:2::print_cls:7::memset:46 [ memset::dst#2 ] ) always clobbers reg byte a reg byte y Statement [56] (word) div16u::return#2 ← (word) div16u::return#0 [ div16u::return#2 ] ( main:2::sin8s_gen:5 [ div16u::return#2 ] ) always clobbers reg byte a Statement [57] (word) sin8s_gen::step#0 ← (word) div16u::return#2 [ sin8s_gen::step#0 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 ] ) always clobbers reg byte a -Statement [59] if((word) sin8s_gen::i#2<(const word) main::wavelength) goto sin8s_gen::@2 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ) always clobbers reg byte a +Statement [59] if((word) sin8s_gen::i#2<(const word) wavelength) goto sin8s_gen::@2 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ) always clobbers reg byte a Statement [61] (word) sin8s::x#0 ← (word) sin8s_gen::x#2 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 sin8s::x#0 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 sin8s::x#0 ] ) always clobbers reg byte a Statement [65] *((signed byte*) sin8s_gen::sintab#2) ← (signed byte~) sin8s_gen::$2 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ) always clobbers reg byte y Statement [67] (word) sin8s_gen::x#1 ← (word) sin8s_gen::x#2 + (word) sin8s_gen::step#0 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#1 sin8s_gen::sintab#0 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#1 sin8s_gen::sintab#0 ] ) always clobbers reg byte a @@ -3793,9 +3803,9 @@ Statement [134] (word) div16u::return#0 ← (word) divr16u::return#2 [ div16u::r Statement [139] (byte~) divr16u::$1 ← > (word) divr16u::dividend#2 [ divr16u::dividend#2 divr16u::quotient#3 divr16u::i#2 divr16u::rem#0 divr16u::$1 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::dividend#2 divr16u::quotient#3 divr16u::i#2 divr16u::rem#0 divr16u::$1 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:37 [ divr16u::i#2 divr16u::i#1 ] Statement [142] (word) divr16u::rem#1 ← (word) divr16u::rem#0 | (byte) 1 [ divr16u::dividend#2 divr16u::quotient#3 divr16u::i#2 divr16u::rem#1 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::dividend#2 divr16u::quotient#3 divr16u::i#2 divr16u::rem#1 ] ) always clobbers reg byte a -Statement [146] if((word) divr16u::rem#5<(const word) main::wavelength) goto divr16u::@3 [ divr16u::i#2 divr16u::dividend#0 divr16u::rem#5 divr16u::quotient#1 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::i#2 divr16u::dividend#0 divr16u::rem#5 divr16u::quotient#1 ] ) always clobbers reg byte a -Statement [148] (word) divr16u::rem#2 ← (word) divr16u::rem#5 - (const word) main::wavelength [ divr16u::i#2 divr16u::dividend#0 divr16u::quotient#2 divr16u::rem#2 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::i#2 divr16u::dividend#0 divr16u::quotient#2 divr16u::rem#2 ] ) always clobbers reg byte a -Statement [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) main::sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) main::sintabref + (byte) main::i#2) [ main::i#2 print_char_cursor#42 main::sb#0 ] ( main:2 [ main::i#2 print_char_cursor#42 main::sb#0 ] ) always clobbers reg byte a +Statement [146] if((word) divr16u::rem#5<(const word) wavelength) goto divr16u::@3 [ divr16u::i#2 divr16u::dividend#0 divr16u::rem#5 divr16u::quotient#1 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::i#2 divr16u::dividend#0 divr16u::rem#5 divr16u::quotient#1 ] ) always clobbers reg byte a +Statement [148] (word) divr16u::rem#2 ← (word) divr16u::rem#5 - (const word) wavelength [ divr16u::i#2 divr16u::dividend#0 divr16u::quotient#2 divr16u::rem#2 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::i#2 divr16u::dividend#0 divr16u::quotient#2 divr16u::rem#2 ] ) always clobbers reg byte a +Statement [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) sintabref + (byte) main::i#2) [ main::i#2 print_char_cursor#42 main::sb#0 ] ( main:2 [ main::i#2 print_char_cursor#42 main::sb#0 ] ) always clobbers reg byte a Statement [19] if((byte) 0!=*((byte*) print_str::str#2)) goto print_str::@2 [ print_char_cursor#19 print_str::str#2 ] ( main:2::print_str:13 [ main::i#2 print_char_cursor#19 print_str::str#2 ] ) always clobbers reg byte a reg byte y Statement [21] *((byte*) print_char_cursor#19) ← *((byte*) print_str::str#2) [ print_char_cursor#19 print_str::str#2 ] ( main:2::print_str:13 [ main::i#2 print_char_cursor#19 print_str::str#2 ] ) always clobbers reg byte a reg byte y Statement [33] (signed byte) print_sbyte::b#0 ← - (signed byte) print_sbyte::b#1 [ print_char_cursor#10 print_sbyte::b#0 ] ( main:2::print_sbyte:11 [ main::i#2 print_char_cursor#10 print_sbyte::b#0 ] ) always clobbers reg byte a @@ -3806,7 +3816,7 @@ Statement [50] if((byte*) memset::dst#2!=(const byte*) memset::end#0) goto memse Statement [52] *((byte*) memset::dst#2) ← (const byte) memset::c#0 [ memset::dst#2 ] ( main:2::print_cls:7::memset:46 [ memset::dst#2 ] ) always clobbers reg byte a reg byte y Statement [56] (word) div16u::return#2 ← (word) div16u::return#0 [ div16u::return#2 ] ( main:2::sin8s_gen:5 [ div16u::return#2 ] ) always clobbers reg byte a Statement [57] (word) sin8s_gen::step#0 ← (word) div16u::return#2 [ sin8s_gen::step#0 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 ] ) always clobbers reg byte a -Statement [59] if((word) sin8s_gen::i#2<(const word) main::wavelength) goto sin8s_gen::@2 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ) always clobbers reg byte a +Statement [59] if((word) sin8s_gen::i#2<(const word) wavelength) goto sin8s_gen::@2 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ) always clobbers reg byte a Statement [61] (word) sin8s::x#0 ← (word) sin8s_gen::x#2 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 sin8s::x#0 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 sin8s::x#0 ] ) always clobbers reg byte a Statement [65] *((signed byte*) sin8s_gen::sintab#2) ← (signed byte~) sin8s_gen::$2 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#2 sin8s_gen::sintab#2 ] ) always clobbers reg byte y Statement [67] (word) sin8s_gen::x#1 ← (word) sin8s_gen::x#2 + (word) sin8s_gen::step#0 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#1 sin8s_gen::sintab#0 ] ( main:2::sin8s_gen:5 [ sin8s_gen::step#0 sin8s_gen::i#2 sin8s_gen::x#1 sin8s_gen::sintab#0 ] ) always clobbers reg byte a @@ -3830,8 +3840,8 @@ Statement [133] (word) divr16u::return#2 ← (word) divr16u::return#0 [ divr16u: Statement [134] (word) div16u::return#0 ← (word) divr16u::return#2 [ div16u::return#0 ] ( main:2::sin8s_gen:5::div16u:55 [ div16u::return#0 ] ) always clobbers reg byte a Statement [139] (byte~) divr16u::$1 ← > (word) divr16u::dividend#2 [ divr16u::dividend#2 divr16u::quotient#3 divr16u::i#2 divr16u::rem#0 divr16u::$1 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::dividend#2 divr16u::quotient#3 divr16u::i#2 divr16u::rem#0 divr16u::$1 ] ) always clobbers reg byte a Statement [142] (word) divr16u::rem#1 ← (word) divr16u::rem#0 | (byte) 1 [ divr16u::dividend#2 divr16u::quotient#3 divr16u::i#2 divr16u::rem#1 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::dividend#2 divr16u::quotient#3 divr16u::i#2 divr16u::rem#1 ] ) always clobbers reg byte a -Statement [146] if((word) divr16u::rem#5<(const word) main::wavelength) goto divr16u::@3 [ divr16u::i#2 divr16u::dividend#0 divr16u::rem#5 divr16u::quotient#1 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::i#2 divr16u::dividend#0 divr16u::rem#5 divr16u::quotient#1 ] ) always clobbers reg byte a -Statement [148] (word) divr16u::rem#2 ← (word) divr16u::rem#5 - (const word) main::wavelength [ divr16u::i#2 divr16u::dividend#0 divr16u::quotient#2 divr16u::rem#2 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::i#2 divr16u::dividend#0 divr16u::quotient#2 divr16u::rem#2 ] ) always clobbers reg byte a +Statement [146] if((word) divr16u::rem#5<(const word) wavelength) goto divr16u::@3 [ divr16u::i#2 divr16u::dividend#0 divr16u::rem#5 divr16u::quotient#1 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::i#2 divr16u::dividend#0 divr16u::rem#5 divr16u::quotient#1 ] ) always clobbers reg byte a +Statement [148] (word) divr16u::rem#2 ← (word) divr16u::rem#5 - (const word) wavelength [ divr16u::i#2 divr16u::dividend#0 divr16u::quotient#2 divr16u::rem#2 ] ( main:2::sin8s_gen:5::div16u:55::divr16u:132 [ divr16u::i#2 divr16u::dividend#0 divr16u::quotient#2 divr16u::rem#2 ] ) always clobbers reg byte a Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , Potential registers zp[2]:3 [ print_str::str#2 print_str::str#0 ] : zp[2]:3 , Potential registers zp[1]:5 [ print_sbyte::b#4 print_sbyte::b#0 print_sbyte::b#1 ] : zp[1]:5 , reg byte a , reg byte x , @@ -3996,6 +4006,7 @@ ASSEMBLER BEFORE OPTIMIZATION // PI/2 in u[4.12] format .const PI_HALF_u4f12 = $1922 .label print_line_cursor = $400 + .const wavelength = $c0 .label print_char_cursor = 2 // @begin __bbegin: @@ -4015,7 +4026,6 @@ __bend_from___b1: __bend: // main main: { - .label wavelength = $c0 // [5] call sin8s_gen // [54] phi from main to sin8s_gen [phi:main->sin8s_gen] sin8s_gen_from_main: @@ -4046,7 +4056,7 @@ main: { jmp __b1 // main::@1 __b1: - // [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) main::sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) main::sintabref + (byte) main::i#2) -- vbsaa=pbsc1_derefidx_vbuxx_minus_pbsc2_derefidx_vbuxx + // [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) sintabref + (byte) main::i#2) -- vbsaa=pbsc1_derefidx_vbuxx_minus_pbsc2_derefidx_vbuxx lda sintab2,x sec sbc sintabref,x @@ -4078,9 +4088,6 @@ main: { rts str: .text " " .byte 0 - sintab2: .fill $c0, 0 - // .fill $c0, round(127.5*sin(i*2*PI/$c0)) - sintabref: .byte 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc } // print_str // Print a zero-terminated string @@ -4328,10 +4335,10 @@ sin8s_gen: { // [57] (word) sin8s_gen::step#0 ← (word) div16u::return#2 // [58] phi from sin8s_gen::@3 to sin8s_gen::@1 [phi:sin8s_gen::@3->sin8s_gen::@1] __b1_from___b3: - // [58] phi (signed byte*) sin8s_gen::sintab#2 = (const signed byte[$c0]) main::sintab2 [phi:sin8s_gen::@3->sin8s_gen::@1#0] -- pbsz1=pbsc1 - lda #sin8s_gen::@1#0] -- pbsz1=pbsc1 + lda #main.sintab2 + lda #>sintab2 sta.z sintab+1 // [58] phi (word) sin8s_gen::x#2 = (byte) 0 [phi:sin8s_gen::@3->sin8s_gen::@1#1] -- vwuz1=vbuc1 lda #<0 @@ -4347,13 +4354,13 @@ sin8s_gen: { // u[4.12] // sin8s_gen::@1 __b1: - // [59] if((word) sin8s_gen::i#2<(const word) main::wavelength) goto sin8s_gen::@2 -- vwuz1_lt_vwuc1_then_la1 + // [59] if((word) sin8s_gen::i#2<(const word) wavelength) goto sin8s_gen::@2 -- vwuz1_lt_vwuc1_then_la1 lda.z i+1 - cmp #>main.wavelength + cmp #>wavelength bcc __b2 bne !+ lda.z i - cmp #main.wavelength + cmp #>wavelength bcc __b3_from___b2 bne !+ lda.z rem - cmp #main.wavelength + sbc #>wavelength sta.z rem+1 // [149] phi from divr16u::@2 divr16u::@5 to divr16u::@3 [phi:divr16u::@2/divr16u::@5->divr16u::@3] __b3_from___b2: @@ -4884,6 +4891,9 @@ divr16u: { } // File Data print_hextab: .text "0123456789abcdef" + sintab2: .fill $c0, 0 + // .fill $c0, round(127.5*sin(i*2*PI/$c0)) + sintabref: .byte 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc ASSEMBLER OPTIMIZATIONS Removing instruction jmp __b1 @@ -5129,10 +5139,7 @@ FINAL SYMBOL TABLE (byte) main::i#2 reg byte x 5.5 (signed byte) main::sb (signed byte) main::sb#0 reg byte a 22.0 -(const signed byte[$c0]) main::sintab2 = { fill( $c0, 0) } -(const byte[]) main::sintabref = { (byte) 0, (byte) 4, (byte) 8, (byte) $c, (byte) $11, (byte) $15, (byte) $19, (byte) $1d, (byte) $21, (byte) $25, (byte) $29, (byte) $2d, (byte) $31, (byte) $35, (byte) $38, (byte) $3c, (byte) $40, (byte) $43, (byte) $47, (byte) $4a, (byte) $4e, (byte) $51, (byte) $54, (byte) $57, (byte) $5a, (byte) $5d, (byte) $60, (byte) $63, (byte) $65, (byte) $68, (byte) $6a, (byte) $6c, (byte) $6e, (byte) $70, (byte) $72, (byte) $74, (byte) $76, (byte) $77, (byte) $79, (byte) $7a, (byte) $7b, (byte) $7c, (byte) $7d, (byte) $7e, (byte) $7e, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $80, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $7e, (byte) $7e, (byte) $7d, (byte) $7c, (byte) $7b, (byte) $7a, (byte) $79, (byte) $77, (byte) $76, (byte) $74, (byte) $72, (byte) $70, (byte) $6e, (byte) $6c, (byte) $6a, (byte) $68, (byte) $65, (byte) $63, (byte) $60, (byte) $5d, (byte) $5a, (byte) $57, (byte) $54, (byte) $51, (byte) $4e, (byte) $4a, (byte) $47, (byte) $43, (byte) $40, (byte) $3c, (byte) $38, (byte) $35, (byte) $31, (byte) $2d, (byte) $29, (byte) $25, (byte) $21, (byte) $1d, (byte) $19, (byte) $15, (byte) $11, (byte) $c, (byte) 8, (byte) 4, (byte) 0, (byte) $fc, (byte) $f8, (byte) $f4, (byte) $ef, (byte) $eb, (byte) $e7, (byte) $e3, (byte) $df, (byte) $db, (byte) $d7, (byte) $d3, (byte) $cf, (byte) $cb, (byte) $c8, (byte) $c4, (byte) $c0, (byte) $bd, (byte) $b9, (byte) $b6, (byte) $b2, (byte) $af, (byte) $ac, (byte) $a9, (byte) $a6, (byte) $a3, (byte) $a0, (byte) $9d, (byte) $9b, (byte) $98, (byte) $96, (byte) $94, (byte) $92, (byte) $90, (byte) $8e, (byte) $8c, (byte) $8a, (byte) $89, (byte) $87, (byte) $86, (byte) $85, (byte) $84, (byte) $83, (byte) $82, (byte) $82, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $82, (byte) $82, (byte) $83, (byte) $84, (byte) $85, (byte) $86, (byte) $87, (byte) $89, (byte) $8a, (byte) $8c, (byte) $8e, (byte) $90, (byte) $92, (byte) $94, (byte) $96, (byte) $98, (byte) $9b, (byte) $9d, (byte) $a0, (byte) $a3, (byte) $a6, (byte) $a9, (byte) $ac, (byte) $af, (byte) $b2, (byte) $b6, (byte) $b9, (byte) $bd, (byte) $c0, (byte) $c4, (byte) $c8, (byte) $cb, (byte) $cf, (byte) $d3, (byte) $d7, (byte) $db, (byte) $df, (byte) $e3, (byte) $e7, (byte) $eb, (byte) $ef, (byte) $f4, (byte) $f8, (byte) $fc } (const string) main::str = (string) " " -(const word) main::wavelength = (byte) $c0 (void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num) (label) memset::@1 (label) memset::@2 @@ -5310,6 +5317,9 @@ FINAL SYMBOL TABLE (word) sin8s_gen::x (word) sin8s_gen::x#1 x zp[2]:10 11.0 (word) sin8s_gen::x#2 x zp[2]:10 4.125 +(const signed byte[$c0]) sintab2 = { fill( $c0, 0) } +(const byte[]) sintabref = { (byte) 0, (byte) 4, (byte) 8, (byte) $c, (byte) $11, (byte) $15, (byte) $19, (byte) $1d, (byte) $21, (byte) $25, (byte) $29, (byte) $2d, (byte) $31, (byte) $35, (byte) $38, (byte) $3c, (byte) $40, (byte) $43, (byte) $47, (byte) $4a, (byte) $4e, (byte) $51, (byte) $54, (byte) $57, (byte) $5a, (byte) $5d, (byte) $60, (byte) $63, (byte) $65, (byte) $68, (byte) $6a, (byte) $6c, (byte) $6e, (byte) $70, (byte) $72, (byte) $74, (byte) $76, (byte) $77, (byte) $79, (byte) $7a, (byte) $7b, (byte) $7c, (byte) $7d, (byte) $7e, (byte) $7e, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $80, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $7e, (byte) $7e, (byte) $7d, (byte) $7c, (byte) $7b, (byte) $7a, (byte) $79, (byte) $77, (byte) $76, (byte) $74, (byte) $72, (byte) $70, (byte) $6e, (byte) $6c, (byte) $6a, (byte) $68, (byte) $65, (byte) $63, (byte) $60, (byte) $5d, (byte) $5a, (byte) $57, (byte) $54, (byte) $51, (byte) $4e, (byte) $4a, (byte) $47, (byte) $43, (byte) $40, (byte) $3c, (byte) $38, (byte) $35, (byte) $31, (byte) $2d, (byte) $29, (byte) $25, (byte) $21, (byte) $1d, (byte) $19, (byte) $15, (byte) $11, (byte) $c, (byte) 8, (byte) 4, (byte) 0, (byte) $fc, (byte) $f8, (byte) $f4, (byte) $ef, (byte) $eb, (byte) $e7, (byte) $e3, (byte) $df, (byte) $db, (byte) $d7, (byte) $d3, (byte) $cf, (byte) $cb, (byte) $c8, (byte) $c4, (byte) $c0, (byte) $bd, (byte) $b9, (byte) $b6, (byte) $b2, (byte) $af, (byte) $ac, (byte) $a9, (byte) $a6, (byte) $a3, (byte) $a0, (byte) $9d, (byte) $9b, (byte) $98, (byte) $96, (byte) $94, (byte) $92, (byte) $90, (byte) $8e, (byte) $8c, (byte) $8a, (byte) $89, (byte) $87, (byte) $86, (byte) $85, (byte) $84, (byte) $83, (byte) $82, (byte) $82, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $82, (byte) $82, (byte) $83, (byte) $84, (byte) $85, (byte) $86, (byte) $87, (byte) $89, (byte) $8a, (byte) $8c, (byte) $8e, (byte) $90, (byte) $92, (byte) $94, (byte) $96, (byte) $98, (byte) $9b, (byte) $9d, (byte) $a0, (byte) $a3, (byte) $a6, (byte) $a9, (byte) $ac, (byte) $af, (byte) $b2, (byte) $b6, (byte) $b9, (byte) $bd, (byte) $c0, (byte) $c4, (byte) $c8, (byte) $cb, (byte) $cf, (byte) $d3, (byte) $d7, (byte) $db, (byte) $df, (byte) $e3, (byte) $e7, (byte) $eb, (byte) $ef, (byte) $f4, (byte) $f8, (byte) $fc } +(const word) wavelength = (byte) $c0 reg byte x [ main::i#2 main::i#1 ] reg byte a [ print_char::ch#4 print_char::ch#2 print_char::ch#3 ] @@ -5368,6 +5378,7 @@ Score: 16797 // PI/2 in u[4.12] format .const PI_HALF_u4f12 = $1922 .label print_line_cursor = $400 + .const wavelength = $c0 .label print_char_cursor = 2 // @begin // [1] phi from @begin to @1 [phi:@begin->@1] @@ -5378,7 +5389,6 @@ Score: 16797 // @end // main main: { - .label wavelength = $c0 // sin8s_gen(sintab2, wavelength) // [5] call sin8s_gen // [54] phi from main to sin8s_gen [phi:main->sin8s_gen] @@ -5403,7 +5413,7 @@ main: { // main::@1 __b1: // sb = sintab2[i]-(signed byte)sintabref[i] - // [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) main::sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) main::sintabref + (byte) main::i#2) -- vbsaa=pbsc1_derefidx_vbuxx_minus_pbsc2_derefidx_vbuxx + // [9] (signed byte) main::sb#0 ← *((const signed byte[$c0]) sintab2 + (byte) main::i#2) - (signed byte)*((const byte[]) sintabref + (byte) main::i#2) -- vbsaa=pbsc1_derefidx_vbuxx_minus_pbsc2_derefidx_vbuxx lda sintab2,x sec sbc sintabref,x @@ -5431,9 +5441,6 @@ main: { rts str: .text " " .byte 0 - sintab2: .fill $c0, 0 - // .fill $c0, round(127.5*sin(i*2*PI/$c0)) - sintabref: .byte 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc } // print_str // Print a zero-terminated string @@ -5668,10 +5675,10 @@ sin8s_gen: { // step = div16u(PI2_u4f12, wavelength) // [57] (word) sin8s_gen::step#0 ← (word) div16u::return#2 // [58] phi from sin8s_gen::@3 to sin8s_gen::@1 [phi:sin8s_gen::@3->sin8s_gen::@1] - // [58] phi (signed byte*) sin8s_gen::sintab#2 = (const signed byte[$c0]) main::sintab2 [phi:sin8s_gen::@3->sin8s_gen::@1#0] -- pbsz1=pbsc1 - lda #sin8s_gen::@1#0] -- pbsz1=pbsc1 + lda #main.sintab2 + lda #>sintab2 sta.z sintab+1 // [58] phi (word) sin8s_gen::x#2 = (byte) 0 [phi:sin8s_gen::@3->sin8s_gen::@1#1] -- vwuz1=vbuc1 lda #<0 @@ -5684,13 +5691,13 @@ sin8s_gen: { // sin8s_gen::@1 __b1: // for( word i=0; imain.wavelength + cmp #>wavelength bcc __b2 bne !+ lda.z i - cmp #=divisor) - // [146] if((word) divr16u::rem#5<(const word) main::wavelength) goto divr16u::@3 -- vwuz1_lt_vwuc1_then_la1 + // [146] if((word) divr16u::rem#5<(const word) wavelength) goto divr16u::@3 -- vwuz1_lt_vwuc1_then_la1 lda.z rem+1 - cmp #>main.wavelength + cmp #>wavelength bcc __b3 bne !+ lda.z rem - cmp #main.wavelength + sbc #>wavelength sta.z rem+1 // [149] phi from divr16u::@2 divr16u::@5 to divr16u::@3 [phi:divr16u::@2/divr16u::@5->divr16u::@3] // [149] phi (word) divr16u::return#0 = (word) divr16u::quotient#1 [phi:divr16u::@2/divr16u::@5->divr16u::@3#0] -- register_copy @@ -6201,4 +6208,7 @@ divr16u: { } // File Data print_hextab: .text "0123456789abcdef" + sintab2: .fill $c0, 0 + // .fill $c0, round(127.5*sin(i*2*PI/$c0)) + sintabref: .byte 0, 4, 8, $c, $11, $15, $19, $1d, $21, $25, $29, $2d, $31, $35, $38, $3c, $40, $43, $47, $4a, $4e, $51, $54, $57, $5a, $5d, $60, $63, $65, $68, $6a, $6c, $6e, $70, $72, $74, $76, $77, $79, $7a, $7b, $7c, $7d, $7e, $7e, $7f, $7f, $7f, $80, $7f, $7f, $7f, $7e, $7e, $7d, $7c, $7b, $7a, $79, $77, $76, $74, $72, $70, $6e, $6c, $6a, $68, $65, $63, $60, $5d, $5a, $57, $54, $51, $4e, $4a, $47, $43, $40, $3c, $38, $35, $31, $2d, $29, $25, $21, $1d, $19, $15, $11, $c, 8, 4, 0, $fc, $f8, $f4, $ef, $eb, $e7, $e3, $df, $db, $d7, $d3, $cf, $cb, $c8, $c4, $c0, $bd, $b9, $b6, $b2, $af, $ac, $a9, $a6, $a3, $a0, $9d, $9b, $98, $96, $94, $92, $90, $8e, $8c, $8a, $89, $87, $86, $85, $84, $83, $82, $82, $81, $81, $81, $81, $81, $81, $81, $82, $82, $83, $84, $85, $86, $87, $89, $8a, $8c, $8e, $90, $92, $94, $96, $98, $9b, $9d, $a0, $a3, $a6, $a9, $ac, $af, $b2, $b6, $b9, $bd, $c0, $c4, $c8, $cb, $cf, $d3, $d7, $db, $df, $e3, $e7, $eb, $ef, $f4, $f8, $fc diff --git a/src/test/ref/sinusgen8.sym b/src/test/ref/sinusgen8.sym index 8554bb364..61af47cfd 100644 --- a/src/test/ref/sinusgen8.sym +++ b/src/test/ref/sinusgen8.sym @@ -57,10 +57,7 @@ (byte) main::i#2 reg byte x 5.5 (signed byte) main::sb (signed byte) main::sb#0 reg byte a 22.0 -(const signed byte[$c0]) main::sintab2 = { fill( $c0, 0) } -(const byte[]) main::sintabref = { (byte) 0, (byte) 4, (byte) 8, (byte) $c, (byte) $11, (byte) $15, (byte) $19, (byte) $1d, (byte) $21, (byte) $25, (byte) $29, (byte) $2d, (byte) $31, (byte) $35, (byte) $38, (byte) $3c, (byte) $40, (byte) $43, (byte) $47, (byte) $4a, (byte) $4e, (byte) $51, (byte) $54, (byte) $57, (byte) $5a, (byte) $5d, (byte) $60, (byte) $63, (byte) $65, (byte) $68, (byte) $6a, (byte) $6c, (byte) $6e, (byte) $70, (byte) $72, (byte) $74, (byte) $76, (byte) $77, (byte) $79, (byte) $7a, (byte) $7b, (byte) $7c, (byte) $7d, (byte) $7e, (byte) $7e, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $80, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $7e, (byte) $7e, (byte) $7d, (byte) $7c, (byte) $7b, (byte) $7a, (byte) $79, (byte) $77, (byte) $76, (byte) $74, (byte) $72, (byte) $70, (byte) $6e, (byte) $6c, (byte) $6a, (byte) $68, (byte) $65, (byte) $63, (byte) $60, (byte) $5d, (byte) $5a, (byte) $57, (byte) $54, (byte) $51, (byte) $4e, (byte) $4a, (byte) $47, (byte) $43, (byte) $40, (byte) $3c, (byte) $38, (byte) $35, (byte) $31, (byte) $2d, (byte) $29, (byte) $25, (byte) $21, (byte) $1d, (byte) $19, (byte) $15, (byte) $11, (byte) $c, (byte) 8, (byte) 4, (byte) 0, (byte) $fc, (byte) $f8, (byte) $f4, (byte) $ef, (byte) $eb, (byte) $e7, (byte) $e3, (byte) $df, (byte) $db, (byte) $d7, (byte) $d3, (byte) $cf, (byte) $cb, (byte) $c8, (byte) $c4, (byte) $c0, (byte) $bd, (byte) $b9, (byte) $b6, (byte) $b2, (byte) $af, (byte) $ac, (byte) $a9, (byte) $a6, (byte) $a3, (byte) $a0, (byte) $9d, (byte) $9b, (byte) $98, (byte) $96, (byte) $94, (byte) $92, (byte) $90, (byte) $8e, (byte) $8c, (byte) $8a, (byte) $89, (byte) $87, (byte) $86, (byte) $85, (byte) $84, (byte) $83, (byte) $82, (byte) $82, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $82, (byte) $82, (byte) $83, (byte) $84, (byte) $85, (byte) $86, (byte) $87, (byte) $89, (byte) $8a, (byte) $8c, (byte) $8e, (byte) $90, (byte) $92, (byte) $94, (byte) $96, (byte) $98, (byte) $9b, (byte) $9d, (byte) $a0, (byte) $a3, (byte) $a6, (byte) $a9, (byte) $ac, (byte) $af, (byte) $b2, (byte) $b6, (byte) $b9, (byte) $bd, (byte) $c0, (byte) $c4, (byte) $c8, (byte) $cb, (byte) $cf, (byte) $d3, (byte) $d7, (byte) $db, (byte) $df, (byte) $e3, (byte) $e7, (byte) $eb, (byte) $ef, (byte) $f4, (byte) $f8, (byte) $fc } (const string) main::str = (string) " " -(const word) main::wavelength = (byte) $c0 (void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num) (label) memset::@1 (label) memset::@2 @@ -238,6 +235,9 @@ (word) sin8s_gen::x (word) sin8s_gen::x#1 x zp[2]:10 11.0 (word) sin8s_gen::x#2 x zp[2]:10 4.125 +(const signed byte[$c0]) sintab2 = { fill( $c0, 0) } +(const byte[]) sintabref = { (byte) 0, (byte) 4, (byte) 8, (byte) $c, (byte) $11, (byte) $15, (byte) $19, (byte) $1d, (byte) $21, (byte) $25, (byte) $29, (byte) $2d, (byte) $31, (byte) $35, (byte) $38, (byte) $3c, (byte) $40, (byte) $43, (byte) $47, (byte) $4a, (byte) $4e, (byte) $51, (byte) $54, (byte) $57, (byte) $5a, (byte) $5d, (byte) $60, (byte) $63, (byte) $65, (byte) $68, (byte) $6a, (byte) $6c, (byte) $6e, (byte) $70, (byte) $72, (byte) $74, (byte) $76, (byte) $77, (byte) $79, (byte) $7a, (byte) $7b, (byte) $7c, (byte) $7d, (byte) $7e, (byte) $7e, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $80, (byte) $7f, (byte) $7f, (byte) $7f, (byte) $7e, (byte) $7e, (byte) $7d, (byte) $7c, (byte) $7b, (byte) $7a, (byte) $79, (byte) $77, (byte) $76, (byte) $74, (byte) $72, (byte) $70, (byte) $6e, (byte) $6c, (byte) $6a, (byte) $68, (byte) $65, (byte) $63, (byte) $60, (byte) $5d, (byte) $5a, (byte) $57, (byte) $54, (byte) $51, (byte) $4e, (byte) $4a, (byte) $47, (byte) $43, (byte) $40, (byte) $3c, (byte) $38, (byte) $35, (byte) $31, (byte) $2d, (byte) $29, (byte) $25, (byte) $21, (byte) $1d, (byte) $19, (byte) $15, (byte) $11, (byte) $c, (byte) 8, (byte) 4, (byte) 0, (byte) $fc, (byte) $f8, (byte) $f4, (byte) $ef, (byte) $eb, (byte) $e7, (byte) $e3, (byte) $df, (byte) $db, (byte) $d7, (byte) $d3, (byte) $cf, (byte) $cb, (byte) $c8, (byte) $c4, (byte) $c0, (byte) $bd, (byte) $b9, (byte) $b6, (byte) $b2, (byte) $af, (byte) $ac, (byte) $a9, (byte) $a6, (byte) $a3, (byte) $a0, (byte) $9d, (byte) $9b, (byte) $98, (byte) $96, (byte) $94, (byte) $92, (byte) $90, (byte) $8e, (byte) $8c, (byte) $8a, (byte) $89, (byte) $87, (byte) $86, (byte) $85, (byte) $84, (byte) $83, (byte) $82, (byte) $82, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $81, (byte) $82, (byte) $82, (byte) $83, (byte) $84, (byte) $85, (byte) $86, (byte) $87, (byte) $89, (byte) $8a, (byte) $8c, (byte) $8e, (byte) $90, (byte) $92, (byte) $94, (byte) $96, (byte) $98, (byte) $9b, (byte) $9d, (byte) $a0, (byte) $a3, (byte) $a6, (byte) $a9, (byte) $ac, (byte) $af, (byte) $b2, (byte) $b6, (byte) $b9, (byte) $bd, (byte) $c0, (byte) $c4, (byte) $c8, (byte) $cb, (byte) $cf, (byte) $d3, (byte) $d7, (byte) $db, (byte) $df, (byte) $e3, (byte) $e7, (byte) $eb, (byte) $ef, (byte) $f4, (byte) $f8, (byte) $fc } +(const word) wavelength = (byte) $c0 reg byte x [ main::i#2 main::i#1 ] reg byte a [ print_char::ch#4 print_char::ch#2 print_char::ch#3 ]