From a579ab491a8789356fb684b269e8fdeb87e7ead3 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 29 Mar 2020 20:22:16 +0200 Subject: [PATCH] Changed pointer and directive parsing to distinguish directives applied to pointers and directives applied to variables. Fixed all example-code to reflect this. Closes #271 --- .../kickc/model/VariableBuilder.java | 2 + .../kickc/model/symbols/Variable.java | 50 +- .../Pass0GenerateStatementSequence.java | 229 +++++--- src/main/kc/stdlib/basic-floats.kc | 4 +- src/main/kc/stdlib/c64.kc | 130 ++--- src/main/kc/stdlib/c64dtv.kc | 98 ++-- src/main/kc/stdlib/fastmultiply.kc | 14 +- .../dk/camelot64/kickc/test/TestPrograms.java | 23 +- src/test/kc/address-0.kc | 2 +- src/test/kc/address-1.kc | 2 +- src/test/kc/address-2.kc | 2 +- src/test/kc/address-3.kc | 2 +- src/test/kc/address-5.kc | 2 +- src/test/kc/address-6.kc | 2 +- src/test/kc/address-of-2.kc | 4 +- src/test/kc/address-of-3.kc | 2 +- src/test/kc/arrays-init-short.kc | 2 +- src/test/kc/arrays-nonstandard-syntax.kc | 2 +- src/test/kc/asm-mnemonic-names.kc | 2 +- src/test/kc/asm-uses-0.kc | 2 +- src/test/kc/bgblacklib.kc | 2 +- src/test/kc/bitmap-circle-2.kc | 6 +- src/test/kc/bitmap-circle.kc | 6 +- src/test/kc/bitmap-line-anim-1.kc | 4 +- src/test/kc/bitmap-line-anim-2.kc | 4 +- src/test/kc/bitmap-plotter.kc | 2 +- src/test/kc/bitwise-not-1.kc | 2 +- src/test/kc/bool-const.kc | 2 +- src/test/kc/bool-ifs-min.kc | 2 +- src/test/kc/bool-ifs.kc | 8 +- src/test/kc/bool-not-operator-1.kc | 2 +- src/test/kc/bool-not-operator-2.kc | 2 +- src/test/kc/bool-not-operator-3.kc | 2 +- src/test/kc/bool-vars.kc | 8 +- src/test/kc/c64dtv-8bppcharstretch.kc | 4 +- src/test/kc/c64dtv-8bppchunkystretch.kc | 2 +- src/test/kc/c64dtv-blitter-box.kc | 2 +- src/test/kc/c64dtv-blittermin.kc | 2 +- src/test/kc/c64dtv-gfxexplorer.kc | 90 +-- src/test/kc/c64dtv-gfxmodes.kc | 66 +-- src/test/kc/call-parameter-autocast.kc | 2 +- src/test/kc/cia-timer-cyclecount.kc | 2 +- src/test/kc/cia-timer-simple.kc | 2 +- src/test/kc/clobber-a-problem.kc | 2 +- src/test/kc/coalesce-assignment.kc | 2 +- src/test/kc/code-after-return-1.kc | 2 +- src/test/kc/code-after-return.kc | 2 +- src/test/kc/comma-decl-2.kc | 2 +- src/test/kc/comma-decl-for.kc | 2 +- src/test/kc/comma-decl.kc | 2 +- src/test/kc/comma-expr-1.kc | 2 +- src/test/kc/comma-expr-2.kc | 2 +- src/test/kc/comma-expr-for.kc | 2 +- src/test/kc/comparison-rewriting-pointer.kc | 4 +- src/test/kc/comparison-rewriting.kc | 2 +- src/test/kc/complex-conditional-problem.kc | 4 +- .../kc/complex/ataritempest/ataritempest.kc | 4 +- .../kc/complex/clearscreen/clearscreen.kc | 4 +- src/test/kc/complex/prebob/grid-bobs.kc | 8 +- src/test/kc/complex/prebob/vogel-bobs.kc | 8 +- src/test/kc/complex/prebob/vogel-sprites.kc | 2 +- .../kc/complex/splines/truetype-splines.kc | 6 +- src/test/kc/complex/tetris/sid.kc | 10 +- src/test/kc/complex/tetris/tetris-data.kc | 12 +- src/test/kc/complex/xmega65/xmega65.kc | 10 +- src/test/kc/complex/xmega65/xmega65logo.kc | 2 +- src/test/kc/condition-integer-0.kc | 2 +- src/test/kc/condition-integer-1.kc | 2 +- src/test/kc/condition-integer-2.kc | 2 +- src/test/kc/condition-integer-3.kc | 2 +- src/test/kc/condition-integer-4.kc | 2 +- src/test/kc/consolidate-constant-problem.kc | 2 +- src/test/kc/const-bool-0.kc | 2 +- src/test/kc/const-condition.kc | 2 +- src/test/kc/const-declaration.kc | 6 +- src/test/kc/const-identification.kc | 4 +- src/test/kc/const-int-cast-problem.kc | 2 +- src/test/kc/const-pointer-modify.kc | 2 +- src/test/kc/constabsmin.kc | 2 +- src/test/kc/constantmin.kc | 2 +- src/test/kc/constants.kc | 2 +- src/test/kc/cordic-atan2-16-ref.kc | 4 +- src/test/kc/cordic-atan2-16.kc | 4 +- src/test/kc/cordic-atan2-clear.kc | 4 +- src/test/kc/cordic-atan2.kc | 4 +- src/test/kc/cpu-6502.kc | 2 +- src/test/kc/danny-joystick-problem.kc | 2 +- src/test/kc/declared-memory-var-0.kc | 2 +- src/test/kc/declared-memory-var-1.kc | 2 +- src/test/kc/declared-memory-var-2.kc | 2 +- src/test/kc/declared-memory-var-3.kc | 2 +- src/test/kc/declared-memory-var-4.kc | 2 +- src/test/kc/declared-memory-var-5.kc | 2 +- src/test/kc/declared-memory-var-6.kc | 2 +- src/test/kc/declared-memory-var-7.kc | 2 +- src/test/kc/declared-memory-var-8.kc | 2 +- src/test/kc/declared-ssa-var-0.kc | 8 +- src/test/kc/deref-to-derefidx-2.kc | 2 +- src/test/kc/deref-to-derefidx.kc | 2 +- src/test/kc/derefidx-word-0.kc | 2 +- src/test/kc/derefidx-word-1.kc | 2 +- src/test/kc/derefidx-word-2.kc | 2 +- src/test/kc/divide-2s.kc | 2 +- src/test/kc/duplicate-loop-problem.kc | 2 +- src/test/kc/dword.kc | 2 +- src/test/kc/encoding-literal-char.kc | 2 +- src/test/kc/enum-0.kc | 2 +- src/test/kc/enum-1.kc | 2 +- src/test/kc/enum-2.kc | 2 +- src/test/kc/enum-3.kc | 2 +- src/test/kc/enum-4.kc | 2 +- src/test/kc/enum-5.kc | 4 +- src/test/kc/enum-6.kc | 2 +- src/test/kc/enum-7.kc | 2 +- src/test/kc/enum-8.kc | 2 +- src/test/kc/enum-err-0.kc | 2 +- src/test/kc/enum-err-1.kc | 2 +- src/test/kc/enum-err-2.kc | 2 +- src/test/kc/euclid-problem-2.kc | 2 +- .../kc/examples/bresenham/bitmap-bresenham.kc | 4 +- src/test/kc/examples/fire/sid.kc | 10 +- src/test/kc/examples/font-2x2/font-2x2.kc | 6 +- src/test/kc/examples/irq/irq-hyperscreen.kc | 2 +- src/test/kc/examples/kernalload/kernalload.kc | 14 +- src/test/kc/examples/music/music.kc | 2 +- src/test/kc/examples/music/music_irq.kc | 2 +- src/test/kc/examples/nmisamples/nmisamples.kc | 2 +- src/test/kc/examples/plasma/plasma-unroll.kc | 4 +- src/test/kc/examples/plasma/plasma.kc | 6 +- src/test/kc/examples/plasma/sid.kc | 10 +- src/test/kc/examples/scroll/scroll.kc | 10 +- .../kc/examples/sinsprites/sinus-sprites.kc | 4 +- src/test/kc/fastmultiply-127.kc | 10 +- src/test/kc/for-empty-increment.kc | 2 +- src/test/kc/for-empty-init.kc | 2 +- src/test/kc/for-ranged-novar.kc | 2 +- src/test/kc/for-two-vars.kc | 2 +- src/test/kc/forrangesymbolic.kc | 2 +- src/test/kc/function-pointer-noarg-2.kc | 6 +- src/test/kc/function-pointer-noarg-3.kc | 6 +- src/test/kc/function-pointer-noarg-call-10.kc | 2 +- src/test/kc/function-pointer-noarg-call-2.kc | 6 +- src/test/kc/function-pointer-noarg-call-3.kc | 4 +- src/test/kc/function-pointer-noarg-call-4.kc | 2 +- src/test/kc/function-pointer-noarg-call-5.kc | 4 +- src/test/kc/function-pointer-noarg-call-7.kc | 2 +- src/test/kc/function-pointer-noarg-call-8.kc | 7 +- src/test/kc/function-pointer-noarg-call-9.kc | 2 +- src/test/kc/function-pointer-noarg-call.kc | 2 +- src/test/kc/function-pointer-noarg.kc | 6 +- src/test/kc/function-pointer-return.kc | 6 +- src/test/kc/gfxbank.kc | 2 +- src/test/kc/global-pc-multiple.kc | 4 +- src/test/kc/global-pc.kc | 4 +- src/test/kc/hex2dec.kc | 6 +- src/test/kc/imported.kc | 2 +- src/test/kc/initializer-0.kc | 2 +- src/test/kc/initializer-1.kc | 2 +- src/test/kc/initializer-2.kc | 2 +- src/test/kc/initializer-3.kc | 2 +- src/test/kc/inline-asm-label.kc | 2 +- src/test/kc/inline-asm-optimized.kc | 2 +- src/test/kc/inline-asm-refout-const.kc | 2 +- src/test/kc/inline-asm-refout-illegal.kc | 2 +- src/test/kc/inline-asm-refout.kc | 2 +- src/test/kc/inline-assignment.kc | 2 +- src/test/kc/inline-kasm-data.kc | 2 +- src/test/kc/inline-kasm-loop.kc | 2 +- src/test/kc/inline-kasm-refout.kc | 2 +- src/test/kc/inline-kasm-resource.kc | 10 +- src/test/kc/inline-string-3.kc | 4 +- src/test/kc/inline-string-4.kc | 2 +- src/test/kc/inline-word.kc | 2 +- src/test/kc/int-conversion.kc | 4 +- src/test/kc/int-literals.kc | 4 +- .../kc/interrupt-volatile-reuse-problem1.kc | 4 +- .../kc/interrupt-volatile-reuse-problem2.kc | 8 +- src/test/kc/irq-hardware-clobber.kc | 22 +- src/test/kc/irq-hardware-stack.kc | 22 +- src/test/kc/irq-hardware.kc | 22 +- src/test/kc/irq-idx-problem.kc | 4 +- src/test/kc/irq-kernel.kc | 14 +- src/test/kc/irq-local-var-overlap-problem.kc | 16 +- src/test/kc/irq-raster.kc | 14 +- src/test/kc/irq-volatile-bool-problem.kc | 14 +- src/test/kc/kickasm-uses-prevent-deletion.kc | 4 +- src/test/kc/literal-char-minus-number.kc | 2 +- src/test/kc/literal-string-array.kc | 4 +- src/test/kc/literal-strings.kc | 2 +- src/test/kc/liverange-1.kc | 2 +- src/test/kc/liverange-10.kc | 2 +- src/test/kc/liverange-2.kc | 2 +- src/test/kc/liverange-3.kc | 2 +- src/test/kc/liverange-4.kc | 2 +- src/test/kc/liverange-5.kc | 2 +- src/test/kc/liverange-6.kc | 2 +- src/test/kc/liverange-7.kc | 2 +- src/test/kc/liverange-8.kc | 2 +- src/test/kc/liverange-9.kc | 2 +- src/test/kc/localscope-loops.kc | 2 +- src/test/kc/localscope-simple.kc | 2 +- src/test/kc/longbranch-interrupt-problem.kc | 4 +- src/test/kc/loop-break-nested.kc | 2 +- src/test/kc/loop-break.kc | 2 +- src/test/kc/loop-continue.kc | 2 +- src/test/kc/loop-for-continue.kc | 2 +- src/test/kc/loop-for-empty-body.kc | 2 +- src/test/kc/loop-problem2.kc | 4 +- src/test/kc/loop-while-continue.kc | 2 +- src/test/kc/loophead-problem-2.kc | 2 +- src/test/kc/loophead-problem.kc | 2 +- src/test/kc/loopnest3.kc | 2 +- src/test/kc/loopsplit.kc | 2 +- src/test/kc/ma_coalesce_problem.kc | 2 +- src/test/kc/memcpy-0.kc | 6 +- src/test/kc/memcpy-1.kc | 2 +- .../kc/millfork-benchmarks/benchcommon.kc | 4 +- src/test/kc/millfork-benchmarks/plasma-kc.kc | 6 +- src/test/kc/millfork-benchmarks/romsum-kc.kc | 2 +- src/test/kc/min-fmul-16.kc | 6 +- src/test/kc/mul8u-min.kc | 2 +- src/test/kc/multiply-2s.kc | 2 +- src/test/kc/multiply-ns.kc | 2 +- src/test/kc/nomodify-3.kc | 2 +- src/test/kc/nomodify-4.kc | 2 +- src/test/kc/nomodify-5.kc | 2 +- src/test/kc/noop-cast-elimination.kc | 2 +- src/test/kc/number-conversion.kc | 4 +- src/test/kc/number-inference-sum.kc | 4 +- src/test/kc/number-ternary-fail.kc | 2 +- src/test/kc/number-type.kc | 4 +- src/test/kc/operator-lohi-problem-1.kc | 2 +- src/test/kc/operator-lohi-problem.kc | 2 +- src/test/kc/optimize-unsigned-comparisons.kc | 2 +- src/test/kc/parse-negated-struct-ref.kc | 2 +- src/test/kc/plasma-center.kc | 6 +- src/test/kc/pointer-cast-2.kc | 4 +- src/test/kc/pointer-cast-3.kc | 2 +- src/test/kc/pointer-const-deep.kc | 7 + src/test/kc/pointer-const-typedef.kc | 43 ++ src/test/kc/pointer-const.kc | 23 + src/test/kc/pointer-plus-0.kc | 2 +- src/test/kc/pointer-pointer-1.kc | 2 +- src/test/kc/pointer-void-0.kc | 2 +- src/test/kc/pointer-void-1.kc | 2 +- src/test/kc/pointer-void-2.kc | 2 +- src/test/kc/pointer-void-3.kc | 2 +- src/test/kc/problem-array-struct-init.kc | 2 +- src/test/kc/problem-inline-struct-return.kc | 2 +- .../kc/procedure-callingconvention-stack-0.kc | 2 +- .../kc/procedure-callingconvention-stack-1.kc | 2 +- .../procedure-callingconvention-stack-10.kc | 2 +- .../procedure-callingconvention-stack-11.kc | 2 +- .../procedure-callingconvention-stack-12.kc | 2 +- .../kc/procedure-callingconvention-stack-2.kc | 2 +- .../kc/procedure-callingconvention-stack-3.kc | 2 +- .../kc/procedure-callingconvention-stack-4.kc | 2 +- .../kc/procedure-callingconvention-stack-5.kc | 2 +- .../kc/procedure-callingconvention-stack-6.kc | 2 +- .../kc/procedure-callingconvention-stack-7.kc | 2 +- .../kc/procedure-callingconvention-stack-8.kc | 2 +- .../kc/procedure-callingconvention-stack-9.kc | 2 +- src/test/kc/processor-port-test.kc | 8 +- src/test/kc/register-0.kc | 2 +- src/test/kc/register-1.kc | 2 +- src/test/kc/reserve-zp-global.kc | 2 +- src/test/kc/reserve-zp-procedure-1.kc | 2 +- src/test/kc/reserve-zp-procedure-2.kc | 2 +- src/test/kc/reserve-zp-procedure-3.kc | 2 +- src/test/kc/sandbox-ternary-error.kc | 2 +- src/test/kc/sandbox.kc | 10 +- src/test/kc/scan-desire-problem.kc | 10 +- src/test/kc/screen-center-angle.kc | 4 +- src/test/kc/screen-center-distance.kc | 4 +- src/test/kc/screen-show-spiral-buckets.kc | 2 +- src/test/kc/screen-show-spiral.kc | 2 +- src/test/kc/sequence-locality-0.kc | 2 +- src/test/kc/sequence-locality-1.kc | 2 +- src/test/kc/sid.kc | 10 +- src/test/kc/sieve-min.kc | 2 +- src/test/kc/sieve.kc | 2 +- src/test/kc/signed-words.kc | 6 +- src/test/kc/simple-loop.kc | 2 +- src/test/kc/sinus-basic.kc | 2 +- src/test/kc/sizeof-arrays.kc | 2 +- src/test/kc/sizeof-expr.kc | 2 +- src/test/kc/sizeof-struct.kc | 2 +- src/test/kc/sizeof-types.kc | 2 +- src/test/kc/sprite-font.kc | 8 +- src/test/kc/stack-relative-addressing.kc | 4 +- src/test/kc/statement-sequence-1.kc | 2 +- src/test/kc/string-escapes-2.kc | 2 +- src/test/kc/struct-0.kc | 2 +- src/test/kc/struct-1.kc | 2 +- src/test/kc/struct-10.kc | 2 +- src/test/kc/struct-11.kc | 2 +- src/test/kc/struct-11b.kc | 2 +- src/test/kc/struct-12.kc | 2 +- src/test/kc/struct-13.kc | 2 +- src/test/kc/struct-14.kc | 2 +- src/test/kc/struct-15.kc | 2 +- src/test/kc/struct-16.kc | 2 +- src/test/kc/struct-17.kc | 2 +- src/test/kc/struct-18.kc | 2 +- src/test/kc/struct-19.kc | 2 +- src/test/kc/struct-2.kc | 2 +- src/test/kc/struct-20.kc | 2 +- src/test/kc/struct-21.kc | 2 +- src/test/kc/struct-22.kc | 2 +- src/test/kc/struct-23.kc | 2 +- src/test/kc/struct-24.kc | 2 +- src/test/kc/struct-25.kc | 2 +- src/test/kc/struct-26.kc | 2 +- src/test/kc/struct-27.kc | 2 +- src/test/kc/struct-28.kc | 2 +- src/test/kc/struct-29.kc | 2 +- src/test/kc/struct-3.kc | 2 +- src/test/kc/struct-30.kc | 2 +- src/test/kc/struct-31.kc | 2 +- src/test/kc/struct-32.kc | 2 +- src/test/kc/struct-33.kc | 2 +- src/test/kc/struct-34.kc | 2 +- src/test/kc/struct-35.kc | 2 +- src/test/kc/struct-36.kc | 2 +- src/test/kc/struct-37.kc | 2 +- src/test/kc/struct-38.kc | 2 +- src/test/kc/struct-39.kc | 2 +- src/test/kc/struct-4.kc | 2 +- src/test/kc/struct-40.kc | 2 +- src/test/kc/struct-41.kc | 2 +- src/test/kc/struct-42.kc | 2 +- src/test/kc/struct-5.kc | 2 +- src/test/kc/struct-6.kc | 2 +- src/test/kc/struct-7.kc | 2 +- src/test/kc/struct-8.kc | 2 +- src/test/kc/struct-9.kc | 2 +- src/test/kc/struct-err-1.kc | 2 +- src/test/kc/struct-err-2.kc | 2 +- src/test/kc/struct-err-3.kc | 2 +- src/test/kc/struct-err-4.kc | 2 +- src/test/kc/struct-err-5.kc | 2 +- src/test/kc/struct-error-6.kc | 2 +- src/test/kc/struct-ptr-0.kc | 2 +- src/test/kc/struct-ptr-1.kc | 2 +- src/test/kc/struct-ptr-10.kc | 2 +- src/test/kc/struct-ptr-11.kc | 2 +- src/test/kc/struct-ptr-12-ref.kc | 2 +- src/test/kc/struct-ptr-12.kc | 2 +- src/test/kc/struct-ptr-13.kc | 2 +- src/test/kc/struct-ptr-14.kc | 2 +- src/test/kc/struct-ptr-15.kc | 2 +- src/test/kc/struct-ptr-16.kc | 2 +- src/test/kc/struct-ptr-17.kc | 2 +- src/test/kc/struct-ptr-18.kc | 2 +- src/test/kc/struct-ptr-19.kc | 2 +- src/test/kc/struct-ptr-2.kc | 2 +- src/test/kc/struct-ptr-20.kc | 2 +- src/test/kc/struct-ptr-21.kc | 2 +- src/test/kc/struct-ptr-23.kc | 2 +- src/test/kc/struct-ptr-28.kc | 2 +- src/test/kc/struct-ptr-29.kc | 2 +- src/test/kc/struct-ptr-3.kc | 2 +- src/test/kc/struct-ptr-30.kc | 2 +- src/test/kc/struct-ptr-31.kc | 2 +- src/test/kc/struct-ptr-32.kc | 2 +- src/test/kc/struct-ptr-33.kc | 2 +- src/test/kc/struct-ptr-34.kc | 2 +- src/test/kc/struct-ptr-4.kc | 2 +- src/test/kc/struct-ptr-5.kc | 2 +- src/test/kc/struct-ptr-6.kc | 2 +- src/test/kc/struct-ptr-7.kc | 2 +- src/test/kc/struct-ptr-8.kc | 2 +- src/test/kc/struct-ptr-9.kc | 2 +- src/test/kc/switch-0.kc | 2 +- src/test/kc/switch-1.kc | 2 +- src/test/kc/switch-4.kc | 2 +- src/test/kc/ternary-1.kc | 2 +- src/test/kc/ternary-2.kc | 2 +- src/test/kc/ternary-3.kc | 2 +- src/test/kc/ternary-4.kc | 2 +- src/test/kc/ternary-inference.kc | 2 +- src/test/kc/test-comments-block.kc | 2 +- src/test/kc/test-comments-loop.kc | 2 +- src/test/kc/test-comments-single.kc | 2 +- src/test/kc/test-comments-usage.kc | 2 +- src/test/kc/test-interrupt-notype.kc | 6 +- src/test/kc/test-interrupt-volatile-write.kc | 4 +- src/test/kc/test-interrupt-volatile.kc | 4 +- src/test/kc/test-interrupt.kc | 6 +- src/test/kc/test-scroll-up.kc | 2 +- src/test/kc/textbox.kc | 2 +- src/test/kc/tod018-problem.kc | 4 +- src/test/kc/tofewparams.kc | 2 +- src/test/kc/tomanyparams.kc | 2 +- src/test/kc/type-inference.kc | 2 +- src/test/kc/type-promotion-bool-param.kc | 2 +- src/test/kc/type-promotion-schar-param.kc | 2 +- src/test/kc/typedef-2.kc | 2 +- src/test/kc/typedef-3.kc | 2 +- src/test/kc/typeid-plus-byte-problem.kc | 2 +- src/test/kc/typeid-plus-bytes.kc | 4 +- src/test/kc/typeid-simple.kc | 2 +- src/test/kc/typemismatch.kc | 2 +- src/test/kc/uninitialized.kc | 2 +- src/test/kc/unused-irq.kc | 4 +- src/test/kc/unused-vars.kc | 4 +- src/test/kc/var-forward-problem.kc | 2 +- src/test/kc/varmodel-ma_mem-5.kc | 2 +- src/test/kc/varmodel-unknown.kc | 2 +- src/test/kc/void-parameter.kc | 2 +- src/test/kc/volatile-0.kc | 2 +- src/test/kc/volatile-1.kc | 2 +- src/test/kc/volatile-2.kc | 2 +- src/test/kc/word-array-0.kc | 2 +- src/test/kc/word-array-1.kc | 2 +- src/test/kc/word-array-2.kc | 2 +- src/test/kc/word-pointer-compound.kc | 2 +- src/test/kc/word-pointer-iteration-0.kc | 2 +- src/test/kc/word-pointer-iteration.kc | 2 +- src/test/kc/word-pointer-math-0.kc | 2 +- src/test/kc/word-pointer-math-1.kc | 2 +- src/test/kc/word-pointer-math.kc | 2 +- src/test/kc/zeropage-exhausted.kc | 2 +- src/test/kc/zeropage-sinus.kc | 2 +- src/test/ref/pointer-const-typedef.asm | 48 ++ src/test/ref/pointer-const-typedef.cfg | 25 + src/test/ref/pointer-const-typedef.log | 488 ++++++++++++++++ src/test/ref/pointer-const-typedef.sym | 17 + src/test/ref/pointer-const.asm | 43 ++ src/test/ref/pointer-const.cfg | 34 ++ src/test/ref/pointer-const.log | 542 ++++++++++++++++++ src/test/ref/pointer-const.sym | 22 + 432 files changed, 2341 insertions(+), 908 deletions(-) create mode 100644 src/test/kc/pointer-const-deep.kc create mode 100644 src/test/kc/pointer-const-typedef.kc create mode 100644 src/test/kc/pointer-const.kc create mode 100644 src/test/ref/pointer-const-typedef.asm create mode 100644 src/test/ref/pointer-const-typedef.cfg create mode 100644 src/test/ref/pointer-const-typedef.log create mode 100644 src/test/ref/pointer-const-typedef.sym create mode 100644 src/test/ref/pointer-const.asm create mode 100644 src/test/ref/pointer-const.cfg create mode 100644 src/test/ref/pointer-const.log create mode 100644 src/test/ref/pointer-const.sym diff --git a/src/main/java/dk/camelot64/kickc/model/VariableBuilder.java b/src/main/java/dk/camelot64/kickc/model/VariableBuilder.java index 1c6aacfd3..0e6235b52 100644 --- a/src/main/java/dk/camelot64/kickc/model/VariableBuilder.java +++ b/src/main/java/dk/camelot64/kickc/model/VariableBuilder.java @@ -61,6 +61,8 @@ public class VariableBuilder { variable.setVolatile(this.isVolatile()); variable.setExport(this.isExport()); variable.setPermanent(this.isPermanent()); + variable.setToNoModify(this.isToNoModify()); + variable.setToVolatile(this.isToVolatile()); variable.setOptimize(this.isOptimize()); variable.setRegister(this.getRegister()); if(variable.getRegister() instanceof Registers.RegisterMainMem) { diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java b/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java index 383e61f70..4e4ffa5da 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java @@ -68,6 +68,12 @@ public class Variable implements Symbol { /** Specifies that the variable must always live in memory to be available for any multi-threaded accees (eg. in interrupts). (volatile keyword) [Only Variables] */ private boolean isVolatile; + /** Specifies that the variable points to a volatile. (volatile* keyword) */ + private boolean isToVolatile; + + /** Specifies that the variable points to a a nomodify. (const* keyword) */ + private boolean isToNoModify; + /** Specifies that the variable must always be added to the output ASM even if it is never used anywhere. (export keyword) */ private boolean export; @@ -188,6 +194,8 @@ public class Variable implements Symbol { version.setNoModify(phiMaster.isNoModify()); version.setRegister(phiMaster.getRegister()); version.setVolatile(phiMaster.isVolatile()); + version.setToNoModify(phiMaster.isToNoModify()); + version.setToVolatile(phiMaster.isToVolatile()); version.setPermanent(phiMaster.isPermanent()); version.setExport(phiMaster.isExport()); version.setComments(phiMaster.getComments()); @@ -232,6 +240,8 @@ public class Variable implements Symbol { constVar.setNoModify(variable.isNoModify()); constVar.setRegister(variable.getRegister()); constVar.setVolatile(variable.isVolatile()); + constVar.setToNoModify(variable.isToNoModify()); + constVar.setToVolatile(variable.isToVolatile()); constVar.setPermanent(variable.isPermanent()); constVar.setExport(variable.isExport()); constVar.setComments(variable.getComments()); @@ -252,6 +262,8 @@ public class Variable implements Symbol { copy.setNoModify(original.isNoModify()); copy.setPermanent(original.isPermanent()); copy.setVolatile(original.isVolatile()); + copy.setToNoModify(original.isToNoModify()); + copy.setToVolatile(original.isToVolatile()); copy.setExport(original.isExport()); copy.setRegister(original.getRegister()); copy.setComments(original.getComments()); @@ -282,6 +294,8 @@ public class Variable implements Symbol { } memberVariable.setVolatile(structVar.isVolatile()); memberVariable.setNoModify(structVar.isNoModify()); + memberVariable.setToNoModify(structVar.isToNoModify()); + memberVariable.setToVolatile(structVar.isToVolatile()); memberVariable.setExport(structVar.isExport()); memberVariable.setPermanent(structVar.isPermanent()); return memberVariable; @@ -479,14 +493,6 @@ public class Variable implements Symbol { this.noModify = noModify; } - public boolean isPermanent() { - return permanent; - } - - public void setPermanent(boolean permanent) { - this.permanent = permanent; - } - public boolean isVolatile() { return isVolatile; } @@ -495,6 +501,30 @@ public class Variable implements Symbol { this.isVolatile = aVolatile; } + public boolean isToNoModify() { + return isToNoModify; + } + + public void setToNoModify(boolean toNoModify) { + isToNoModify = toNoModify; + } + + public boolean isToVolatile() { + return isToVolatile; + } + + public void setToVolatile(boolean toVolatile) { + isToVolatile = toVolatile; + } + + public boolean isPermanent() { + return permanent; + } + + public void setPermanent(boolean permanent) { + this.permanent = permanent; + } + public boolean isExport() { return export; } @@ -582,6 +612,10 @@ public class Variable implements Symbol { return new StringBuilder() .append("(") .append(isKindConstant() ? "const " : "") + //.append(isNoModify() ? "nomodify " : "") + //.append(isVolatile() ? "volatile " : "") + //.append(isToNoModify() ? "to_nomodify " : "") + //.append(isToVolatile() ? "to_volatile " : "") .append(getType().getTypeName()) .append(isKindIntermediate() ? "~" : "") .append(") ") diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java index a81430499..d20890125 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java @@ -536,119 +536,207 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor directives = null; + /** Holds directives that are not part of the type-spec (all other than const & volatile) when descending into a Variable Declaration. (type level) */ + private List declDirectives = null; /** Holds the declared comments when descending into a Variable Declaration. (type level) */ - private List comments = null; - - /** Holds the type when diving into a single variable. (variable level) */ - private SymbolType varType = null; - /** Holds the array information for a single variable. (variable level) */ - private ArraySpec varArraySpec; - /** Holds the declared directives for a single variable. (variable level) */ - private List varDirectives = null; + private List declComments = null; + /** The declared type (type level) */ + private VariableDeclType declType; + /** The declared type (variable level) */ + private VariableDeclType varDeclType; /** - * Exits the type layer (clears everyting except struct information) + * Exits the type layer (clears everything except struct information) */ void exitType() { - exitVar(); - this.type = null; - this.directives = null; - this.arraySpec = null; - this.comments = null; + this.declDirectives = null; + this.declComments = null; + this.declType = null; + this.varDeclType = null; } /** * Exits the variable layer (clears variable information) */ void exitVar() { - this.varType = null; - this.varArraySpec = null; - this.varDirectives = null; + this.varDeclType = null; + } + + /** The declared type of a variable. Combines SymbolType, type directives (const, volatile) and ArraySpec. It holds advanced type information like

char volatile * const * [42] */ + static class VariableDeclType { + /** The type. */ + SymbolType type; + /** The array specification (non-null if it is an array, also holds size) */ + ArraySpec arraySpec; + /** Const / Volatile Directives if applied to the type */ + List typeDirectives; + /** If the type is SymbolTypePointer this holds the declaration type of the elements. */ + VariableDeclType elementDeclType; + + public VariableDeclType(SymbolType type) { + this.type = type; + this.typeDirectives = new ArrayList<>(); + } + + public SymbolType getType() { + return type; + } + + public ArraySpec getArraySpec() { + return arraySpec; + } + + public List getTypeDirectives() { + return typeDirectives; + } + + public void setTypeDirectives(List directives) { + this.typeDirectives = directives; + } + + public void setElementDeclType(VariableDeclType elementDeclType) { + this.elementDeclType = elementDeclType; + } + + public void setArraySpec(ArraySpec arraySpec) { + this.arraySpec = arraySpec; + } + + public VariableDeclType getElementDeclType() { + return elementDeclType; + } + } + + VariableDeclType getEffectiveDeclType() { + return varDeclType != null ? varDeclType : declType; } SymbolType getEffectiveType() { - return varType != null ? varType : type; + if(varDeclType != null) + return varDeclType.getType(); + if(declType != null) + return declType.getType(); + return null; } ArraySpec getEffectiveArraySpec() { - return varArraySpec != null ? varArraySpec : arraySpec; + return varDeclType != null ? varDeclType.getArraySpec() : declType.getArraySpec(); + } + + /** + * Set type-level directives. Splits directives into type-directives (const, volatile) and general directives (all other). + * + * @param directives The directives + */ + void setDeclDirectives(List directives) { + this.declDirectives = new ArrayList<>(); + for(Directive directive : directives) { + if(directive instanceof Directive.Const || directive instanceof Directive.Volatile) { + // Type directive + this.declType.getTypeDirectives().add(directive); + } else { + // general directive + this.declDirectives.add(directive); + } + } } List getEffectiveDirectives() { final ArrayList dirs = new ArrayList<>(); - if(directives != null) - dirs.addAll(directives); - if(varDirectives != null) - dirs.addAll(varDirectives); + // Add all general directives + dirs.addAll(declDirectives); + // Add type-directives + final VariableDeclType effectiveDeclType = getEffectiveDeclType(); + dirs.addAll(effectiveDeclType.getTypeDirectives()); + // Convert element directives + final VariableDeclType elementDeclType = effectiveDeclType.getElementDeclType(); + if(elementDeclType != null) { + for(Directive elementTypeDirective : elementDeclType.getTypeDirectives()) { + if(elementTypeDirective instanceof Directive.Const) { + dirs.add(new Directive.ToConst()); + } else if(elementTypeDirective instanceof Directive.Volatile) { + dirs.add(new Directive.ToVolatile()); + } + } + // Produce error on any deeper directives + VariableDeclType deepDeclType = elementDeclType.getElementDeclType(); + while(deepDeclType != null) { + if(!deepDeclType.getTypeDirectives().isEmpty()) { + throw new CompileError("Deep const/volatile not supported."); + } + deepDeclType = deepDeclType.getElementDeclType(); + } + } return dirs; } - public List getComments() { - return comments; + public List getDeclComments() { + return declComments; } boolean isStructMember() { return structMember; } - public void setType(SymbolType type) { - this.type = type; + public VariableDeclType getDeclType() { + return declType; } - void setArraySpec(ArraySpec arraySpec) { - this.arraySpec = arraySpec; + public void setDeclType(SymbolType type) { + this.declType = new VariableDeclType(type); } - void setDirectives(List directives) { - this.directives = directives; + public void setVarDeclType(VariableDeclType varDeclType) { + this.varDeclType = varDeclType; } - public void setComments(List comments) { - this.comments = comments; + public VariableDeclType getVarDeclType() { + return varDeclType; + } + + public void setDeclComments(List declComments) { + this.declComments = declComments; } void setStructMember(boolean structMember) { this.structMember = structMember; } - void setVarArraySpec(ArraySpec varArraySpec) { - this.varArraySpec = varArraySpec; - } - - void setVarType(SymbolType varType) { - this.varType = varType; - } } private VariableDeclaration varDecl = new VariableDeclaration(); @Override public Object visitDeclPointer(KickCParser.DeclPointerContext ctx) { - if(!ctx.directive().isEmpty()) { - throw new InternalError("Not implemented!"); - } - varDecl.setVarType(new SymbolTypePointer(varDecl.getEffectiveType())); + // Detect char * const * x; + //if(varDecl.getDeclDirectives()!=null && !varDecl.getDeclDirectives().isEmpty()) { + // throw new CompileError("Pointer directives (const/volatile) not supported between pointers.", new StatementSource(ctx.getParent().getParent())); + //}; + // Create a var-level declaration type + final VariableDeclaration.VariableDeclType elementDeclType = varDecl.getEffectiveDeclType(); + VariableDeclaration.VariableDeclType pointerDeclType = new VariableDeclaration.VariableDeclType(new SymbolTypePointer(elementDeclType.getType())); + pointerDeclType.setElementDeclType(elementDeclType); + final List typeDirectives = getDirectives(ctx.directive()); + pointerDeclType.setTypeDirectives(typeDirectives); + varDecl.setVarDeclType(pointerDeclType); return null; } @Override public Object visitDeclArray(KickCParser.DeclArrayContext ctx) { // Handle array type declaration by updating the declared type and the array spec - SymbolType elementType = varDecl.getEffectiveType(); + ArraySpec arraySpec; if(ctx.expr() != null) { RValue sizeVal = (RValue) visit(ctx.expr()); - varDecl.setVarArraySpec(new ArraySpec((ConstantValue) sizeVal)); - varDecl.setVarType(new SymbolTypePointer(elementType)); + arraySpec = new ArraySpec((ConstantValue) sizeVal); } else { - varDecl.setVarArraySpec(new ArraySpec()); - varDecl.setVarType(new SymbolTypePointer(elementType)); + arraySpec = new ArraySpec(); } + final VariableDeclaration.VariableDeclType elementDeclType = varDecl.getEffectiveDeclType(); + VariableDeclaration.VariableDeclType arrayDeclType = new VariableDeclaration.VariableDeclType(new SymbolTypePointer(elementDeclType.getType())); + arrayDeclType.setElementDeclType(elementDeclType); + arrayDeclType.setArraySpec(arraySpec); + varDecl.setVarDeclType(arrayDeclType); return null; } @@ -662,9 +750,9 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor directive = ctx.directive(); varDecl.exitType(); - varDecl.setType((SymbolType) visit(ctx.type())); - varDecl.setDirectives(getDirectives(directive)); - varDecl.setComments(getCommentsSymbol(ctx.getParent())); + varDecl.setDeclType((SymbolType) visit(ctx.type())); + varDecl.setDeclDirectives(getDirectives(directive)); + varDecl.setDeclComments(getCommentsSymbol(ctx.getParent())); return null; } @@ -713,9 +801,9 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitorm = (>m)-(byte)b; @@ -117,9 +117,9 @@ signed word mulf8s(signed byte a, signed byte b) { // Fast multiply two unsigned words to a double word result // Done in assembler to utilize fast addition A+X dword mulf16u(word a, word b) { - const word* memA = $f8; - const word* memB = $fa; - const dword* memR = $fc; + word* const memA = $f8; + word* const memB = $fa; + dword* const memR = $fc; *memA = a; *memB = b; asm { diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 2d14c446f..7238b850f 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -942,10 +942,10 @@ public class TestPrograms { compileAndCompare("enum-0"); } - @Test - public void testTypedef3() throws IOException, URISyntaxException { - compileAndCompare("typedef-3"); - } + //@Test + //public void testTypedef3() throws IOException, URISyntaxException { + // compileAndCompare("typedef-3"); + //} @Test public void testTypedef2() throws IOException, URISyntaxException { @@ -1777,6 +1777,21 @@ public class TestPrograms { compileAndCompare("sandbox"); } + @Test + public void testPointerConstDeep() throws IOException, URISyntaxException { + assertError("pointer-const-deep", "Deep const/volatile not supported"); + } + + @Test + public void testPointerConstTypedef() throws IOException, URISyntaxException { + compileAndCompare("pointer-const-typedef"); + } + + @Test + public void testPointerConst() throws IOException, URISyntaxException { + compileAndCompare("pointer-const"); + } + @Test public void testPointerCast4() throws IOException, URISyntaxException { compileAndCompare("pointer-cast-4"); diff --git a/src/test/kc/address-0.kc b/src/test/kc/address-0.kc index df9d259ce..3e9edf129 100644 --- a/src/test/kc/address-0.kc +++ b/src/test/kc/address-0.kc @@ -1,7 +1,7 @@ // Test that address vars are turned into load/store and located at hardcoded addresses // Hard-coded zero-page address - global variable -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char __address(0x02) i = 3; diff --git a/src/test/kc/address-1.kc b/src/test/kc/address-1.kc index a078554df..f524a6bc7 100644 --- a/src/test/kc/address-1.kc +++ b/src/test/kc/address-1.kc @@ -1,7 +1,7 @@ // Test that address vars are turned into load/store and located at hardcoded addresses // Hard-coded zero-page address - local variable -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { diff --git a/src/test/kc/address-2.kc b/src/test/kc/address-2.kc index 33fe5e0ee..69fe42c15 100644 --- a/src/test/kc/address-2.kc +++ b/src/test/kc/address-2.kc @@ -1,7 +1,7 @@ // Test that address vars are turned into load/store and located at hardcoded addresses // Hard-coded mainmem-page address - global variable -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char __address(0x2000) i = 3; diff --git a/src/test/kc/address-3.kc b/src/test/kc/address-3.kc index f599ebed4..ff9c9dc41 100644 --- a/src/test/kc/address-3.kc +++ b/src/test/kc/address-3.kc @@ -1,7 +1,7 @@ // Test that address vars are turned into load/store and located at hardcoded addresses // Hard-coded mainmem address - local variable -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { char __address(0x2000) i = 3; diff --git a/src/test/kc/address-5.kc b/src/test/kc/address-5.kc index 91ca7cece..45f57fcbd 100644 --- a/src/test/kc/address-5.kc +++ b/src/test/kc/address-5.kc @@ -7,7 +7,7 @@ void main() { print('l'); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; volatile char __address(0x03) idx; diff --git a/src/test/kc/address-6.kc b/src/test/kc/address-6.kc index 13bab1790..2df4ee1ec 100644 --- a/src/test/kc/address-6.kc +++ b/src/test/kc/address-6.kc @@ -7,7 +7,7 @@ void main() { print('l'); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; volatile char __address(0x3000) idx; diff --git a/src/test/kc/address-of-2.kc b/src/test/kc/address-of-2.kc index 0f66172f3..8ad5e03b6 100644 --- a/src/test/kc/address-of-2.kc +++ b/src/test/kc/address-of-2.kc @@ -3,8 +3,8 @@ byte val = 0; void main() { - const byte* SCREEN1 = 0x0400; - const byte* SCREEN2 = SCREEN1+40; + byte* const SCREEN1 = 0x0400; + byte* const SCREEN2 = SCREEN1+40; byte idx = 0; SCREEN1[idx] = val; SCREEN2[idx++] = '.'; diff --git a/src/test/kc/address-of-3.kc b/src/test/kc/address-of-3.kc index 1a4a35aea..422d84a13 100644 --- a/src/test/kc/address-of-3.kc +++ b/src/test/kc/address-of-3.kc @@ -11,7 +11,7 @@ void main() { } -const int* SCREEN = 0x0400; +int* const SCREEN = 0x0400; char idx = 0; void print(int* p) { diff --git a/src/test/kc/arrays-init-short.kc b/src/test/kc/arrays-init-short.kc index 59e0113b5..37facaf30 100644 --- a/src/test/kc/arrays-init-short.kc +++ b/src/test/kc/arrays-init-short.kc @@ -3,7 +3,7 @@ char msg1[16] ="camelot"; char msg2[16] = { 'c', 'm', 'l' }; -const char* SCREEN = 0x400; +char* const SCREEN = 0x400; void main() { for(char i=0;msg1[i];i++) diff --git a/src/test/kc/arrays-nonstandard-syntax.kc b/src/test/kc/arrays-nonstandard-syntax.kc index ac61837d3..e678021e8 100644 --- a/src/test/kc/arrays-nonstandard-syntax.kc +++ b/src/test/kc/arrays-nonstandard-syntax.kc @@ -2,7 +2,7 @@ char[16] msg ="camelot"; -const char* SCREEN = 0x400; +char* const SCREEN = 0x400; void main() { for(char i=0;msg[i];i++) diff --git a/src/test/kc/asm-mnemonic-names.kc b/src/test/kc/asm-mnemonic-names.kc index 3759d080b..bc438c6bf 100644 --- a/src/test/kc/asm-mnemonic-names.kc +++ b/src/test/kc/asm-mnemonic-names.kc @@ -1,7 +1,7 @@ // Test using an ASM mnemonic as a C symbol names // Works if the C-lexer and the ASM-lexer are separated properly -const char* lda = 0x0400; +char* const lda = 0x0400; void main() { char jmp = 1; diff --git a/src/test/kc/asm-uses-0.kc b/src/test/kc/asm-uses-0.kc index f99f994aa..78d75ccd1 100644 --- a/src/test/kc/asm-uses-0.kc +++ b/src/test/kc/asm-uses-0.kc @@ -6,7 +6,7 @@ void main() { } } -const char* BGCOL = 0xd020; +char* const BGCOL = 0xd020; // Function only used inside the inline asm void init() { diff --git a/src/test/kc/bgblacklib.kc b/src/test/kc/bgblacklib.kc index 2977f694d..9ff84f45a 100644 --- a/src/test/kc/bgblacklib.kc +++ b/src/test/kc/bgblacklib.kc @@ -1,2 +1,2 @@ -const char* BGCOL = 0xd021; +char* const BGCOL = 0xd021; const char BLACK = 0x00; \ No newline at end of file diff --git a/src/test/kc/bitmap-circle-2.kc b/src/test/kc/bitmap-circle-2.kc index 21cd5f587..1fd02c244 100644 --- a/src/test/kc/bitmap-circle-2.kc +++ b/src/test/kc/bitmap-circle-2.kc @@ -1,8 +1,8 @@ import "c64" -const byte* SCREEN = $400; -const byte* BITMAP = $2000; -const byte* COLORS = $d800; +byte* const SCREEN = $400; +byte* const BITMAP = $2000; +byte* const COLORS = $d800; byte bitmask[] = { 128, 64, 32, 16, 8, 4, 2, 1 }; diff --git a/src/test/kc/bitmap-circle.kc b/src/test/kc/bitmap-circle.kc index 9234c5c5c..297a815d4 100644 --- a/src/test/kc/bitmap-circle.kc +++ b/src/test/kc/bitmap-circle.kc @@ -4,9 +4,9 @@ import "c64" -const byte* SCREEN = $400; -const byte* BITMAP = $2000; -const byte* COLORS = $d800; +byte* const SCREEN = $400; +byte* const BITMAP = $2000; +byte* const COLORS = $d800; byte bitmask[] = { 128, 64, 32, 16, 8, 4, 2, 1 }; diff --git a/src/test/kc/bitmap-line-anim-1.kc b/src/test/kc/bitmap-line-anim-1.kc index 745fb8063..f0fcc1455 100644 --- a/src/test/kc/bitmap-line-anim-1.kc +++ b/src/test/kc/bitmap-line-anim-1.kc @@ -4,8 +4,8 @@ import "c64.kc" import "bitmap-draw.kc" -const byte* SCREEN = $400; -const byte* BITMAP = $2000; +byte* const SCREEN = $400; +byte* const BITMAP = $2000; byte next=0; diff --git a/src/test/kc/bitmap-line-anim-2.kc b/src/test/kc/bitmap-line-anim-2.kc index 47ba74b75..36ce4875e 100644 --- a/src/test/kc/bitmap-line-anim-2.kc +++ b/src/test/kc/bitmap-line-anim-2.kc @@ -4,8 +4,8 @@ import "c64.kc" import "bitmap2.kc" -const byte* SCREEN = $400; -const byte* BITMAP = $2000; +byte* const SCREEN = $400; +byte* const BITMAP = $2000; word next=0; diff --git a/src/test/kc/bitmap-plotter.kc b/src/test/kc/bitmap-plotter.kc index 0fbdda706..e840c7994 100644 --- a/src/test/kc/bitmap-plotter.kc +++ b/src/test/kc/bitmap-plotter.kc @@ -16,7 +16,7 @@ byte* COLS = $d800; byte* SCREEN = $400; -const byte* BITMAP = $2000; +byte* const BITMAP = $2000; void main() { *BGCOL = 0; diff --git a/src/test/kc/bitwise-not-1.kc b/src/test/kc/bitwise-not-1.kc index 1656db490..eb2401aa7 100644 --- a/src/test/kc/bitwise-not-1.kc +++ b/src/test/kc/bitwise-not-1.kc @@ -1,7 +1,7 @@ // Test that bitwise NOT (~) is handled correctly void main() { - const char* screen = 0x0400; + char* const screen = 0x0400; char b = ~0x10; *screen = b; } \ No newline at end of file diff --git a/src/test/kc/bool-const.kc b/src/test/kc/bool-const.kc index edd95d909..406e3a79d 100644 --- a/src/test/kc/bool-const.kc +++ b/src/test/kc/bool-const.kc @@ -1,6 +1,6 @@ // A Minimal test of boolean constants. -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { bool_const_if(); diff --git a/src/test/kc/bool-ifs-min.kc b/src/test/kc/bool-ifs-min.kc index b5ee3cc2a..8fdc4def9 100644 --- a/src/test/kc/bool-ifs-min.kc +++ b/src/test/kc/bool-ifs-min.kc @@ -1,7 +1,7 @@ // A test of boolean conditions using && || and ! void main() { - const char* screen = 0x400; + char* const screen = 0x400; for( char i : 0..20) { if( (i<10) && ((i&1)==0) ) { screen[i] = '*'; diff --git a/src/test/kc/bool-ifs.kc b/src/test/kc/bool-ifs.kc index 06fb48134..aed29d918 100644 --- a/src/test/kc/bool-ifs.kc +++ b/src/test/kc/bool-ifs.kc @@ -8,7 +8,7 @@ void main() { } void bool_and() { - const byte* screen = $400; + byte* const screen = $400; for( byte i : 0..20) { if( (i<10) && ((i&1)==0) ) { screen[i] = '*'; @@ -19,7 +19,7 @@ void bool_and() { } void bool_or() { - const byte* screen = $428; + byte* const screen = $428; for( byte i : 0..20) { if( (i<10) || ((i&1)==0) ) { screen[i] = '*'; @@ -30,7 +30,7 @@ void bool_or() { } void bool_not() { - const byte* screen = $450; + byte* const screen = $450; for( byte i : 0..20) { if( !((i<10) || (i&1)==0)) { screen[i] = '*'; @@ -41,7 +41,7 @@ void bool_not() { } void bool_complex() { - const byte* screen = $478; + byte* const screen = $478; for( byte i : 0..20) { if( ((i<10) && (i&1)==0) || !((i<10) || (i&1)==0) ) { screen[i] = '*'; diff --git a/src/test/kc/bool-not-operator-1.kc b/src/test/kc/bool-not-operator-1.kc index 2e23bc351..f52d7b86e 100644 --- a/src/test/kc/bool-not-operator-1.kc +++ b/src/test/kc/bool-not-operator-1.kc @@ -4,7 +4,7 @@ // https://gitlab.com/camelot/kickc/issues/199 void main() { - const char* screen = 0x0400; + char* const screen = 0x0400; for(char i: 0..7) { bool b = (i&1)==1; char c = !b ? 1 : 0 ; diff --git a/src/test/kc/bool-not-operator-2.kc b/src/test/kc/bool-not-operator-2.kc index b056c649a..099105a49 100644 --- a/src/test/kc/bool-not-operator-2.kc +++ b/src/test/kc/bool-not-operator-2.kc @@ -4,7 +4,7 @@ // https://gitlab.com/camelot/kickc/issues/199 void main() { - const char* screen = 0x0400; + char* const screen = 0x0400; for(char i: 0..7) { char b = i&1; char c = !b ? 1 : 0 ; diff --git a/src/test/kc/bool-not-operator-3.kc b/src/test/kc/bool-not-operator-3.kc index e53497cbf..dcf5c457e 100644 --- a/src/test/kc/bool-not-operator-3.kc +++ b/src/test/kc/bool-not-operator-3.kc @@ -4,7 +4,7 @@ // https://gitlab.com/camelot/kickc/issues/295 void main() { - const char* screen = 0x0400; + char* const screen = 0x0400; for(char i: 0..7) { char b = (i&1); screen[i] = !b; diff --git a/src/test/kc/bool-vars.kc b/src/test/kc/bool-vars.kc index 12ad08ef3..631b9309d 100644 --- a/src/test/kc/bool-vars.kc +++ b/src/test/kc/bool-vars.kc @@ -8,7 +8,7 @@ void main() { } void bool_and() { - const byte* screen = $400; + byte* const screen = $400; for( byte i : 0..20) { bool o1 = (i<10); bool o2 = ((i&1)==0); @@ -22,7 +22,7 @@ void bool_and() { } void bool_or() { - const byte* screen = $428; + byte* const screen = $428; for( byte i : 0..20) { bool o1 = (i<10); bool o2 = ((i&1)==0); @@ -36,7 +36,7 @@ void bool_or() { } void bool_not() { - const byte* screen = $450; + byte* const screen = $450; for( byte i : 0..20) { bool o1 = (i<10); bool o2 = (i&1)==0; @@ -50,7 +50,7 @@ void bool_not() { } void bool_complex() { - const byte* screen = $478; + byte* const screen = $478; for( byte i : 0..20) { bool o1 = (i<10); bool o2 = (i&1)==0; diff --git a/src/test/kc/c64dtv-8bppcharstretch.kc b/src/test/kc/c64dtv-8bppcharstretch.kc index c835e14cf..540f5cc72 100644 --- a/src/test/kc/c64dtv-8bppcharstretch.kc +++ b/src/test/kc/c64dtv-8bppcharstretch.kc @@ -2,9 +2,9 @@ import "c64dtv.kc" // Plane with the screen -const byte* SCREEN = $7c00; +byte* const SCREEN = $7c00; // Plane with all pixels -const byte* CHARSET8 = $8000; +byte* const CHARSET8 = $8000; void main() { asm { sei } // Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal) diff --git a/src/test/kc/c64dtv-8bppchunkystretch.kc b/src/test/kc/c64dtv-8bppchunkystretch.kc index 58c3744fe..d140518bf 100644 --- a/src/test/kc/c64dtv-8bppchunkystretch.kc +++ b/src/test/kc/c64dtv-8bppchunkystretch.kc @@ -2,7 +2,7 @@ import "c64dtv.kc" // Plane with all pixels -const byte* CHUNKY = $8000; +byte* const CHUNKY = $8000; void main() { asm { sei } // Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal) diff --git a/src/test/kc/c64dtv-blitter-box.kc b/src/test/kc/c64dtv-blitter-box.kc index 81367da8c..c95ed3608 100644 --- a/src/test/kc/c64dtv-blitter-box.kc +++ b/src/test/kc/c64dtv-blitter-box.kc @@ -2,7 +2,7 @@ import "c64dtv.kc" -const byte* SCREEN = $400; +byte* const SCREEN = $400; const byte SRCA[] = "camelot rules!"; const byte SRCB[] = { $80 }; diff --git a/src/test/kc/c64dtv-blittermin.kc b/src/test/kc/c64dtv-blittermin.kc index 3d9f54706..5973b263b 100644 --- a/src/test/kc/c64dtv-blittermin.kc +++ b/src/test/kc/c64dtv-blittermin.kc @@ -1,6 +1,6 @@ import "c64dtv.kc" -const byte* SCREEN = $400; +byte* const SCREEN = $400; const byte SRCA[] = { 'c', 'a', 'm', 'e', 'l', 'o', 't', '!', ' '}; const byte SRCA_LEN = 9; const byte SRCB[] = { $80 }; diff --git a/src/test/kc/c64dtv-gfxexplorer.kc b/src/test/kc/c64dtv-gfxexplorer.kc index 1c0c1e467..3acb5d490 100644 --- a/src/test/kc/c64dtv-gfxexplorer.kc +++ b/src/test/kc/c64dtv-gfxexplorer.kc @@ -22,15 +22,15 @@ void main() { } // VIC Screens -const byte* VIC_SCREEN0 = $4000; -const byte* VIC_SCREEN1 = $4400; -const byte* VIC_SCREEN2 = $4800; -const byte* VIC_SCREEN3 = $4c00; -const byte* VIC_SCREEN4 = $5000; +byte* const VIC_SCREEN0 = $4000; +byte* const VIC_SCREEN1 = $4400; +byte* const VIC_SCREEN2 = $4800; +byte* const VIC_SCREEN3 = $4c00; +byte* const VIC_SCREEN4 = $5000; // VIC Charset from ROM -const byte* VIC_CHARSET_ROM = $5800; +byte* const VIC_CHARSET_ROM = $5800; // VIC Bitmap -const byte* VIC_BITMAP = $6000; +byte* const VIC_BITMAP = $6000; // 8BPP Chunky Bitmap (contains 8bpp pixels) const dword PLANE_8BPP_CHUNKY = $20000; @@ -110,9 +110,9 @@ byte* get_vic_charset(byte idx) { } // Screen containing the FORM -const byte* FORM_SCREEN = $0400; +byte* const FORM_SCREEN = $0400; // Charset used for the FORM -const byte* FORM_CHARSET = $1800; // Charset ROM +byte* const FORM_CHARSET = $1800; // Charset ROM byte FORM_TEXT[] = " C64 DTV Graphics Mode Explorer @" @@ -254,42 +254,42 @@ void render_preset_name(byte idx) { // Form fields direct addressing -const byte* form_preset = form_fields_val+0; -const byte* form_ctrl_bmm = form_fields_val+1; -const byte* form_ctrl_mcm = form_fields_val+2; -const byte* form_ctrl_ecm = form_fields_val+3; -const byte* form_ctrl_hicol = form_fields_val+4; -const byte* form_ctrl_line = form_fields_val+5; -const byte* form_ctrl_colof = form_fields_val+6; -const byte* form_ctrl_chunk = form_fields_val+7; -const byte* form_ctrl_borof = form_fields_val+8; -const byte* form_ctrl_overs = form_fields_val+9; -const byte* form_a_pattern = form_fields_val+10; -const byte* form_a_start_hi = form_fields_val+11; -const byte* form_a_start_lo = form_fields_val+12; -const byte* form_a_step_hi = form_fields_val+13; -const byte* form_a_step_lo = form_fields_val+14; -const byte* form_a_mod_hi = form_fields_val+15; -const byte* form_a_mod_lo = form_fields_val+16; -const byte* form_b_pattern = form_fields_val+17; -const byte* form_b_start_hi = form_fields_val+18; -const byte* form_b_start_lo = form_fields_val+19; -const byte* form_b_step_hi = form_fields_val+20; -const byte* form_b_step_lo = form_fields_val+21; -const byte* form_b_mod_hi = form_fields_val+22; -const byte* form_b_mod_lo = form_fields_val+23; -const byte* form_vic_screen = form_fields_val+24; -const byte* form_vic_gfx = form_fields_val+25; -const byte* form_vic_cols = form_fields_val+26; -const byte* form_dtv_palet = form_fields_val+27; -const byte* form_vic_bg0_hi = form_fields_val+28; -const byte* form_vic_bg0_lo = form_fields_val+29; -const byte* form_vic_bg1_hi = form_fields_val+30; -const byte* form_vic_bg1_lo = form_fields_val+31; -const byte* form_vic_bg2_hi = form_fields_val+32; -const byte* form_vic_bg2_lo = form_fields_val+33; -const byte* form_vic_bg3_hi = form_fields_val+34; -const byte* form_vic_bg3_lo = form_fields_val+35; +byte* const form_preset = form_fields_val+0; +byte* const form_ctrl_bmm = form_fields_val+1; +byte* const form_ctrl_mcm = form_fields_val+2; +byte* const form_ctrl_ecm = form_fields_val+3; +byte* const form_ctrl_hicol = form_fields_val+4; +byte* const form_ctrl_line = form_fields_val+5; +byte* const form_ctrl_colof = form_fields_val+6; +byte* const form_ctrl_chunk = form_fields_val+7; +byte* const form_ctrl_borof = form_fields_val+8; +byte* const form_ctrl_overs = form_fields_val+9; +byte* const form_a_pattern = form_fields_val+10; +byte* const form_a_start_hi = form_fields_val+11; +byte* const form_a_start_lo = form_fields_val+12; +byte* const form_a_step_hi = form_fields_val+13; +byte* const form_a_step_lo = form_fields_val+14; +byte* const form_a_mod_hi = form_fields_val+15; +byte* const form_a_mod_lo = form_fields_val+16; +byte* const form_b_pattern = form_fields_val+17; +byte* const form_b_start_hi = form_fields_val+18; +byte* const form_b_start_lo = form_fields_val+19; +byte* const form_b_step_hi = form_fields_val+20; +byte* const form_b_step_lo = form_fields_val+21; +byte* const form_b_mod_hi = form_fields_val+22; +byte* const form_b_mod_lo = form_fields_val+23; +byte* const form_vic_screen = form_fields_val+24; +byte* const form_vic_gfx = form_fields_val+25; +byte* const form_vic_cols = form_fields_val+26; +byte* const form_dtv_palet = form_fields_val+27; +byte* const form_vic_bg0_hi = form_fields_val+28; +byte* const form_vic_bg0_lo = form_fields_val+29; +byte* const form_vic_bg1_hi = form_fields_val+30; +byte* const form_vic_bg1_lo = form_fields_val+31; +byte* const form_vic_bg2_hi = form_fields_val+32; +byte* const form_vic_bg2_lo = form_fields_val+33; +byte* const form_vic_bg3_hi = form_fields_val+34; +byte* const form_vic_bg3_lo = form_fields_val+35; // Change graphics mode to show the selected graphics mode void gfx_mode() { diff --git a/src/test/kc/c64dtv-gfxmodes.kc b/src/test/kc/c64dtv-gfxmodes.kc index 510d383f5..817ba86fe 100644 --- a/src/test/kc/c64dtv-gfxmodes.kc +++ b/src/test/kc/c64dtv-gfxmodes.kc @@ -42,8 +42,8 @@ byte MENU_TEXT[] = void menu() { - const byte* SCREEN = $8000; - const byte* CHARSET = $9800; // Charset ROM + byte* const SCREEN = $8000; + byte* const CHARSET = $9800; // Charset ROM // DTV Graphics Bank *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); // DTV Color Bank @@ -187,9 +187,9 @@ void mode_ctrl() { // - 0: 4bpp BgColor0[3:0] // - 1: 4bpp ColorData[3:0] void mode_stdchar() { - const byte* SCREEN = $8000; - const byte* CHARSET = $9000; // Charset ROM - const byte* COLORS = $d800; + byte* const SCREEN = $8000; + byte* const CHARSET = $9000; // Charset ROM + byte* const COLORS = $d800; // DTV Graphics Bank *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); // DTV Color Bank @@ -238,9 +238,9 @@ void mode_stdchar() { // - CharData[7:6] 11: 4bpp BgColor3[3:0] // - 1: 4bpp ColorData[3:0] void mode_ecmchar() { - const byte* SCREEN = $8000; - const byte* CHARSET = $9000; // Charset ROM - const byte* COLORS = $d800; + byte* const SCREEN = $8000; + byte* const CHARSET = $9000; // Charset ROM + byte* const COLORS = $d800; // DTV Graphics Bank *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); // DTV Color Bank @@ -294,9 +294,9 @@ void mode_ecmchar() { // - 10: 4bpp BgColor2[3:0] // - 11: 4bpp ColorData[2:0]// Standard Character Mode (LINEAR/HICOL/CHUNK/COLDIS/ECM/MCM/BMM = 0) void mode_mcchar() { - const byte* SCREEN = $8000; - const byte* CHARSET = $9000; // Charset ROM - const byte* COLORS = $d800; + byte* const SCREEN = $8000; + byte* const CHARSET = $9000; // Charset ROM + byte* const COLORS = $d800; // DTV Graphics Bank *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); // DTV Color Bank @@ -344,8 +344,8 @@ void mode_mcchar() { // - 0: 4bpp CharData[3:0] // - 1: 4bpp CharData[7:4] void mode_stdbitmap() { - const byte* SCREEN = $4000; - const byte* BITMAP = $6000; + byte* const SCREEN = $4000; + byte* const BITMAP = $6000; // DTV Graphics Bank *DTV_GRAPHICS_VIC_BANK = (byte)((dword)BITMAP/$10000); // DTV Graphics Mode @@ -396,9 +396,9 @@ void mode_stdbitmap() { // - 0: 8bpp BgColor0[7:0] // - 1: 8bpp ColorData[7:0] void mode_hicolstdchar() { - const byte* SCREEN = $8000; - const byte* CHARSET = $9000; // Charset ROM - const byte* COLORS = $8400; + byte* const SCREEN = $8000; + byte* const CHARSET = $9000; // Charset ROM + byte* const COLORS = $8400; // DTV Graphics Bank *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); // DTV Color Bank @@ -449,9 +449,9 @@ void mode_hicolstdchar() { // - CharData[7:6] 11: 8bpp BgColor3[7:0] // - 1: 8bpp ColorData[7:0] void mode_hicolecmchar() { - const byte* SCREEN = $8000; - const byte* CHARSET = $9000; // Charset ROM - const byte* COLORS = $8400; + byte* const SCREEN = $8000; + byte* const CHARSET = $9000; // Charset ROM + byte* const COLORS = $8400; // DTV Graphics Bank *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); // DTV Color Bank @@ -505,9 +505,9 @@ void mode_hicolecmchar() { // - 10: 8bpp BgColor2[7:0] // - 11: 8bpp ColorData[7:4] "0" & Color[2:0] void mode_hicolmcchar() { - const byte* SCREEN = $8000; - const byte* CHARSET = $9000; // Charset ROM - const byte* COLORS = $8400; + byte* const SCREEN = $8000; + byte* const CHARSET = $9000; // Charset ROM + byte* const COLORS = $8400; // DTV Graphics Bank *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000); // DTV Color Bank @@ -557,9 +557,9 @@ void mode_hicolmcchar() { // - Plane A = 1 Plane B = 0: 8bpp "0000" & ColorData[3:0] // - Plane A = 1 Plane B = 1: 8bpp BgColor1[7:0] void mode_twoplanebitmap() { - const byte* PLANEA = $4000; - const byte* PLANEB = $6000; - const byte* COLORS = $8000; + byte* const PLANEA = $4000; + byte* const PLANEB = $6000; + byte* const COLORS = $8000; // DTV Graphics Mode dtv_control = DTV_HIGHCOLOR | DTV_LINEAR; *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR; @@ -627,9 +627,9 @@ void mode_twoplanebitmap() { // GfxData/PlaneA Pixel Shifter (2), CharData/PlaneB Pixel Shifter (2): // - 8bpp color (ColorData[3:0],CharData/PlaneB[1:0], GfxData/PlaneA[1:0]) void mode_sixsfred() { - const byte* PLANEA = $4000; - const byte* PLANEB = $6000; - const byte* COLORS = $8000; + byte* const PLANEA = $4000; + byte* const PLANEB = $6000; + byte* const COLORS = $8000; // DTV Graphics Mode dtv_control = DTV_HIGHCOLOR | DTV_LINEAR; *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR; @@ -693,9 +693,9 @@ void mode_sixsfred() { // PlaneA Pixel Shifter (2), PlaneB Pixel Shifter (2): // - 8bpp color (PlaneB[1:0],ColorData[5:4],PlaneA[1:0],ColorData[1:0]) void mode_sixsfred2() { - const byte* PLANEA = $4000; - const byte* PLANEB = $6000; - const byte* COLORS = $8000; + byte* const PLANEA = $4000; + byte* const PLANEB = $6000; + byte* const COLORS = $8000; // DTV Graphics Mode dtv_control = DTV_LINEAR; *DTV_CONTROL = DTV_LINEAR; @@ -764,9 +764,9 @@ void mode_sixsfred2() { //Counter B step and modulo should be set to 0, counter A modulo to 0 and counter A step to 1 for normal operation. void mode_8bpppixelcell() { // 8BPP Pixel Cell Screen (contains 40x25=1000 chars) - const byte* PLANEA = $3c00; + byte* const PLANEA = $3c00; // 8BPP Pixel Cell Charset (contains 256 64 byte chars) - const byte* PLANEB = $4000; + byte* const PLANEB = $4000; // DTV Graphics Mode dtv_control = DTV_HIGHCOLOR | DTV_LINEAR | DTV_CHUNKY; *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR | DTV_CHUNKY; diff --git a/src/test/kc/call-parameter-autocast.kc b/src/test/kc/call-parameter-autocast.kc index beff09c63..b03c78c0d 100644 --- a/src/test/kc/call-parameter-autocast.kc +++ b/src/test/kc/call-parameter-autocast.kc @@ -7,7 +7,7 @@ void main() { print( {0x12,0x34} ); } -const word* SCREEN = 0x0400; +word* const SCREEN = 0x0400; byte idx = 0; void print(word w) { diff --git a/src/test/kc/cia-timer-cyclecount.kc b/src/test/kc/cia-timer-cyclecount.kc index 8e485abdb..e85345bd4 100644 --- a/src/test/kc/cia-timer-cyclecount.kc +++ b/src/test/kc/cia-timer-cyclecount.kc @@ -4,7 +4,7 @@ import "c64" import "time" import "print" -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { diff --git a/src/test/kc/cia-timer-simple.kc b/src/test/kc/cia-timer-simple.kc index d4b0bc952..fd0c7a929 100644 --- a/src/test/kc/cia-timer-simple.kc +++ b/src/test/kc/cia-timer-simple.kc @@ -4,7 +4,7 @@ import "c64" import "time" import "print" -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { diff --git a/src/test/kc/clobber-a-problem.kc b/src/test/kc/clobber-a-problem.kc index 407074098..c5dc0aaa4 100644 --- a/src/test/kc/clobber-a-problem.kc +++ b/src/test/kc/clobber-a-problem.kc @@ -3,7 +3,7 @@ byte* BORDERCOL = $d020; byte* RASTER = $d012; byte DARK_GREY = $b; byte BLACK = 0; -const void()** KERNEL_IRQ = $0314; +void()** const KERNEL_IRQ = $0314; void main() { diff --git a/src/test/kc/coalesce-assignment.kc b/src/test/kc/coalesce-assignment.kc index f3eb2fe32..e785928ee 100644 --- a/src/test/kc/coalesce-assignment.kc +++ b/src/test/kc/coalesce-assignment.kc @@ -1,7 +1,7 @@ // Tests variable coalescing over assignments void main() { - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; byte idx = 0; for( byte a: 0..5) { for( byte b: 0..5) { diff --git a/src/test/kc/code-after-return-1.kc b/src/test/kc/code-after-return-1.kc index 65e08abf6..c83b70141 100644 --- a/src/test/kc/code-after-return-1.kc +++ b/src/test/kc/code-after-return-1.kc @@ -1,6 +1,6 @@ // Test code after return in main() -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char b = 0; diff --git a/src/test/kc/code-after-return.kc b/src/test/kc/code-after-return.kc index a4007c30a..e2a95f3b1 100644 --- a/src/test/kc/code-after-return.kc +++ b/src/test/kc/code-after-return.kc @@ -1,6 +1,6 @@ // Test code after return in main() -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { SCREEN[0] = 'a'; diff --git a/src/test/kc/comma-decl-2.kc b/src/test/kc/comma-decl-2.kc index 7fe7a4721..944df2f41 100644 --- a/src/test/kc/comma-decl-2.kc +++ b/src/test/kc/comma-decl-2.kc @@ -1,7 +1,7 @@ // Tests comma-separated declarations with different array-ness void main() { - const char* SCREEN = $400; + char* const SCREEN = $400; char b, c[3], d; SCREEN[0] = b; SCREEN[1] = c[0]; diff --git a/src/test/kc/comma-decl-for.kc b/src/test/kc/comma-decl-for.kc index 21a58dd48..08ae5b88c 100644 --- a/src/test/kc/comma-decl-for.kc +++ b/src/test/kc/comma-decl-for.kc @@ -1,7 +1,7 @@ // Tests comma-separated declarations inside for() void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for(byte i, j='g'; i<10; i++, j++) { SCREEN[i] = j; } diff --git a/src/test/kc/comma-decl.kc b/src/test/kc/comma-decl.kc index 14caa08b1..201bdd510 100644 --- a/src/test/kc/comma-decl.kc +++ b/src/test/kc/comma-decl.kc @@ -1,7 +1,7 @@ // Tests comma-separated declarations void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; byte b = 'c', c = b+1, d = c+1; SCREEN[0] = b; SCREEN[1] = c; diff --git a/src/test/kc/comma-expr-1.kc b/src/test/kc/comma-expr-1.kc index 49495b90e..7e2d1834e 100644 --- a/src/test/kc/comma-expr-1.kc +++ b/src/test/kc/comma-expr-1.kc @@ -1,7 +1,7 @@ // Tests simple comma-expression (in parenthesis) void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; byte b = (1,2,3); byte c = (1+1,b+1); SCREEN[1,0] = c; diff --git a/src/test/kc/comma-expr-2.kc b/src/test/kc/comma-expr-2.kc index 689cb0842..04e646d12 100644 --- a/src/test/kc/comma-expr-2.kc +++ b/src/test/kc/comma-expr-2.kc @@ -1,7 +1,7 @@ // Tests simple comma-expressions (without parenthesis) void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; byte b; byte c; b = 1,2,3; diff --git a/src/test/kc/comma-expr-for.kc b/src/test/kc/comma-expr-for.kc index ffcd474c9..13a69d1e1 100644 --- a/src/test/kc/comma-expr-for.kc +++ b/src/test/kc/comma-expr-for.kc @@ -1,7 +1,7 @@ // Tests comma-expressions in for()-statement void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; byte j='g'; for( byte i=0; j<10, i<10; i++, j++) { SCREEN[i] = j; diff --git a/src/test/kc/comparison-rewriting-pointer.kc b/src/test/kc/comparison-rewriting-pointer.kc index 3dd54a970..a947aad9c 100644 --- a/src/test/kc/comparison-rewriting-pointer.kc +++ b/src/test/kc/comparison-rewriting-pointer.kc @@ -1,10 +1,10 @@ // Test rewriting of constant comparisons for pointers void main() { - const byte* screen = $0400; + byte* const screen = $0400; for(byte* sc =screen;sc<=screen+999;sc++) *sc='a'; - const byte* cols = $d800; + byte* const cols = $d800; for(byte* cc =cols+999;cc>cols-1;cc--) *cc=2; } \ No newline at end of file diff --git a/src/test/kc/comparison-rewriting.kc b/src/test/kc/comparison-rewriting.kc index d1f12c9a5..83baab7fc 100644 --- a/src/test/kc/comparison-rewriting.kc +++ b/src/test/kc/comparison-rewriting.kc @@ -1,7 +1,7 @@ // Test rewriting of constant comparisons void main() { - const byte* SCREEN = $0400; + byte* const SCREEN = $0400; for(byte* sc : SCREEN..SCREEN+1000) *sc=' '; diff --git a/src/test/kc/complex-conditional-problem.kc b/src/test/kc/complex-conditional-problem.kc index d0bd2ae7d..76d570382 100644 --- a/src/test/kc/complex-conditional-problem.kc +++ b/src/test/kc/complex-conditional-problem.kc @@ -1,7 +1,7 @@ // Test to provoke Exception when using complex || condition -const byte* RASTER = $d012; -const byte* SCREEN = $0400; +byte* const RASTER = $d012; +byte* const SCREEN = $0400; void main() { while(true) { diff --git a/src/test/kc/complex/ataritempest/ataritempest.kc b/src/test/kc/complex/ataritempest/ataritempest.kc index 33094479a..2b7afa1e7 100644 --- a/src/test/kc/complex/ataritempest/ataritempest.kc +++ b/src/test/kc/complex/ataritempest/ataritempest.kc @@ -4,7 +4,7 @@ #pragma link("ataritempest.ld") -const char* BGCOL = 0xc01a; +char* const BGCOL = 0xc01a; #pragma data_seg(RomData) char MESSAGE[] = "hello world"; @@ -25,4 +25,4 @@ void main() { } #pragma data_seg(Vectors) -export const void()* VECTORS[] = { &nmiHandler, &entryPoint }; +export void()* const VECTORS[] = { &nmiHandler, &entryPoint }; diff --git a/src/test/kc/complex/clearscreen/clearscreen.kc b/src/test/kc/complex/clearscreen/clearscreen.kc index 130a837ca..b5fb1dc60 100644 --- a/src/test/kc/complex/clearscreen/clearscreen.kc +++ b/src/test/kc/complex/clearscreen/clearscreen.kc @@ -9,9 +9,9 @@ import "c64" const bool DEBUG = false; // Address of the screen -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; // Sprite data for the animating sprites -const byte* SPRITE_DATA = 0x2000; +byte* const SPRITE_DATA = 0x2000; // Values added to VX const unsigned int VXSIN[40] = kickasm {{ .for(var i=0; i<40; i++) { diff --git a/src/test/kc/complex/prebob/grid-bobs.kc b/src/test/kc/complex/prebob/grid-bobs.kc index b6ef6fecb..6e4efd7de 100644 --- a/src/test/kc/complex/prebob/grid-bobs.kc +++ b/src/test/kc/complex/prebob/grid-bobs.kc @@ -29,13 +29,13 @@ signed char align(0x40) SIN[0x140] = kickasm {{ signed char* COS = SIN+$40; // sin(x) = cos(x+PI/2) // The BASIC screen -const char* BASIC_SCREEN = 0x0400; +char* const BASIC_SCREEN = 0x0400; // The BASIC charset -const char* BASIC_CHARSET = 0x1000; +char* const BASIC_CHARSET = 0x1000; // The BOB screen -const char* BOB_SCREEN = 0x2800; +char* const BOB_SCREEN = 0x2800; // The BOB charset -const char* BOB_CHARSET = 0x2000; +char* const BOB_CHARSET = 0x2000; // Tables containing the char to use for a specific cell of a shifted BOB. // char_id = BOB_TABLES[cell*BOB_SUBTABLE_SIZE + shift_y*BOB_SHIFTS_X + shift_x]; diff --git a/src/test/kc/complex/prebob/vogel-bobs.kc b/src/test/kc/complex/prebob/vogel-bobs.kc index 5667dbaae..4db6e4252 100644 --- a/src/test/kc/complex/prebob/vogel-bobs.kc +++ b/src/test/kc/complex/prebob/vogel-bobs.kc @@ -36,13 +36,13 @@ align(0x100) const char VOGEL_THETA[] = kickasm {{ align(0x100) const char VOGEL_R[] = kickasm {{ .fill 100, round(sqrt(i)*15) }}; // The BASIC screen -const char* SCREEN_BASIC = 0x0400; +char* const SCREEN_BASIC = 0x0400; // The BASIC charset -const char* CHARSET_BASIC = 0x1000; +char* const CHARSET_BASIC = 0x1000; // The BOB screen -const char* BOB_SCREEN = 0x2800; +char* const BOB_SCREEN = 0x2800; // The BOB charset -const char* BOB_CHARSET = 0x2000; +char* const BOB_CHARSET = 0x2000; // Tables containing the char to use for a specific cell of a shifted BOB. // char_id = BOB_TABLES[cell*BOB_SUBTABLE_SIZE + shift_y*BOB_SHIFTS_X + shift_x]; diff --git a/src/test/kc/complex/prebob/vogel-sprites.kc b/src/test/kc/complex/prebob/vogel-sprites.kc index c8e361fa7..b9a38d997 100644 --- a/src/test/kc/complex/prebob/vogel-sprites.kc +++ b/src/test/kc/complex/prebob/vogel-sprites.kc @@ -24,7 +24,7 @@ align(0x40) signed char SIN[0x140] = kickasm {{ signed char* COS = SIN+0x40; // sin(x) = cos(x+PI/2) // The BASIC screen -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; // The number of BOBs to render const char NUM_BOBS = 16; diff --git a/src/test/kc/complex/splines/truetype-splines.kc b/src/test/kc/complex/splines/truetype-splines.kc index 41e84e4de..b6d0fc5e7 100644 --- a/src/test/kc/complex/splines/truetype-splines.kc +++ b/src/test/kc/complex/splines/truetype-splines.kc @@ -7,9 +7,9 @@ import "print" import "fastmultiply" import "c64" -const char* PRINT_SCREEN = 0x0400; -const char* BITMAP_SCREEN = 0x5c00; -const char* BITMAP_GRAPHICS = 0x6000; +char* const PRINT_SCREEN = 0x0400; +char* const BITMAP_SCREEN = 0x5c00; +char* const BITMAP_GRAPHICS = 0x6000; // A segment of a spline struct Segment { diff --git a/src/test/kc/complex/tetris/sid.kc b/src/test/kc/complex/tetris/sid.kc index e31a74d3a..e89fc783c 100644 --- a/src/test/kc/complex/tetris/sid.kc +++ b/src/test/kc/complex/tetris/sid.kc @@ -1,8 +1,8 @@ // SID registers for random number generation -const unsigned int* SID_VOICE3_FREQ = 0xd40e; -const char* SID_VOICE3_FREQ_LOW = 0xd40e; -const char* SID_VOICE3_FREQ_HIGH = 0xd40f; -const char* SID_VOICE3_CONTROL = 0xd412; +unsigned int* const SID_VOICE3_FREQ = 0xd40e; +char* const SID_VOICE3_FREQ_LOW = 0xd40e; +char* const SID_VOICE3_FREQ_HIGH = 0xd40f; +char* const SID_VOICE3_CONTROL = 0xd412; const char SID_CONTROL_NOISE = 0x80; const char SID_CONTROL_PULSE = 0x40; const char SID_CONTROL_SAWTOOTH = 0x20; @@ -11,7 +11,7 @@ const char SID_CONTROL_TEST = 0x08; const char SID_CONTROL_RING = 0x04; const char SID_CONTROL_SYNC = 0x02; const char SID_CONTROL_GATE = 0x01; -const char* SID_VOICE3_OSC = 0xd41b; +char* const SID_VOICE3_OSC = 0xd41b; // Initialize SID voice 3 for random number generation void sid_rnd_init() { diff --git a/src/test/kc/complex/tetris/tetris-data.kc b/src/test/kc/complex/tetris/tetris-data.kc index c7ad55c3f..27cf39500 100644 --- a/src/test/kc/complex/tetris/tetris-data.kc +++ b/src/test/kc/complex/tetris/tetris-data.kc @@ -2,17 +2,17 @@ // Memory Layout and Shared Data // Address of the first screen -const char* PLAYFIELD_SCREEN_1 = 0x0400; +char* const PLAYFIELD_SCREEN_1 = 0x0400; // Address of the second screen -const char* PLAYFIELD_SCREEN_2 = 0x2c00; +char* const PLAYFIELD_SCREEN_2 = 0x2c00; // Screen Sprite pointers on screen 1 -const char* PLAYFIELD_SPRITE_PTRS_1 = (PLAYFIELD_SCREEN_1+SPRITE_PTRS); +char* const PLAYFIELD_SPRITE_PTRS_1 = (PLAYFIELD_SCREEN_1+SPRITE_PTRS); // Screen Sprite pointers on screen 2 -const char* PLAYFIELD_SPRITE_PTRS_2 = (PLAYFIELD_SCREEN_2+SPRITE_PTRS); +char* const PLAYFIELD_SPRITE_PTRS_2 = (PLAYFIELD_SCREEN_2+SPRITE_PTRS); // Address of the sprites covering the playfield -const char* PLAYFIELD_SPRITES = 0x3000; +char* const PLAYFIELD_SPRITES = 0x3000; // Address of the charset -const char* PLAYFIELD_CHARSET = 0x2800; +char* const PLAYFIELD_CHARSET = 0x2800; // The size of the playfield const char PLAYFIELD_LINES = 22; diff --git a/src/test/kc/complex/xmega65/xmega65.kc b/src/test/kc/complex/xmega65/xmega65.kc index 7f3fc2e29..f5b3dc7b5 100644 --- a/src/test/kc/complex/xmega65/xmega65.kc +++ b/src/test/kc/complex/xmega65/xmega65.kc @@ -7,11 +7,11 @@ import "string" #pragma link("xmega65.ld") -const char* RASTER = 0xd012; -const char* VIC_MEMORY = 0xd018; -const char* SCREEN = 0x0400; -const char* BGCOL = 0xd021; -const char* COLS = 0xd800; +char* const RASTER = 0xd012; +char* const VIC_MEMORY = 0xd018; +char* const SCREEN = 0x0400; +char* const BGCOL = 0xd021; +char* const COLS = 0xd800; const char BLACK = 0; const char WHITE = 1; diff --git a/src/test/kc/complex/xmega65/xmega65logo.kc b/src/test/kc/complex/xmega65/xmega65logo.kc index ae888bba6..1b0db6fcd 100644 --- a/src/test/kc/complex/xmega65/xmega65logo.kc +++ b/src/test/kc/complex/xmega65/xmega65logo.kc @@ -2,7 +2,7 @@ // Fill the palette values into void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; for(byte i:0..0xff) { (SCREEN+40*0)[i] = LOGO256_RED[i]; (SCREEN+40*8)[i] = LOGO256_GREEN[i]; diff --git a/src/test/kc/condition-integer-0.kc b/src/test/kc/condition-integer-0.kc index 09f9451cc..4aab9c67c 100644 --- a/src/test/kc/condition-integer-0.kc +++ b/src/test/kc/condition-integer-0.kc @@ -1,7 +1,7 @@ // Tests using integer conditions in if() // This should produce '+ ++ ++' at the top of the screen -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { byte idx = 0; diff --git a/src/test/kc/condition-integer-1.kc b/src/test/kc/condition-integer-1.kc index 77129ba64..c4807b60a 100644 --- a/src/test/kc/condition-integer-1.kc +++ b/src/test/kc/condition-integer-1.kc @@ -1,7 +1,7 @@ // Tests using integer conditions in if() // This should produce '0 0 0' at the top of the screen -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { byte idx = 0; diff --git a/src/test/kc/condition-integer-2.kc b/src/test/kc/condition-integer-2.kc index de66ac330..604f369e7 100644 --- a/src/test/kc/condition-integer-2.kc +++ b/src/test/kc/condition-integer-2.kc @@ -1,7 +1,7 @@ // Tests using integer conditions in while() / for() / do..while // This should produce 'ba ba ba' at the top of the screen -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; byte idx = 0; void main() { diff --git a/src/test/kc/condition-integer-3.kc b/src/test/kc/condition-integer-3.kc index b09ad24fc..8c84427aa 100644 --- a/src/test/kc/condition-integer-3.kc +++ b/src/test/kc/condition-integer-3.kc @@ -1,7 +1,7 @@ // Tests using integer conditions in ternary operator // This should produce '++0++' at the top of the screen -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { byte idx = 0; diff --git a/src/test/kc/condition-integer-4.kc b/src/test/kc/condition-integer-4.kc index 6f67ed742..ac290e75e 100644 --- a/src/test/kc/condition-integer-4.kc +++ b/src/test/kc/condition-integer-4.kc @@ -1,7 +1,7 @@ // Tests using integer conditions in && and || operator // This should produce '01010101', '00110011', '00010001', '01110111' at the top of the screen -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { byte idx = 0; diff --git a/src/test/kc/consolidate-constant-problem.kc b/src/test/kc/consolidate-constant-problem.kc index bfdd04f92..bf5dbe0f6 100644 --- a/src/test/kc/consolidate-constant-problem.kc +++ b/src/test/kc/consolidate-constant-problem.kc @@ -1,4 +1,4 @@ -const byte* screen = $400; +byte* const screen = $400; void main() { inline for( byte j: 0..1) { diff --git a/src/test/kc/const-bool-0.kc b/src/test/kc/const-bool-0.kc index 9f97b779f..a722aa986 100644 --- a/src/test/kc/const-bool-0.kc +++ b/src/test/kc/const-bool-0.kc @@ -3,7 +3,7 @@ void main() { char bError = 7; bError &= ~(0x10 | 0x20 | 0x40); - const char* screen = 0x0400; + char* const screen = 0x0400; *screen = bError; } diff --git a/src/test/kc/const-condition.kc b/src/test/kc/const-condition.kc index 38963fe70..25feee706 100644 --- a/src/test/kc/const-condition.kc +++ b/src/test/kc/const-condition.kc @@ -1,7 +1,7 @@ // Ensure that if()'s with constant comparisons are identified and eliminated void main() { - const byte* SCREEN = $0400; + byte* const SCREEN = $0400; if(7<4) { SCREEN[0] = '*'; } else { diff --git a/src/test/kc/const-declaration.kc b/src/test/kc/const-declaration.kc index c6b171ee3..09ea4cb43 100644 --- a/src/test/kc/const-declaration.kc +++ b/src/test/kc/const-declaration.kc @@ -1,12 +1,12 @@ // Tests a number of constant declarations -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; const char LINE_LEN = 40; const char MARGIN_TOP = 4; const char MARGIN_LEFT = 4; const unsigned int OFFSET = 40*5+5; -const char* BODY1 = SCREEN+MARGIN_TOP*LINE_LEN+MARGIN_LEFT; -const char* BODY2 = SCREEN+OFFSET; +char* const BODY1 = SCREEN+MARGIN_TOP*LINE_LEN+MARGIN_LEFT; +char* const BODY2 = SCREEN+OFFSET; void main() { *BODY1 = '*'; diff --git a/src/test/kc/const-identification.kc b/src/test/kc/const-identification.kc index 34f5d37c7..3145b9ba7 100644 --- a/src/test/kc/const-identification.kc +++ b/src/test/kc/const-identification.kc @@ -1,5 +1,5 @@ -const byte* plots = $1000; -const byte* SCREEN = $0400; +byte* const plots = $1000; +byte* const SCREEN = $0400; void main() { for(byte i : 0..39) { diff --git a/src/test/kc/const-int-cast-problem.kc b/src/test/kc/const-int-cast-problem.kc index 01a8dea74..4f1971677 100644 --- a/src/test/kc/const-int-cast-problem.kc +++ b/src/test/kc/const-int-cast-problem.kc @@ -1,5 +1,5 @@ // Test a problem with converting casted constant numbers to fixed type constant integers -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; void main() { for( byte i: 121..122) { diff --git a/src/test/kc/const-pointer-modify.kc b/src/test/kc/const-pointer-modify.kc index c658ee100..7426ab584 100644 --- a/src/test/kc/const-pointer-modify.kc +++ b/src/test/kc/const-pointer-modify.kc @@ -1,7 +1,7 @@ // Test that modifying constant pointers fail void main() { - const byte* screen = $400; + byte* const screen = $400; screen[0] = 'c'; screen++; screen[0] = 'm'; diff --git a/src/test/kc/constabsmin.kc b/src/test/kc/constabsmin.kc index 26d165700..b5b2417b1 100644 --- a/src/test/kc/constabsmin.kc +++ b/src/test/kc/constabsmin.kc @@ -1,4 +1,4 @@ -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; void main() { *SCREEN = 1; diff --git a/src/test/kc/constantmin.kc b/src/test/kc/constantmin.kc index 09f8d675d..374ee2686 100644 --- a/src/test/kc/constantmin.kc +++ b/src/test/kc/constantmin.kc @@ -1,4 +1,4 @@ -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; const byte STAR = 81; byte* VIC = $d000; diff --git a/src/test/kc/constants.kc b/src/test/kc/constants.kc index 8e5a98b3a..b37d15bb8 100644 --- a/src/test/kc/constants.kc +++ b/src/test/kc/constants.kc @@ -1,5 +1,5 @@ import "print.kc" -const byte* BGCOL = $d021; +byte* const BGCOL = $d021; const byte GREEN = 5; const byte RED = 2 ; diff --git a/src/test/kc/cordic-atan2-16-ref.kc b/src/test/kc/cordic-atan2-16-ref.kc index 4e32b69a9..b1bb54fab 100644 --- a/src/test/kc/cordic-atan2-16-ref.kc +++ b/src/test/kc/cordic-atan2-16-ref.kc @@ -6,8 +6,8 @@ import "atan2" import "c64" import "print" -const byte* CHARSET = 0x2000; -const byte* SCREEN = 0x2800; +byte* const CHARSET = 0x2000; +byte* const SCREEN = 0x2800; const byte SCREEN_REF[1000] = kickasm {{ .for(var y=-12;y<=12;y++) diff --git a/src/test/kc/cordic-atan2-16.kc b/src/test/kc/cordic-atan2-16.kc index f6ae3c336..4db719b40 100644 --- a/src/test/kc/cordic-atan2-16.kc +++ b/src/test/kc/cordic-atan2-16.kc @@ -5,8 +5,8 @@ import "font-hex" import "atan2" import "c64" -const byte* CHARSET = 0x2000; -const byte* SCREEN = 0x2800; +byte* const CHARSET = 0x2000; +byte* const SCREEN = 0x2800; void main() { init_font_hex(CHARSET); diff --git a/src/test/kc/cordic-atan2-clear.kc b/src/test/kc/cordic-atan2-clear.kc index a2b7db3a0..b4dd40418 100644 --- a/src/test/kc/cordic-atan2-clear.kc +++ b/src/test/kc/cordic-atan2-clear.kc @@ -4,8 +4,8 @@ import "font-hex" import "atan2" import "c64" -const byte* CHARSET = 0x2000; -const byte* SCREEN = 0x2800; +byte* const CHARSET = 0x2000; +byte* const SCREEN = 0x2800; void main() { init_font_hex(CHARSET); diff --git a/src/test/kc/cordic-atan2.kc b/src/test/kc/cordic-atan2.kc index d91c2e0b8..4e5cf97b9 100644 --- a/src/test/kc/cordic-atan2.kc +++ b/src/test/kc/cordic-atan2.kc @@ -6,8 +6,8 @@ import "c64" import "atan2" -const byte* CHARSET = 0x2000; -const byte* SCREEN = 0x2800; +byte* const CHARSET = 0x2000; +byte* const SCREEN = 0x2800; void main() { init_font_hex(CHARSET); diff --git a/src/test/kc/cpu-6502.kc b/src/test/kc/cpu-6502.kc index dbb06c61f..99f742e64 100644 --- a/src/test/kc/cpu-6502.kc +++ b/src/test/kc/cpu-6502.kc @@ -4,7 +4,7 @@ #pragma cpu(MOS6502) void main() { - const char* screen = 0x0400; + char* const screen = 0x0400; char c=0; while(c<100) { screen[c] = '*'; diff --git a/src/test/kc/danny-joystick-problem.kc b/src/test/kc/danny-joystick-problem.kc index cc306e8b2..6254c0608 100644 --- a/src/test/kc/danny-joystick-problem.kc +++ b/src/test/kc/danny-joystick-problem.kc @@ -2,7 +2,7 @@ // https://www.protovision.games/hardw/build4player.php?language=en&fbclid=IwAR1MJLgQjOU0zVa0ax2aNeGa-xVbE9IGY9zC6b6eInTV4HQzoUAoCPoXu14 import "c64" -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { (*CIA2_PORT_B) &= 0x7f; asm { lda #0 } diff --git a/src/test/kc/declared-memory-var-0.kc b/src/test/kc/declared-memory-var-0.kc index e1b8eca73..5d08f5d77 100644 --- a/src/test/kc/declared-memory-var-0.kc +++ b/src/test/kc/declared-memory-var-0.kc @@ -2,7 +2,7 @@ __mem __ma char idx; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { for( char i: 0..5 ) { diff --git a/src/test/kc/declared-memory-var-1.kc b/src/test/kc/declared-memory-var-1.kc index 59b86e290..775673ce3 100644 --- a/src/test/kc/declared-memory-var-1.kc +++ b/src/test/kc/declared-memory-var-1.kc @@ -4,7 +4,7 @@ __mem __ma char idx; char* idx_p = &idx; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { for( char i: 0..5 ) { diff --git a/src/test/kc/declared-memory-var-2.kc b/src/test/kc/declared-memory-var-2.kc index 0122744dc..7655ea061 100644 --- a/src/test/kc/declared-memory-var-2.kc +++ b/src/test/kc/declared-memory-var-2.kc @@ -1,7 +1,7 @@ // Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store) // Test a memory variable containing a pointer -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; __mem __ma char* cursor = SCREEN; diff --git a/src/test/kc/declared-memory-var-3.kc b/src/test/kc/declared-memory-var-3.kc index f7714908a..d2a13205e 100644 --- a/src/test/kc/declared-memory-var-3.kc +++ b/src/test/kc/declared-memory-var-3.kc @@ -10,7 +10,7 @@ __mem __ma struct foo bar = { 'a', 'b' }; void main(void) { struct foo* barp = &bar; - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; char i=0; SCREEN[i++] = barp->thing1; SCREEN[i++] = barp->thing2; diff --git a/src/test/kc/declared-memory-var-4.kc b/src/test/kc/declared-memory-var-4.kc index e624f4f25..0d36a826b 100644 --- a/src/test/kc/declared-memory-var-4.kc +++ b/src/test/kc/declared-memory-var-4.kc @@ -11,7 +11,7 @@ __mem __ma struct foo bar = { 'a', 'b', "qwe" }; void main(void) { struct foo* barp = &bar; - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; char i=0; SCREEN[i++] = barp->thing1; SCREEN[i++] = barp->thing2; diff --git a/src/test/kc/declared-memory-var-5.kc b/src/test/kc/declared-memory-var-5.kc index 83c350ddb..ffc83dd1b 100644 --- a/src/test/kc/declared-memory-var-5.kc +++ b/src/test/kc/declared-memory-var-5.kc @@ -9,7 +9,7 @@ struct foo { __mem __ma struct foo bar = { 'a', 'b' }; void main(void) { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; char i=0; SCREEN[i++] = bar.thing1; SCREEN[i++] = bar.thing2; diff --git a/src/test/kc/declared-memory-var-6.kc b/src/test/kc/declared-memory-var-6.kc index 5e1224049..37bee624a 100644 --- a/src/test/kc/declared-memory-var-6.kc +++ b/src/test/kc/declared-memory-var-6.kc @@ -1,6 +1,6 @@ // Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store) -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char i=0; void main(void) { diff --git a/src/test/kc/declared-memory-var-7.kc b/src/test/kc/declared-memory-var-7.kc index d9e4ef0d3..1a226743e 100644 --- a/src/test/kc/declared-memory-var-7.kc +++ b/src/test/kc/declared-memory-var-7.kc @@ -3,7 +3,7 @@ __ma char idx; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { for( char i: 0..5 ) { diff --git a/src/test/kc/declared-memory-var-8.kc b/src/test/kc/declared-memory-var-8.kc index 121a6d231..b5a3f8600 100644 --- a/src/test/kc/declared-memory-var-8.kc +++ b/src/test/kc/declared-memory-var-8.kc @@ -3,7 +3,7 @@ __ma __address(0x1000) char idx; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { for( char i: 0..5 ) { diff --git a/src/test/kc/declared-ssa-var-0.kc b/src/test/kc/declared-ssa-var-0.kc index 69f6e6047..72c709832 100644 --- a/src/test/kc/declared-ssa-var-0.kc +++ b/src/test/kc/declared-ssa-var-0.kc @@ -3,10 +3,10 @@ char __ssa idx_ssa_g; char __ma idx_nssa_g; -const char* SCREEN1 = 0x0400; -const char* SCREEN2 = 0x0400+40; -const char* SCREEN3 = 0x0400+80; -const char* SCREEN4 = 0x0400+120; +char* const SCREEN1 = 0x0400; +char* const SCREEN2 = 0x0400+40; +char* const SCREEN3 = 0x0400+80; +char* const SCREEN4 = 0x0400+120; void main() { char __ssa idx_ssa_l; diff --git a/src/test/kc/deref-to-derefidx-2.kc b/src/test/kc/deref-to-derefidx-2.kc index 2214dd6e4..6973476a6 100644 --- a/src/test/kc/deref-to-derefidx-2.kc +++ b/src/test/kc/deref-to-derefidx-2.kc @@ -8,7 +8,7 @@ void main() { print(msg2); } -const word* SCREEN = $0400; +word* const SCREEN = $0400; byte screen_idx=0; void print(byte* m) { diff --git a/src/test/kc/deref-to-derefidx.kc b/src/test/kc/deref-to-derefidx.kc index c22b6c530..684a36e54 100644 --- a/src/test/kc/deref-to-derefidx.kc +++ b/src/test/kc/deref-to-derefidx.kc @@ -8,7 +8,7 @@ void main() { print(msg2); } -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; byte idx=0; void print(byte* m) { diff --git a/src/test/kc/derefidx-word-0.kc b/src/test/kc/derefidx-word-0.kc index 7b5117853..a740bedfd 100644 --- a/src/test/kc/derefidx-word-0.kc +++ b/src/test/kc/derefidx-word-0.kc @@ -1,7 +1,7 @@ // Tests that array-indexing by a word variable is turned into pointer addition void main() { - const byte* screen = 0x0400; + byte* const screen = 0x0400; for( word i=0;i<1000;i+=40) { screen[i] = 'a'; } diff --git a/src/test/kc/derefidx-word-1.kc b/src/test/kc/derefidx-word-1.kc index 5124674fa..23d8e0f18 100644 --- a/src/test/kc/derefidx-word-1.kc +++ b/src/test/kc/derefidx-word-1.kc @@ -1,7 +1,7 @@ // Tests that array-indexing by a constant word is turned into a constant pointer void main() { - const byte* screen = 0x0400; + byte* const screen = 0x0400; screen[40*10] = 'a'; } diff --git a/src/test/kc/derefidx-word-2.kc b/src/test/kc/derefidx-word-2.kc index af8417918..2c9512292 100644 --- a/src/test/kc/derefidx-word-2.kc +++ b/src/test/kc/derefidx-word-2.kc @@ -1,7 +1,7 @@ // Tests that array-indexing by a word variable that is a sum of a constant word and a byte is turned back into derefidx void main() { - const byte* screen = 0x0400; + byte* const screen = 0x0400; for( byte i : 0..39) { screen[40*10+i] = 'a'; } diff --git a/src/test/kc/divide-2s.kc b/src/test/kc/divide-2s.kc index eaf5a87d7..cec3f522c 100644 --- a/src/test/kc/divide-2s.kc +++ b/src/test/kc/divide-2s.kc @@ -1,7 +1,7 @@ // Check that division by factors of 2 is converted to shifts void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for(byte i: 0..10) { (SCREEN+40*0)[i] = i/1; diff --git a/src/test/kc/duplicate-loop-problem.kc b/src/test/kc/duplicate-loop-problem.kc index 0adad8013..8d455810e 100755 --- a/src/test/kc/duplicate-loop-problem.kc +++ b/src/test/kc/duplicate-loop-problem.kc @@ -2,7 +2,7 @@ // Resulted in infinite loop in loop depth analysis -const byte* DC00 = $DC00; +byte* const DC00 = $DC00; byte rpc; byte key; diff --git a/src/test/kc/dword.kc b/src/test/kc/dword.kc index 42a98457b..0b7f01cd0 100644 --- a/src/test/kc/dword.kc +++ b/src/test/kc/dword.kc @@ -5,7 +5,7 @@ void main() { for( byte i: 0..100) { dword b = a + i; byte c = (byte) b; - const byte* SCREEN = $400; + byte* const SCREEN = $400; SCREEN[i] = c; } } \ No newline at end of file diff --git a/src/test/kc/encoding-literal-char.kc b/src/test/kc/encoding-literal-char.kc index 322782215..e2c0f8624 100644 --- a/src/test/kc/encoding-literal-char.kc +++ b/src/test/kc/encoding-literal-char.kc @@ -13,7 +13,7 @@ const char ssm[] = "A"; const char csu = 'A'; const char ssu[] = "A"; -const char* screen = 0x0400; +char* const screen = 0x0400; void main() { char idx = 0; screen[idx++] = cpm; diff --git a/src/test/kc/enum-0.kc b/src/test/kc/enum-0.kc index 1700331ac..cf889ed05 100644 --- a/src/test/kc/enum-0.kc +++ b/src/test/kc/enum-0.kc @@ -4,6 +4,6 @@ enum State { OFF , ON }; void main() { enum State state = ON; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = state; } \ No newline at end of file diff --git a/src/test/kc/enum-1.kc b/src/test/kc/enum-1.kc index 2e0b24be4..534c09d98 100644 --- a/src/test/kc/enum-1.kc +++ b/src/test/kc/enum-1.kc @@ -8,6 +8,6 @@ enum State { void main() { enum State state = BROKEN; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = state; } \ No newline at end of file diff --git a/src/test/kc/enum-2.kc b/src/test/kc/enum-2.kc index 9442bbbb6..dbce8fb0c 100644 --- a/src/test/kc/enum-2.kc +++ b/src/test/kc/enum-2.kc @@ -8,6 +8,6 @@ enum Letter { void main() { enum Letter letter = B; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = letter; } \ No newline at end of file diff --git a/src/test/kc/enum-3.kc b/src/test/kc/enum-3.kc index 13a22718b..2ef236734 100644 --- a/src/test/kc/enum-3.kc +++ b/src/test/kc/enum-3.kc @@ -8,6 +8,6 @@ enum State { void main() { enum State state = BROKEN; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = state; } \ No newline at end of file diff --git a/src/test/kc/enum-4.kc b/src/test/kc/enum-4.kc index bad6fa08e..572b87876 100644 --- a/src/test/kc/enum-4.kc +++ b/src/test/kc/enum-4.kc @@ -2,7 +2,7 @@ void main() { enum State { OFF, ON } state = ON; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = state; } diff --git a/src/test/kc/enum-5.kc b/src/test/kc/enum-5.kc index 7301da020..886878f06 100644 --- a/src/test/kc/enum-5.kc +++ b/src/test/kc/enum-5.kc @@ -2,13 +2,13 @@ void main() { enum State { OFF, ON } state = ON; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = state; test(); } void test() { enum State { OFF=7, ON } state = ON; - const byte* SCREEN = 0x0428; + byte* const SCREEN = 0x0428; *SCREEN = state; } diff --git a/src/test/kc/enum-6.kc b/src/test/kc/enum-6.kc index 8c619db71..93c9b5f2e 100644 --- a/src/test/kc/enum-6.kc +++ b/src/test/kc/enum-6.kc @@ -2,7 +2,7 @@ void main() { enum { OFF, ON } state = ON; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = state; state = OFF; SCREEN[1] = state; diff --git a/src/test/kc/enum-7.kc b/src/test/kc/enum-7.kc index 16fcf4c15..d12c460ff 100644 --- a/src/test/kc/enum-7.kc +++ b/src/test/kc/enum-7.kc @@ -9,7 +9,7 @@ struct Button { void main() { struct Button button = { RED, 24}; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = button.color; SCREEN[1] = button.size; } diff --git a/src/test/kc/enum-8.kc b/src/test/kc/enum-8.kc index cf8871a83..336732a57 100644 --- a/src/test/kc/enum-8.kc +++ b/src/test/kc/enum-8.kc @@ -7,7 +7,7 @@ struct Button { void main() { struct Button button = { RED, 24 }; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = button.color; SCREEN[1] = button.size; } diff --git a/src/test/kc/enum-err-0.kc b/src/test/kc/enum-err-0.kc index 229d0c122..e76ce679b 100644 --- a/src/test/kc/enum-err-0.kc +++ b/src/test/kc/enum-err-0.kc @@ -9,7 +9,7 @@ enum State { void main() { enum State state = ON; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = state; } diff --git a/src/test/kc/enum-err-1.kc b/src/test/kc/enum-err-1.kc index 05c97198c..cb7645ea5 100644 --- a/src/test/kc/enum-err-1.kc +++ b/src/test/kc/enum-err-1.kc @@ -8,7 +8,7 @@ enum State { void main() { enum State state = ON; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = state; } diff --git a/src/test/kc/enum-err-2.kc b/src/test/kc/enum-err-2.kc index c395b0e12..f77d653cd 100644 --- a/src/test/kc/enum-err-2.kc +++ b/src/test/kc/enum-err-2.kc @@ -9,7 +9,7 @@ enum State { void main() { enum State state = ON; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = state; } diff --git a/src/test/kc/euclid-problem-2.kc b/src/test/kc/euclid-problem-2.kc index 79ad9ee2f..c579b14d3 100644 --- a/src/test/kc/euclid-problem-2.kc +++ b/src/test/kc/euclid-problem-2.kc @@ -1,7 +1,7 @@ // Demonstrates a problem where wrong alive ranges result in clobbering an alive variable // The compiler does not realize that A is alive in the statement b=b-a - and thus can clobber it. -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void main() { diff --git a/src/test/kc/examples/bresenham/bitmap-bresenham.kc b/src/test/kc/examples/bresenham/bitmap-bresenham.kc index 8b1c09d40..d7953cb46 100644 --- a/src/test/kc/examples/bresenham/bitmap-bresenham.kc +++ b/src/test/kc/examples/bresenham/bitmap-bresenham.kc @@ -1,8 +1,8 @@ import "c64.kc" import "bitmap-draw.kc" -const char* SCREEN = $400; -const char* BITMAP = $2000; +char* const SCREEN = $400; +char* const BITMAP = $2000; char lines_x[] = { 60, 80, 110, 80, 60, 40, 10, 40, 60 }; char lines_y[] = { 10, 40, 60, 80, 110, 80, 60, 40, 10 }; diff --git a/src/test/kc/examples/fire/sid.kc b/src/test/kc/examples/fire/sid.kc index f02552d16..8b28b5986 100644 --- a/src/test/kc/examples/fire/sid.kc +++ b/src/test/kc/examples/fire/sid.kc @@ -1,8 +1,8 @@ // SID registers for random number generation -const unsigned int* SID_VOICE3_FREQ = $d40e; -const char* SID_VOICE3_FREQ_LOW = $d40e; -const char* SID_VOICE3_FREQ_HIGH = $d40f; -const char* SID_VOICE3_CONTROL = $d412; +unsigned int* const SID_VOICE3_FREQ = $d40e; +char* const SID_VOICE3_FREQ_LOW = $d40e; +char* const SID_VOICE3_FREQ_HIGH = $d40f; +char* const SID_VOICE3_CONTROL = $d412; const char SID_CONTROL_NOISE = $80; const char SID_CONTROL_PULSE = $40; const char SID_CONTROL_SAWTOOTH = $20; @@ -11,7 +11,7 @@ const char SID_CONTROL_TEST = $08; const char SID_CONTROL_RING = $04; const char SID_CONTROL_SYNC = $02; const char SID_CONTROL_GATE = $01; -const char* SID_VOICE3_OSC = $d41b; +char* const SID_VOICE3_OSC = $d41b; // Initialize SID voice 3 for random number generation void sid_rnd_init() { diff --git a/src/test/kc/examples/font-2x2/font-2x2.kc b/src/test/kc/examples/font-2x2/font-2x2.kc index feb6d8730..678837d37 100644 --- a/src/test/kc/examples/font-2x2/font-2x2.kc +++ b/src/test/kc/examples/font-2x2/font-2x2.kc @@ -3,9 +3,9 @@ import "c64" import "string" -const char* SCREEN = 0x0400; -const char* FONT_ORIGINAL = 0x2000; -const char* FONT_COMPRESSED = 0x2800; +char* const SCREEN = 0x0400; +char* const FONT_ORIGINAL = 0x2000; +char* const FONT_COMPRESSED = 0x2800; char align(0x100) FONT_COMPRESSED_MAP[0x100]; void main() { diff --git a/src/test/kc/examples/irq/irq-hyperscreen.kc b/src/test/kc/examples/irq/irq-hyperscreen.kc index 2f4d37766..a5a1d1be0 100644 --- a/src/test/kc/examples/irq/irq-hyperscreen.kc +++ b/src/test/kc/examples/irq/irq-hyperscreen.kc @@ -1,7 +1,7 @@ // A raster IRQ that opens the top/bottom border. import "c64.kc" -const char* GHOST_BYTE = $3fff; +char* const GHOST_BYTE = $3fff; void main() { *GHOST_BYTE = 0; diff --git a/src/test/kc/examples/kernalload/kernalload.kc b/src/test/kc/examples/kernalload/kernalload.kc index 76997b00c..a3f027c77 100644 --- a/src/test/kc/examples/kernalload/kernalload.kc +++ b/src/test/kc/examples/kernalload/kernalload.kc @@ -19,10 +19,10 @@ export char SPRITE[] = kickasm(resource "sprite.png") {{ #pragma data_seg(Data) // Address to load to -const char* LOAD_SPRITE = 0x3000; +char* const LOAD_SPRITE = 0x3000; -const char* SCREEN = 0x0400; -const char* SPRITES_PTR = SCREEN+SPRITE_PTRS; +char* const SCREEN = 0x0400; +char* const SPRITES_PTR = SCREEN+SPRITE_PTRS; void main() { // Load sprite file into memory @@ -52,7 +52,7 @@ char loadFileToMemory( char device, char* filename, char* address) { // Basic ERROR function // ERROR. Show error. void error(char err) { - const char* errCode = 0xff; + char* const errCode = 0xff; *errCode = err; asm { // Basic SHOWERR function @@ -65,8 +65,8 @@ void error(char err) { // Kernal SETNAM function // SETNAM. Set file name parameters. void setnam(char* filename) { - const char* filename_len = 0xfd; - const char** filename_ptr = 0xfe; + char* const filename_len = 0xfd; + char** const filename_ptr = 0xfe; *filename_len = (char)strlen(filename); *filename_ptr = filename; asm { @@ -82,7 +82,7 @@ void setnam(char* filename) { // SETLFS. Set file parameters. void setlfs(char device) { - const char* deviceNum = 0xff; + char* const deviceNum = 0xff; *deviceNum = device; asm { // SETLFS. Set file parameters. diff --git a/src/test/kc/examples/music/music.kc b/src/test/kc/examples/music/music.kc index 24d6fba4b..3600e7ec8 100755 --- a/src/test/kc/examples/music/music.kc +++ b/src/test/kc/examples/music/music.kc @@ -1,7 +1,7 @@ // A simple SID music player playing music in the main loop. import "c64.kc" -const char* MUSIC = $1000; +char* const MUSIC = $1000; // Load the SID kickasm(resource "toiletrensdyr.sid") {{ diff --git a/src/test/kc/examples/music/music_irq.kc b/src/test/kc/examples/music/music_irq.kc index d37968e84..b733aa179 100755 --- a/src/test/kc/examples/music/music_irq.kc +++ b/src/test/kc/examples/music/music_irq.kc @@ -1,7 +1,7 @@ // A simple SID music player using RASTER IRQ import "c64.kc" -const char* MUSIC = $1000; +char* const MUSIC = $1000; // Load the SID kickasm(resource "toiletrensdyr.sid") {{ diff --git a/src/test/kc/examples/nmisamples/nmisamples.kc b/src/test/kc/examples/nmisamples/nmisamples.kc index ed90097cf..96ad4d45d 100644 --- a/src/test/kc/examples/nmisamples/nmisamples.kc +++ b/src/test/kc/examples/nmisamples/nmisamples.kc @@ -7,7 +7,7 @@ import "c64" const unsigned int SAMPLE_SIZE = 0x6100; char SAMPLE[SAMPLE_SIZE] = kickasm(resource "moments_sample.bin") {{ .import binary "moments_sample.bin" }}; -volatile char* sample = SAMPLE; +char* volatile sample = SAMPLE; void main() { // Boosting 8580 Digis diff --git a/src/test/kc/examples/plasma/plasma-unroll.kc b/src/test/kc/examples/plasma/plasma-unroll.kc index 3dd966a04..036b97b59 100644 --- a/src/test/kc/examples/plasma/plasma-unroll.kc +++ b/src/test/kc/examples/plasma/plasma-unroll.kc @@ -10,8 +10,8 @@ import "c64" import "print" import "sid" -const unsigned char* SCREEN1 = $2800; -const unsigned char* CHARSET = $2000; +unsigned char* const SCREEN1 = $2800; +unsigned char* const CHARSET = $2000; const unsigned char align(0x100) SINTABLE[0x100] = kickasm {{ .for(var i=0;i<$100;i++) diff --git a/src/test/kc/examples/plasma/plasma.kc b/src/test/kc/examples/plasma/plasma.kc index 7f166c0d0..399027314 100644 --- a/src/test/kc/examples/plasma/plasma.kc +++ b/src/test/kc/examples/plasma/plasma.kc @@ -8,9 +8,9 @@ import "c64" import "print" import "sid" -const char* SCREEN1 = 0x2800; -const char* SCREEN2 = 0x2c00; -const char* CHARSET = 0x2000; +char* const SCREEN1 = 0x2800; +char* const SCREEN2 = 0x2c00; +char* const CHARSET = 0x2000; const char align(0x100) SINTABLE[0x100] = kickasm {{ .for(var i=0;i<$100;i++) diff --git a/src/test/kc/examples/plasma/sid.kc b/src/test/kc/examples/plasma/sid.kc index 37d8f4821..a1b173f56 100644 --- a/src/test/kc/examples/plasma/sid.kc +++ b/src/test/kc/examples/plasma/sid.kc @@ -1,8 +1,8 @@ // SID registers for random number generation -const unsigned int* SID_VOICE3_FREQ = $d40e; -const char* SID_VOICE3_FREQ_LOW = $d40e; -const char* SID_VOICE3_FREQ_HIGH = $d40f; -const char* SID_VOICE3_CONTROL = $d412; +unsigned int* const SID_VOICE3_FREQ = $d40e; +char* const SID_VOICE3_FREQ_LOW = $d40e; +char* const SID_VOICE3_FREQ_HIGH = $d40f; +char* const SID_VOICE3_CONTROL = $d412; const char SID_CONTROL_NOISE = $80; const char SID_CONTROL_PULSE = $40; const char SID_CONTROL_SAWTOOTH = $20; @@ -11,7 +11,7 @@ const char SID_CONTROL_TEST = $08; const char SID_CONTROL_RING = $04; const char SID_CONTROL_SYNC = $02; const char SID_CONTROL_GATE = $01; -const char* SID_VOICE3_OSC = $d41b; +char* const SID_VOICE3_OSC = $d41b; // Initialize SID voice 3 for random number generation void sid_rnd_init() { diff --git a/src/test/kc/examples/scroll/scroll.kc b/src/test/kc/examples/scroll/scroll.kc index 45c626221..173c3503d 100644 --- a/src/test/kc/examples/scroll/scroll.kc +++ b/src/test/kc/examples/scroll/scroll.kc @@ -1,14 +1,14 @@ -const char* SCREEN = $0400; -const char* RASTER = $d012; -const char* BGCOL = $d020; -const char* SCROLL = $d016; +char* const SCREEN = $0400; +char* const RASTER = $d012; +char* const BGCOL = $d020; +char* const SCROLL = $d016; const char TEXT[] = "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- "; void main() { fillscreen(SCREEN, $20); char scroll = 7; char* nxt = TEXT; - const char* line = SCREEN+40; + char* const line = SCREEN+40; do { // Wait for raster do {} while(*RASTER!=$fe); diff --git a/src/test/kc/examples/sinsprites/sinus-sprites.kc b/src/test/kc/examples/sinsprites/sinus-sprites.kc index 887754d10..f229d2d4f 100644 --- a/src/test/kc/examples/sinsprites/sinus-sprites.kc +++ b/src/test/kc/examples/sinsprites/sinus-sprites.kc @@ -6,8 +6,8 @@ const char sinlen_x = 221; const char sintab_x[221]; const char sinlen_y = 197; const char sintab_y[197]; -const char* sprites = $2000; -const char* SCREEN = $400; +char* const sprites = $2000; +char* const SCREEN = $400; void main() { init(); diff --git a/src/test/kc/fastmultiply-127.kc b/src/test/kc/fastmultiply-127.kc index 982e14f3a..15f29e75a 100644 --- a/src/test/kc/fastmultiply-127.kc +++ b/src/test/kc/fastmultiply-127.kc @@ -62,11 +62,11 @@ unsigned char align($100) mulf127_sqr2_lo[512] = kickasm{{ .fill 512, round(((i-255)/127*(i-255)/127)*127/4) }}; unsigned word mulf8u127(unsigned char a, unsigned char b) { - const byte* memA = $fc; - const byte* memB = $fd; - const word* res = $fe; - const byte* resL = $fe; - const byte* resH = $ff; + byte* const memA = $fc; + byte* const memB = $fd; + word* const res = $fe; + byte* const resL = $fe; + byte* const resH = $ff; *memA = a; *memB = b; asm { diff --git a/src/test/kc/for-empty-increment.kc b/src/test/kc/for-empty-increment.kc index 54b939499..2b14ece13 100644 --- a/src/test/kc/for-empty-increment.kc +++ b/src/test/kc/for-empty-increment.kc @@ -1,7 +1,7 @@ // Tests that for()-loops can have empty increments void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for(unsigned char i=0;i<10;) { SCREEN[i] = i++; } diff --git a/src/test/kc/for-empty-init.kc b/src/test/kc/for-empty-init.kc index d76167b2f..73cb884ba 100644 --- a/src/test/kc/for-empty-init.kc +++ b/src/test/kc/for-empty-init.kc @@ -1,7 +1,7 @@ // Tests that for()-loops can have empty inits void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; unsigned char i=0; for(;i<10;i++) { SCREEN[i] = i; diff --git a/src/test/kc/for-ranged-novar.kc b/src/test/kc/for-ranged-novar.kc index 9fc490dd8..712e0fba0 100644 --- a/src/test/kc/for-ranged-novar.kc +++ b/src/test/kc/for-ranged-novar.kc @@ -1,7 +1,7 @@ // Tests that ranged for()-loops must have an iterator variable void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for( : 0..10) { SCREEN[i] = i; diff --git a/src/test/kc/for-two-vars.kc b/src/test/kc/for-two-vars.kc index 10cf1e510..9c7a639ab 100644 --- a/src/test/kc/for-two-vars.kc +++ b/src/test/kc/for-two-vars.kc @@ -2,7 +2,7 @@ // Illustrates that for()-loops currently cannot contain two variable declarations. void main() { - const byte* SCREEN = 0x400; + byte* const SCREEN = 0x400; byte *sc=SCREEN+39; for( byte i=0; i<40; i++, sc--) *sc = i; diff --git a/src/test/kc/forrangesymbolic.kc b/src/test/kc/forrangesymbolic.kc index 783623f09..07ecb2bc0 100644 --- a/src/test/kc/forrangesymbolic.kc +++ b/src/test/kc/forrangesymbolic.kc @@ -2,7 +2,7 @@ // The following should work but gives a not-constant exception void main() { - const byte* BITMAP = $2000; + byte* const BITMAP = $2000; for(byte* b : BITMAP+$1fff..BITMAP) { *b = $5a; } diff --git a/src/test/kc/function-pointer-noarg-2.kc b/src/test/kc/function-pointer-noarg-2.kc index 0a69dce77..4ac556396 100644 --- a/src/test/kc/function-pointer-noarg-2.kc +++ b/src/test/kc/function-pointer-noarg-2.kc @@ -1,7 +1,7 @@ // Tests creating and assigning pointers to non-args no-return functions void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; void()* f; @@ -15,11 +15,11 @@ void main() { } void fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; } void fn2() { - const byte* BGCOL = $d021; + byte* const BGCOL = $d021; (*BGCOL)++; } \ No newline at end of file diff --git a/src/test/kc/function-pointer-noarg-3.kc b/src/test/kc/function-pointer-noarg-3.kc index 6c2a9a1f9..1b3efb9e9 100644 --- a/src/test/kc/function-pointer-noarg-3.kc +++ b/src/test/kc/function-pointer-noarg-3.kc @@ -1,7 +1,7 @@ // Tests creating and assigning pointers to non-args no-return functions - plus inline kickasm-based calling void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; void()* f; @@ -25,11 +25,11 @@ ff: }} void fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; } void fn2() { - const byte* BGCOL = $d021; + byte* const BGCOL = $d021; (*BGCOL)++; } \ No newline at end of file diff --git a/src/test/kc/function-pointer-noarg-call-10.kc b/src/test/kc/function-pointer-noarg-call-10.kc index 28d267408..a7f1737f8 100644 --- a/src/test/kc/function-pointer-noarg-call-10.kc +++ b/src/test/kc/function-pointer-noarg-call-10.kc @@ -18,7 +18,7 @@ void main() { do10(&world); } -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; volatile byte idx = 0; void print(byte* msg) { diff --git a/src/test/kc/function-pointer-noarg-call-2.kc b/src/test/kc/function-pointer-noarg-call-2.kc index a22dcd6f3..26de3772a 100644 --- a/src/test/kc/function-pointer-noarg-call-2.kc +++ b/src/test/kc/function-pointer-noarg-call-2.kc @@ -1,7 +1,7 @@ // Tests creating, assigning and calling pointers to non-args no-return functions void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; void()* f; @@ -18,11 +18,11 @@ void main() { } void fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; } void fn2() { - const byte* BGCOL = $d021; + byte* const BGCOL = $d021; (*BGCOL)++; } \ No newline at end of file diff --git a/src/test/kc/function-pointer-noarg-call-3.kc b/src/test/kc/function-pointer-noarg-call-3.kc index 6b9b63574..0f60fee33 100644 --- a/src/test/kc/function-pointer-noarg-call-3.kc +++ b/src/test/kc/function-pointer-noarg-call-3.kc @@ -16,11 +16,11 @@ void()* getfn(byte b) { } void fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; } void fn2() { - const byte* BGCOL = $d021; + byte* const BGCOL = $d021; (*BGCOL)++; } \ No newline at end of file diff --git a/src/test/kc/function-pointer-noarg-call-4.kc b/src/test/kc/function-pointer-noarg-call-4.kc index 9a9a8a031..2422d0d54 100644 --- a/src/test/kc/function-pointer-noarg-call-4.kc +++ b/src/test/kc/function-pointer-noarg-call-4.kc @@ -12,7 +12,7 @@ void()* getfn(byte b) { } void fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; } diff --git a/src/test/kc/function-pointer-noarg-call-5.kc b/src/test/kc/function-pointer-noarg-call-5.kc index 0e4c42ae9..de840d4c3 100644 --- a/src/test/kc/function-pointer-noarg-call-5.kc +++ b/src/test/kc/function-pointer-noarg-call-5.kc @@ -1,12 +1,12 @@ // Tests calling into arrays of pointers to non-args no-return functions void fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; } void fn2() { - const byte* BGCOL = $d021; + byte* const BGCOL = $d021; (*BGCOL)++; } diff --git a/src/test/kc/function-pointer-noarg-call-7.kc b/src/test/kc/function-pointer-noarg-call-7.kc index 37dff4eb7..ece5bd16a 100644 --- a/src/test/kc/function-pointer-noarg-call-7.kc +++ b/src/test/kc/function-pointer-noarg-call-7.kc @@ -5,7 +5,7 @@ void do10(void()* fn) { (*fn)(); } -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; const byte msg[] = "hello "; volatile byte idx = 0; diff --git a/src/test/kc/function-pointer-noarg-call-8.kc b/src/test/kc/function-pointer-noarg-call-8.kc index 9be3e0fec..8409ff32d 100644 --- a/src/test/kc/function-pointer-noarg-call-8.kc +++ b/src/test/kc/function-pointer-noarg-call-8.kc @@ -1,17 +1,16 @@ // Tests calling into a function pointer with local variables - void do10(void()* fn) { for( byte i: 0..9) (*fn)(); } -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; const byte msg1[] = "hello "; const byte msg2[] = "world "; -volatile byte* msg; -volatile byte idx = 0; +byte* volatile msg; +byte volatile idx = 0; void hello() { byte i=0; diff --git a/src/test/kc/function-pointer-noarg-call-9.kc b/src/test/kc/function-pointer-noarg-call-9.kc index 68d752f23..bab0cfe99 100644 --- a/src/test/kc/function-pointer-noarg-call-9.kc +++ b/src/test/kc/function-pointer-noarg-call-9.kc @@ -1,6 +1,6 @@ // Tests calling into a function pointer which modifies global volatile -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; volatile byte idx = 0; diff --git a/src/test/kc/function-pointer-noarg-call.kc b/src/test/kc/function-pointer-noarg-call.kc index ae84dc2fb..aef59d025 100644 --- a/src/test/kc/function-pointer-noarg-call.kc +++ b/src/test/kc/function-pointer-noarg-call.kc @@ -1,7 +1,7 @@ // Tests creating, assigning and calling pointers to non-args no-return functions void fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; } diff --git a/src/test/kc/function-pointer-noarg.kc b/src/test/kc/function-pointer-noarg.kc index 5f7452543..c10a930d3 100644 --- a/src/test/kc/function-pointer-noarg.kc +++ b/src/test/kc/function-pointer-noarg.kc @@ -1,7 +1,7 @@ // Tests creating pointers to non-args no-return functions void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; void()* f; f = &fn1; @@ -14,11 +14,11 @@ void main() { } void fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; } void fn2() { - const byte* BGCOL = $d021; + byte* const BGCOL = $d021; (*BGCOL)++; } \ No newline at end of file diff --git a/src/test/kc/function-pointer-return.kc b/src/test/kc/function-pointer-return.kc index af2d5ff84..a46f4dc18 100644 --- a/src/test/kc/function-pointer-return.kc +++ b/src/test/kc/function-pointer-return.kc @@ -1,7 +1,7 @@ // Tests creating and assigning pointers to non-args return with function value void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; byte()* f; @@ -18,13 +18,13 @@ void main() { } byte fn1() { - const byte* BORDERCOL = $d020; + byte* const BORDERCOL = $d020; (*BORDERCOL)++; return *BORDERCOL; } byte fn2() { - const byte* BGCOL = $d021; + byte* const BGCOL = $d021; (*BGCOL)++; return *BGCOL; } \ No newline at end of file diff --git a/src/test/kc/gfxbank.kc b/src/test/kc/gfxbank.kc index 990aaa585..2be26d023 100644 --- a/src/test/kc/gfxbank.kc +++ b/src/test/kc/gfxbank.kc @@ -3,6 +3,6 @@ import "c64" void main() { - const byte* PLAYFIELD_CHARSET = $2800; + byte* const PLAYFIELD_CHARSET = $2800; vicSelectGfxBank(PLAYFIELD_CHARSET); } diff --git a/src/test/kc/global-pc-multiple.kc b/src/test/kc/global-pc-multiple.kc index 5d1ffafd1..2ad66b28a 100644 --- a/src/test/kc/global-pc-multiple.kc +++ b/src/test/kc/global-pc-multiple.kc @@ -1,8 +1,8 @@ // Test setting the program PC through a #pc directive -const byte* BGCOL = 0xd021; -const byte* RASTER = 0xd012; +byte* const BGCOL = 0xd021; +byte* const RASTER = 0xd012; #pragma pc(0x1000) diff --git a/src/test/kc/global-pc.kc b/src/test/kc/global-pc.kc index b3ca5ee3e..647b3bd6f 100644 --- a/src/test/kc/global-pc.kc +++ b/src/test/kc/global-pc.kc @@ -2,8 +2,8 @@ #pragma pc(0x1000) -const byte* BGCOL = 0xd021; -const byte* RASTER = 0xd012; +byte* const BGCOL = 0xd021; +byte* const RASTER = 0xd012; void main() { asm { sei } diff --git a/src/test/kc/hex2dec.kc b/src/test/kc/hex2dec.kc index 8722782bb..878dcf525 100644 --- a/src/test/kc/hex2dec.kc +++ b/src/test/kc/hex2dec.kc @@ -1,8 +1,8 @@ // Testing hex to decimal conversion -const unsigned char *control = 0xd011; -const unsigned char *raster = 0xd012; -const unsigned char *bordercol = 0xd020; +unsigned char * const control = 0xd011; +unsigned char * const raster = 0xd012; +unsigned char * const bordercol = 0xd020; void main() { asm { sei } diff --git a/src/test/kc/imported.kc b/src/test/kc/imported.kc index a3bde0ea6..0306f3f1f 100644 --- a/src/test/kc/imported.kc +++ b/src/test/kc/imported.kc @@ -1,2 +1,2 @@ -const byte *BGCOL = $d021; +byte * const BGCOL = $d021; const byte RED = 2; diff --git a/src/test/kc/initializer-0.kc b/src/test/kc/initializer-0.kc index ded3acd82..d3145b3e9 100644 --- a/src/test/kc/initializer-0.kc +++ b/src/test/kc/initializer-0.kc @@ -4,7 +4,7 @@ unsigned char chars[] = { 1, 2, 3 }; void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; char idx = 0; for( char i: 0..2) { SCREEN[idx++] = chars[i]; diff --git a/src/test/kc/initializer-1.kc b/src/test/kc/initializer-1.kc index d5f319215..1a81e0696 100644 --- a/src/test/kc/initializer-1.kc +++ b/src/test/kc/initializer-1.kc @@ -4,7 +4,7 @@ unsigned int words[] = { 1, 2, 3 }; void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; char idx = 0; for( char i: 0..2) { SCREEN[idx++] = STRING; byte* ptr = (byte*) { *(PTR+1), *PTR }; - const byte* SCREEN = $400; + byte* const SCREEN = $400; *SCREEN = *ptr; } \ No newline at end of file diff --git a/src/test/kc/inline-string-4.kc b/src/test/kc/inline-string-4.kc index 25845b5a5..ce376fd95 100644 --- a/src/test/kc/inline-string-4.kc +++ b/src/test/kc/inline-string-4.kc @@ -6,7 +6,7 @@ void main() { output(dw); } -const unsigned long* screen = 0x0400; +unsigned long* const screen = 0x0400; void output(unsigned long dw) { *screen = dw; diff --git a/src/test/kc/inline-word.kc b/src/test/kc/inline-word.kc index 7502a197d..141276c11 100644 --- a/src/test/kc/inline-word.kc +++ b/src/test/kc/inline-word.kc @@ -1,4 +1,4 @@ -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { byte his[] = { >SCREEN, >SCREEN+$100, >SCREEN+$200 }; // constant array diff --git a/src/test/kc/int-conversion.kc b/src/test/kc/int-conversion.kc index f1e0ff9de..90ee3f0c2 100644 --- a/src/test/kc/int-conversion.kc +++ b/src/test/kc/int-conversion.kc @@ -3,8 +3,8 @@ const byte RED = 2ub; const byte GREEN = 5ub; -const byte* SCREEN = $0400; -const byte* COLS = $d800; +byte* const SCREEN = $0400; +byte* const COLS = $d800; byte idx = 0ub; void main() { diff --git a/src/test/kc/int-literals.kc b/src/test/kc/int-literals.kc index 6c478a300..7be3188eb 100644 --- a/src/test/kc/int-literals.kc +++ b/src/test/kc/int-literals.kc @@ -3,8 +3,8 @@ const byte RED = 2ub; const byte GREEN = 5ub; -const byte* SCREEN = $0400uw; -const byte* COLS = $d800uw; +byte* const SCREEN = $0400uw; +byte* const COLS = $d800uw; byte idx = 0ub; void main() { diff --git a/src/test/kc/interrupt-volatile-reuse-problem1.kc b/src/test/kc/interrupt-volatile-reuse-problem1.kc index cca1b6c6a..6c880ee29 100644 --- a/src/test/kc/interrupt-volatile-reuse-problem1.kc +++ b/src/test/kc/interrupt-volatile-reuse-problem1.kc @@ -1,6 +1,6 @@ // Illustrates problem where volatiles reuse the same ZP addresses for multiple overlapping volatiles -const void()** KERNEL_IRQ = $0314; -const byte* SCREEN=$400; +void()** const KERNEL_IRQ = $0314; +byte* const SCREEN=$400; volatile byte col1 = 0; volatile byte col2 = 8; diff --git a/src/test/kc/interrupt-volatile-reuse-problem2.kc b/src/test/kc/interrupt-volatile-reuse-problem2.kc index 3ba57d6fa..0a6aa2a84 100644 --- a/src/test/kc/interrupt-volatile-reuse-problem2.kc +++ b/src/test/kc/interrupt-volatile-reuse-problem2.kc @@ -1,9 +1,9 @@ // Illustrates problem where volatiles reuse ZP addresses of other variables -const void()** KERNEL_IRQ = $0314; -const byte* IRQ_STATUS = $d019; -const byte* CIA1_INTERRUPT = $dc0d; +void()** const KERNEL_IRQ = $0314; +byte* const IRQ_STATUS = $d019; +byte* const CIA1_INTERRUPT = $dc0d; -const byte* SCREEN=$400; +byte* const SCREEN=$400; volatile byte col1 = 0; void main() { diff --git a/src/test/kc/irq-hardware-clobber.kc b/src/test/kc/irq-hardware-clobber.kc index 750027852..04bfe37e4 100644 --- a/src/test/kc/irq-hardware-clobber.kc +++ b/src/test/kc/irq-hardware-clobber.kc @@ -1,30 +1,30 @@ // A minimal working raster hardware IRQ with clobber-based register savings -const void()** KERNEL_IRQ = $0314; -const void()** HARDWARE_IRQ = $fffe; -const byte* RASTER = $d012; -const byte* VIC_CONTROL = $d011; -const byte* IRQ_STATUS = $d019; -const byte* IRQ_ENABLE = $d01a; +void()** const KERNEL_IRQ = $0314; +void()** const HARDWARE_IRQ = $fffe; +byte* const RASTER = $d012; +byte* const VIC_CONTROL = $d011; +byte* const IRQ_STATUS = $d019; +byte* const IRQ_ENABLE = $d01a; const byte IRQ_RASTER = %00000001; const byte IRQ_COLLISION_BG = %00000010; const byte IRQ_COLLISION_SPRITE = %00000100; const byte IRQ_LIGHTPEN = %00001000; -const byte* BGCOL = $d020; -const byte* FGCOL = $d021; +byte* const BGCOL = $d020; +byte* const FGCOL = $d021; const byte WHITE = 1; const byte BLACK = 0; -const byte* CIA1_INTERRUPT = $dc0d; +byte* const CIA1_INTERRUPT = $dc0d; const byte CIA_INTERRUPT_CLEAR = $7f; // Processor port data direction register -const byte* PROCPORT_DDR = $00; +byte* const PROCPORT_DDR = $00; // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written const byte PROCPORT_DDR_MEMORY_MASK = %00000111; // Processor Port Register controlling RAM/ROM configuration and the datasette -const byte* PROCPORT = $01; +byte* const PROCPORT = $01; // RAM in $A000, $E000 I/O in $D000 const byte PROCPORT_RAM_IO = %00110101; // RAM in $A000, $E000 CHAR ROM in $D000 diff --git a/src/test/kc/irq-hardware-stack.kc b/src/test/kc/irq-hardware-stack.kc index 62e945e87..29e48f90f 100644 --- a/src/test/kc/irq-hardware-stack.kc +++ b/src/test/kc/irq-hardware-stack.kc @@ -1,30 +1,30 @@ // A minimal working raster IRQ -const void()** KERNEL_IRQ = $0314; -const void()** HARDWARE_IRQ = $fffe; -const byte* RASTER = $d012; -const byte* VIC_CONTROL = $d011; -const byte* IRQ_STATUS = $d019; -const byte* IRQ_ENABLE = $d01a; +void()** const KERNEL_IRQ = $0314; +void()** const HARDWARE_IRQ = $fffe; +byte* const RASTER = $d012; +byte* const VIC_CONTROL = $d011; +byte* const IRQ_STATUS = $d019; +byte* const IRQ_ENABLE = $d01a; const byte IRQ_RASTER = %00000001; const byte IRQ_COLLISION_BG = %00000010; const byte IRQ_COLLISION_SPRITE = %00000100; const byte IRQ_LIGHTPEN = %00001000; -const byte* BGCOL = $d020; -const byte* FGCOL = $d021; +byte* const BGCOL = $d020; +byte* const FGCOL = $d021; const byte WHITE = 1; const byte BLACK = 0; -const byte* CIA1_INTERRUPT = $dc0d; +byte* const CIA1_INTERRUPT = $dc0d; const byte CIA_INTERRUPT_CLEAR = $7f; // Processor port data direction register -const byte* PROCPORT_DDR = $00; +byte* const PROCPORT_DDR = $00; // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written const byte PROCPORT_DDR_MEMORY_MASK = %00000111; // Processor Port Register controlling RAM/ROM configuration and the datasette -const byte* PROCPORT = $01; +byte* const PROCPORT = $01; // RAM in $A000, $E000 I/O in $D000 const byte PROCPORT_RAM_IO = %00110101; // RAM in $A000, $E000 CHAR ROM in $D000 diff --git a/src/test/kc/irq-hardware.kc b/src/test/kc/irq-hardware.kc index c9fe90896..f01489aab 100644 --- a/src/test/kc/irq-hardware.kc +++ b/src/test/kc/irq-hardware.kc @@ -1,30 +1,30 @@ // A minimal working raster IRQ -const void()** KERNEL_IRQ = $0314; -const void()** HARDWARE_IRQ = $fffe; -const byte* RASTER = $d012; -const byte* VIC_CONTROL = $d011; -const byte* IRQ_STATUS = $d019; -const byte* IRQ_ENABLE = $d01a; +void()** const KERNEL_IRQ = $0314; +void()** const HARDWARE_IRQ = $fffe; +byte* const RASTER = $d012; +byte* const VIC_CONTROL = $d011; +byte* const IRQ_STATUS = $d019; +byte* const IRQ_ENABLE = $d01a; const byte IRQ_RASTER = %00000001; const byte IRQ_COLLISION_BG = %00000010; const byte IRQ_COLLISION_SPRITE = %00000100; const byte IRQ_LIGHTPEN = %00001000; -const byte* BGCOL = $d020; -const byte* FGCOL = $d021; +byte* const BGCOL = $d020; +byte* const FGCOL = $d021; const byte WHITE = 1; const byte BLACK = 0; -const byte* CIA1_INTERRUPT = $dc0d; +byte* const CIA1_INTERRUPT = $dc0d; const byte CIA_INTERRUPT_CLEAR = $7f; // Processor port data direction register -const byte* PROCPORT_DDR = $00; +byte* const PROCPORT_DDR = $00; // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written const byte PROCPORT_DDR_MEMORY_MASK = %00000111; // Processor Port Register controlling RAM/ROM configuration and the datasette -const byte* PROCPORT = $01; +byte* const PROCPORT = $01; // RAM in $A000, $E000 I/O in $D000 const byte PROCPORT_RAM_IO = %00110101; // RAM in $A000, $E000 CHAR ROM in $D000 diff --git a/src/test/kc/irq-idx-problem.kc b/src/test/kc/irq-idx-problem.kc index b5d55cf77..9f923d225 100644 --- a/src/test/kc/irq-idx-problem.kc +++ b/src/test/kc/irq-idx-problem.kc @@ -1,7 +1,7 @@ // Test interrupt routine using a variable between calls (irq_idx) import "c64" -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; void main() { asm { sei } @@ -19,7 +19,7 @@ void main() { asm { cli } } -const byte *VIC_BASE = $D000; +byte * const VIC_BASE = $D000; const byte VIC_SIZE = 48; const byte IRQ_CHANGE_NEXT = $7f; diff --git a/src/test/kc/irq-kernel.kc b/src/test/kc/irq-kernel.kc index 9bf039215..f65f4aca2 100644 --- a/src/test/kc/irq-kernel.kc +++ b/src/test/kc/irq-kernel.kc @@ -1,19 +1,19 @@ // A minimal working raster IRQ -const void()** KERNEL_IRQ = $0314; -const byte* RASTER = $d012; -const byte* VIC_CONTROL = $d011; -const byte* IRQ_STATUS = $d019; -const byte* IRQ_ENABLE = $d01a; +void()** const KERNEL_IRQ = $0314; +byte* const RASTER = $d012; +byte* const VIC_CONTROL = $d011; +byte* const IRQ_STATUS = $d019; +byte* const IRQ_ENABLE = $d01a; const byte IRQ_RASTER = %00000001; const byte IRQ_COLLISION_BG = %00000010; const byte IRQ_COLLISION_SPRITE = %00000100; const byte IRQ_LIGHTPEN = %00001000; -const byte* BGCOL = $d020; +byte* const BGCOL = $d020; const byte WHITE = 1; const byte BLACK = 0; -const byte* CIA1_INTERRUPT = $dc0d; +byte* const CIA1_INTERRUPT = $dc0d; const byte CIA_INTERRUPT_CLEAR = $7f; void main() { diff --git a/src/test/kc/irq-local-var-overlap-problem.kc b/src/test/kc/irq-local-var-overlap-problem.kc index b84d384b9..df81a9efe 100644 --- a/src/test/kc/irq-local-var-overlap-problem.kc +++ b/src/test/kc/irq-local-var-overlap-problem.kc @@ -1,15 +1,15 @@ // Illustrates a problem where local variables inside an IRQ are assigned the same zeropage as a variable outside the IRQ -const void()** KERNEL_IRQ = $0314; -const byte* RASTER = $d012; -const byte* VIC_CONTROL = $d011; -const byte* IRQ_STATUS = $d019; -const byte* IRQ_ENABLE = $d01a; +void()** const KERNEL_IRQ = $0314; +byte* const RASTER = $d012; +byte* const VIC_CONTROL = $d011; +byte* const IRQ_STATUS = $d019; +byte* const IRQ_ENABLE = $d01a; const byte IRQ_RASTER = %00000001; -const byte* BGCOL = $d020; -const byte* FGCOL = $d021; +byte* const BGCOL = $d020; +byte* const FGCOL = $d021; -const byte* CIA1_INTERRUPT = $dc0d; +byte* const CIA1_INTERRUPT = $dc0d; const byte CIA_INTERRUPT_CLEAR = $7f; diff --git a/src/test/kc/irq-raster.kc b/src/test/kc/irq-raster.kc index 9a2547324..9c3f7930f 100644 --- a/src/test/kc/irq-raster.kc +++ b/src/test/kc/irq-raster.kc @@ -1,19 +1,19 @@ // A minimal working raster IRQ -const void()** KERNEL_IRQ = $0314; -const byte* RASTER = $d012; -const byte* VIC_CONTROL = $d011; -const byte* IRQ_STATUS = $d019; -const byte* IRQ_ENABLE = $d01a; +void()** const KERNEL_IRQ = $0314; +byte* const RASTER = $d012; +byte* const VIC_CONTROL = $d011; +byte* const IRQ_STATUS = $d019; +byte* const IRQ_ENABLE = $d01a; const byte IRQ_RASTER = %00000001; const byte IRQ_COLLISION_BG = %00000010; const byte IRQ_COLLISION_SPRITE = %00000100; const byte IRQ_LIGHTPEN = %00001000; -const byte* BGCOL = $d020; +byte* const BGCOL = $d020; const byte WHITE = 1; const byte BLACK = 0; -const byte* CIA1_INTERRUPT = $dc0d; +byte* const CIA1_INTERRUPT = $dc0d; const byte CIA_INTERRUPT_CLEAR = $7f; void main() { diff --git a/src/test/kc/irq-volatile-bool-problem.kc b/src/test/kc/irq-volatile-bool-problem.kc index d31b28465..113956331 100644 --- a/src/test/kc/irq-volatile-bool-problem.kc +++ b/src/test/kc/irq-volatile-bool-problem.kc @@ -1,15 +1,15 @@ // Illustrates a problem where a volatile bool modified at the end of an IRQ is not stored properly // because it is assigned to the A register -const void()** KERNEL_IRQ = $0314; -const byte* RASTER = $d012; -const byte* VIC_CONTROL = $d011; -const byte* IRQ_STATUS = $d019; -const byte* IRQ_ENABLE = $d01a; +void()** const KERNEL_IRQ = $0314; +byte* const RASTER = $d012; +byte* const VIC_CONTROL = $d011; +byte* const IRQ_STATUS = $d019; +byte* const IRQ_ENABLE = $d01a; const byte IRQ_RASTER = %00000001; -const byte* BGCOL = $d020; +byte* const BGCOL = $d020; -const byte* CIA1_INTERRUPT = $dc0d; +byte* const CIA1_INTERRUPT = $dc0d; const byte CIA_INTERRUPT_CLEAR = $7f; diff --git a/src/test/kc/kickasm-uses-prevent-deletion.kc b/src/test/kc/kickasm-uses-prevent-deletion.kc index 3a1424f06..a4d84cd37 100644 --- a/src/test/kc/kickasm-uses-prevent-deletion.kc +++ b/src/test/kc/kickasm-uses-prevent-deletion.kc @@ -1,8 +1,8 @@ // Ensure that an inline kickasm uses-clause is anough to prevent a function from being deleted // The vector used when the KERNAL serves IRQ interrupts -const void()** KERNEL_IRQ = $0314; -const byte* BGCOL = $d021; +void()** const KERNEL_IRQ = $0314; +byte* const BGCOL = $d021; const byte BLACK = $0; const byte WHITE = $1; diff --git a/src/test/kc/literal-char-minus-number.kc b/src/test/kc/literal-char-minus-number.kc index f3fcccc34..5cce3c0f4 100644 --- a/src/test/kc/literal-char-minus-number.kc +++ b/src/test/kc/literal-char-minus-number.kc @@ -1,6 +1,6 @@ // Tests subtracting a number from a literal char void main() { - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; *SCREEN = 'a' - 1; } \ No newline at end of file diff --git a/src/test/kc/literal-string-array.kc b/src/test/kc/literal-string-array.kc index 2595c9456..66d7427aa 100644 --- a/src/test/kc/literal-string-array.kc +++ b/src/test/kc/literal-string-array.kc @@ -1,7 +1,7 @@ // Tests literal string array -const char* SCREEN = 0x0400; -const void* NUL = (void*)0; +char* const SCREEN = 0x0400; +void* const NUL = (void*)0; // Works // char*[] msgs = { (char*)"hello", (char*)"cruel", (char*)"world", (char*)NUL }; diff --git a/src/test/kc/literal-strings.kc b/src/test/kc/literal-strings.kc index 77d489083..955006f2f 100644 --- a/src/test/kc/literal-strings.kc +++ b/src/test/kc/literal-strings.kc @@ -1,6 +1,6 @@ // Tests literal strings with and without zero-termination -const byte* SCREEN = $400; +byte* const SCREEN = $400; byte msgz[] = "cml"z; byte msg[] = "cml"; diff --git a/src/test/kc/liverange-1.kc b/src/test/kc/liverange-1.kc index 1bf8e935b..7412bb8ae 100644 --- a/src/test/kc/liverange-1.kc +++ b/src/test/kc/liverange-1.kc @@ -7,7 +7,7 @@ void main() { out('m'); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void out(char c) { diff --git a/src/test/kc/liverange-10.kc b/src/test/kc/liverange-10.kc index f037d7dbd..baa904ea1 100644 --- a/src/test/kc/liverange-10.kc +++ b/src/test/kc/liverange-10.kc @@ -1,7 +1,7 @@ // Test effective live range and register allocation // Here outsw::sw and outw::w should have the same allocation -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void main() { diff --git a/src/test/kc/liverange-2.kc b/src/test/kc/liverange-2.kc index 7b1a915f3..d219674b4 100644 --- a/src/test/kc/liverange-2.kc +++ b/src/test/kc/liverange-2.kc @@ -12,7 +12,7 @@ void main() { } } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void print(char b, char ca) { SCREEN[b] = ca; diff --git a/src/test/kc/liverange-3.kc b/src/test/kc/liverange-3.kc index ddbba9aad..866dea7eb 100644 --- a/src/test/kc/liverange-3.kc +++ b/src/test/kc/liverange-3.kc @@ -12,7 +12,7 @@ void main() { } } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void print(char b, char ca) { (*(SCREEN+999))++; diff --git a/src/test/kc/liverange-4.kc b/src/test/kc/liverange-4.kc index d47f55167..bb2947fce 100644 --- a/src/test/kc/liverange-4.kc +++ b/src/test/kc/liverange-4.kc @@ -12,7 +12,7 @@ void main() { } } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void print(char b, char ca) { out(b, ca); diff --git a/src/test/kc/liverange-5.kc b/src/test/kc/liverange-5.kc index d364a487e..563276911 100644 --- a/src/test/kc/liverange-5.kc +++ b/src/test/kc/liverange-5.kc @@ -12,7 +12,7 @@ void main() { } } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void print(char b, char ca) { out(b, ca); diff --git a/src/test/kc/liverange-6.kc b/src/test/kc/liverange-6.kc index 58dec6c90..1345ba670 100644 --- a/src/test/kc/liverange-6.kc +++ b/src/test/kc/liverange-6.kc @@ -3,7 +3,7 @@ byte msg[] = "hello world!"; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void main() { diff --git a/src/test/kc/liverange-7.kc b/src/test/kc/liverange-7.kc index a0fd2e3ec..a82b52e08 100644 --- a/src/test/kc/liverange-7.kc +++ b/src/test/kc/liverange-7.kc @@ -1,7 +1,7 @@ // Test effective live range and register allocation // Here main::c, out2::c and out::c can all have the same allocation - and the global idx can be allocated to a hardware register. -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void main() { diff --git a/src/test/kc/liverange-8.kc b/src/test/kc/liverange-8.kc index 433b7144e..eafc6db10 100644 --- a/src/test/kc/liverange-8.kc +++ b/src/test/kc/liverange-8.kc @@ -1,7 +1,7 @@ // Test effective live range and register allocation // Here main::c, out2::c and out::c can all have the same allocation - and the global idx can be allocated to a hardware register. -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void main() { diff --git a/src/test/kc/liverange-9.kc b/src/test/kc/liverange-9.kc index 20da9494d..b3d09359f 100644 --- a/src/test/kc/liverange-9.kc +++ b/src/test/kc/liverange-9.kc @@ -1,7 +1,7 @@ // Test effective live range and register allocation // Here main::c, outsw::c and outw::c can all have the same allocation -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void main() { diff --git a/src/test/kc/localscope-loops.kc b/src/test/kc/localscope-loops.kc index 9178a434e..7ce5253f7 100644 --- a/src/test/kc/localscope-loops.kc +++ b/src/test/kc/localscope-loops.kc @@ -1,6 +1,6 @@ // Illustrates introducing local scopes inside loops etc -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { for (byte i: 0..5) SCREEN[i] = 'a'; diff --git a/src/test/kc/localscope-simple.kc b/src/test/kc/localscope-simple.kc index 72a4d3c9d..b10c3e817 100644 --- a/src/test/kc/localscope-simple.kc +++ b/src/test/kc/localscope-simple.kc @@ -1,6 +1,6 @@ // Tests anonymous scopes inside functions -const byte* BGCOL = $d021; +byte* const BGCOL = $d021; void main() { { diff --git a/src/test/kc/longbranch-interrupt-problem.kc b/src/test/kc/longbranch-interrupt-problem.kc index c66873ed5..8085bbbbc 100644 --- a/src/test/kc/longbranch-interrupt-problem.kc +++ b/src/test/kc/longbranch-interrupt-problem.kc @@ -1,7 +1,7 @@ // Tests that long branch fixing works with interrupt exits (to $ea81) -const void()** KERNEL_IRQ = $0314; -const byte* BGCOL = $d020; +void()** const KERNEL_IRQ = $0314; +byte* const BGCOL = $d020; volatile byte col = 0; void main() { diff --git a/src/test/kc/loop-break-nested.kc b/src/test/kc/loop-break-nested.kc index d7e86ccea..bcb9b15f9 100644 --- a/src/test/kc/loop-break-nested.kc +++ b/src/test/kc/loop-break-nested.kc @@ -1,6 +1,6 @@ // Tests break statement in a simple loop -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { for(byte* line = $400; line<$400+40*25;line+=40 ) { diff --git a/src/test/kc/loop-break.kc b/src/test/kc/loop-break.kc index 6a3c79adf..cababe09d 100644 --- a/src/test/kc/loop-break.kc +++ b/src/test/kc/loop-break.kc @@ -1,6 +1,6 @@ // Tests break statement in a simple loop -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { for( byte i: 0..40*6) { diff --git a/src/test/kc/loop-continue.kc b/src/test/kc/loop-continue.kc index ecb85ad80..dab08fecc 100644 --- a/src/test/kc/loop-continue.kc +++ b/src/test/kc/loop-continue.kc @@ -1,6 +1,6 @@ // Tests break statement in a simple loop -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { for( byte i: 0..40*6) { diff --git a/src/test/kc/loop-for-continue.kc b/src/test/kc/loop-for-continue.kc index bf6c0c01f..53f9b52ac 100644 --- a/src/test/kc/loop-for-continue.kc +++ b/src/test/kc/loop-for-continue.kc @@ -1,6 +1,6 @@ // Tests continue statement in a simple for()-loop -const char* SCREEN = $400; +char* const SCREEN = $400; const char MESSAGE[] = "hello brave new world!"; diff --git a/src/test/kc/loop-for-empty-body.kc b/src/test/kc/loop-for-empty-body.kc index 4cba743ad..7d375548c 100644 --- a/src/test/kc/loop-for-empty-body.kc +++ b/src/test/kc/loop-for-empty-body.kc @@ -1,7 +1,7 @@ // Test a for-loop with an empty body const char str[] = "Hello!"; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { char b = 0; diff --git a/src/test/kc/loop-problem2.kc b/src/test/kc/loop-problem2.kc index cbd23c78c..f9db239e2 100644 --- a/src/test/kc/loop-problem2.kc +++ b/src/test/kc/loop-problem2.kc @@ -1,5 +1,5 @@ -const byte* BORDERCOL = $d020; -const byte* SCREEN = $0400; +byte* const BORDERCOL = $d020; +byte* const SCREEN = $0400; void main() { print_cls(); diff --git a/src/test/kc/loop-while-continue.kc b/src/test/kc/loop-while-continue.kc index 9316939be..9653a1848 100644 --- a/src/test/kc/loop-while-continue.kc +++ b/src/test/kc/loop-while-continue.kc @@ -1,6 +1,6 @@ // Tests break statement in a simple loop -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { byte i=0; diff --git a/src/test/kc/loophead-problem-2.kc b/src/test/kc/loophead-problem-2.kc index 1d943102f..641e6e386 100644 --- a/src/test/kc/loophead-problem-2.kc +++ b/src/test/kc/loophead-problem-2.kc @@ -6,7 +6,7 @@ int ball_y[8] = { 50, 100, -200, 12, -100, 75, 0, -121 } ; void main() { - const char* screen = 0x0400; + char* const screen = 0x0400; char hit_check=scan_for_lowest(); screen[0] = hit_check; screen[2] = > 6) & 0xF0) | (((unsigned int)CHARSET >> 10) & 0x0E); const char PAGE2 = ((((unsigned int)SCREEN2) >> 6) & 0xF0) | (((unsigned int)CHARSET >> 10) & 0x0E); diff --git a/src/test/kc/millfork-benchmarks/romsum-kc.kc b/src/test/kc/millfork-benchmarks/romsum-kc.kc index 3d6da6cdb..2e8708dda 100644 --- a/src/test/kc/millfork-benchmarks/romsum-kc.kc +++ b/src/test/kc/millfork-benchmarks/romsum-kc.kc @@ -1,7 +1,7 @@ import "benchcommon" import "print" -const byte* rom = (byte*)0xe000; +byte* const rom = (byte*)0xe000; unsigned int sum(void) { unsigned int s; diff --git a/src/test/kc/min-fmul-16.kc b/src/test/kc/min-fmul-16.kc index be2062855..e0d1a85f6 100644 --- a/src/test/kc/min-fmul-16.kc +++ b/src/test/kc/min-fmul-16.kc @@ -70,9 +70,9 @@ void mulf_init() { // Fast multiply two unsigned words to a double word result // Done in assembler to utilize fast addition A+X dword mulf16u(word a, word b) { - const word* memA = $f8; - const word* memB = $fa; - const dword* memR = $fc; + word* const memA = $f8; + word* const memB = $fa; + dword* const memR = $fc; *memA = a; *memB = b; asm { diff --git a/src/test/kc/mul8u-min.kc b/src/test/kc/mul8u-min.kc index 83f0668cb..9d7239293 100644 --- a/src/test/kc/mul8u-min.kc +++ b/src/test/kc/mul8u-min.kc @@ -4,7 +4,7 @@ import "multiply" void main() { - const word* screen = 0x0400; + word* const screen = 0x0400; byte i = 0; for(byte a: 0..5) diff --git a/src/test/kc/multiply-2s.kc b/src/test/kc/multiply-2s.kc index f9a21bd9e..38b134dfd 100644 --- a/src/test/kc/multiply-2s.kc +++ b/src/test/kc/multiply-2s.kc @@ -1,7 +1,7 @@ // Check that multiplication by factors of 2 is converted to shifts void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for(byte i: 0..10) { (SCREEN+0*40)[i] = i*1; diff --git a/src/test/kc/multiply-ns.kc b/src/test/kc/multiply-ns.kc index 7da716e11..4e2befc86 100644 --- a/src/test/kc/multiply-ns.kc +++ b/src/test/kc/multiply-ns.kc @@ -1,7 +1,7 @@ // Check that multiplication by constants is converted to shift/add void main() { - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; for(byte i: 0..17) { (SCREEN+0*40)[i] = i*1; diff --git a/src/test/kc/nomodify-3.kc b/src/test/kc/nomodify-3.kc index 5cf0b389e..2746573c8 100644 --- a/src/test/kc/nomodify-3.kc +++ b/src/test/kc/nomodify-3.kc @@ -2,7 +2,7 @@ const volatile char i = 7; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { SCREEN[0] = i; diff --git a/src/test/kc/nomodify-4.kc b/src/test/kc/nomodify-4.kc index 1f43268d6..e794eff4b 100644 --- a/src/test/kc/nomodify-4.kc +++ b/src/test/kc/nomodify-4.kc @@ -5,7 +5,7 @@ void main() { print('b'); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void print(const char c) { *SCREEN = c; diff --git a/src/test/kc/nomodify-5.kc b/src/test/kc/nomodify-5.kc index 85e887c54..297eb1ed4 100644 --- a/src/test/kc/nomodify-5.kc +++ b/src/test/kc/nomodify-5.kc @@ -5,7 +5,7 @@ void main() { print('b'); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void print(const char c) { *SCREEN = c++; diff --git a/src/test/kc/noop-cast-elimination.kc b/src/test/kc/noop-cast-elimination.kc index 11c2759a7..49425ef37 100644 --- a/src/test/kc/noop-cast-elimination.kc +++ b/src/test/kc/noop-cast-elimination.kc @@ -2,7 +2,7 @@ void main() { - const signed word* screen = 0x400; + signed word* const screen = 0x400; signed word sw = 0x1234; for( byte i: 0..10) { sw += (signed byte)i; diff --git a/src/test/kc/number-conversion.kc b/src/test/kc/number-conversion.kc index 67ee702f6..374359934 100644 --- a/src/test/kc/number-conversion.kc +++ b/src/test/kc/number-conversion.kc @@ -67,8 +67,8 @@ void main() { const byte RED = 2ub; const byte GREEN = 5ub; -const byte* SCREEN = $0400uw; -const byte* COLS = $d800uw; +byte* const SCREEN = $0400uw; +byte* const COLS = $d800uw; byte idx = 0ub; // Check that the two passed type IDs are equal. diff --git a/src/test/kc/number-inference-sum.kc b/src/test/kc/number-inference-sum.kc index b0aa72f6a..655ba890c 100644 --- a/src/test/kc/number-inference-sum.kc +++ b/src/test/kc/number-inference-sum.kc @@ -2,8 +2,8 @@ // Currently fails - because the compiler does not handle byte+byte correctly (not truncating the result to 8 bits) void main() { - const word* screen = 0x0400; - const byte* bgcol = 0xd020; + word* const screen = 0x0400; + byte* const bgcol = 0xd020; const byte RED = 2; byte b1 = 250; diff --git a/src/test/kc/number-ternary-fail.kc b/src/test/kc/number-ternary-fail.kc index efa118d73..af0869735 100644 --- a/src/test/kc/number-ternary-fail.kc +++ b/src/test/kc/number-ternary-fail.kc @@ -1,7 +1,7 @@ // Failing number type resolving in ternary operator // Currently fails in the ternary operator with number-issues if integer literal is not specified! -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { for( byte i: 0..40) { SCREEN[i] = (i&1)?0:0x80; diff --git a/src/test/kc/number-type.kc b/src/test/kc/number-type.kc index 74f270661..c4e13e5c3 100644 --- a/src/test/kc/number-type.kc +++ b/src/test/kc/number-type.kc @@ -8,7 +8,7 @@ void main() { void testBytes() { // Constant values resolvable to bytes - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; byte idx = 0; SCREEN[idx++] = 12; SCREEN[idx++] = 6+6; @@ -27,7 +27,7 @@ void testBytes() { void testSBytes() { // Constant values resolvable to signed bytes - const signed byte* SCREEN = 0x0428; + signed byte* const SCREEN = 0x0428; byte idx = 0; SCREEN[idx++] = -12; SCREEN[idx++] = -6-6; diff --git a/src/test/kc/operator-lohi-problem-1.kc b/src/test/kc/operator-lohi-problem-1.kc index b38a21a4d..fc5292c04 100644 --- a/src/test/kc/operator-lohi-problem-1.kc +++ b/src/test/kc/operator-lohi-problem-1.kc @@ -5,7 +5,7 @@ // - enabling the lo/hi to know that their operand is a word (from the cast). const dword DVAL = $20000; -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { SCREEN[0] = <(word)(DVAL/$400); diff --git a/src/test/kc/operator-lohi-problem.kc b/src/test/kc/operator-lohi-problem.kc index 49da0ca32..f45e84736 100644 --- a/src/test/kc/operator-lohi-problem.kc +++ b/src/test/kc/operator-lohi-problem.kc @@ -4,7 +4,7 @@ // A fix could be adding support for "declared" types for constant literal values // - enabling the lo/hi to know that their operand is a word (from the cast). -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { dword dw = $2000; diff --git a/src/test/kc/optimize-unsigned-comparisons.kc b/src/test/kc/optimize-unsigned-comparisons.kc index 6286bb466..799325893 100644 --- a/src/test/kc/optimize-unsigned-comparisons.kc +++ b/src/test/kc/optimize-unsigned-comparisons.kc @@ -4,7 +4,7 @@ byte ball_active[8] = { 0, 1, 0, 1, 0, 1, 1, 1 }; void main() { - const byte* screen = 0x0400; + byte* const screen = 0x0400; byte temp; for( char i: 0..7) { // Always false diff --git a/src/test/kc/parse-negated-struct-ref.kc b/src/test/kc/parse-negated-struct-ref.kc index f0bff04f0..e3f3cb66a 100644 --- a/src/test/kc/parse-negated-struct-ref.kc +++ b/src/test/kc/parse-negated-struct-ref.kc @@ -8,7 +8,7 @@ struct A { struct A aa = { 1 }; void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; struct A* a = &aa; // A negated struct reference! if(!a->b) { diff --git a/src/test/kc/plasma-center.kc b/src/test/kc/plasma-center.kc index 78e81f9d5..169666260 100644 --- a/src/test/kc/plasma-center.kc +++ b/src/test/kc/plasma-center.kc @@ -19,11 +19,11 @@ byte* SCREEN_DIST = malloc(1000); // Screen containing angle to center byte* SCREEN_ANGLE = malloc(1000); // Plasma charset -const char* CHARSET = 0x2000; +char* const CHARSET = 0x2000; // Plasma screen 1 -const char* SCREEN1 = 0x2800; +char* const SCREEN1 = 0x2800; // Plasma screen 2 -const char* SCREEN2 = 0x2c00; +char* const SCREEN2 = 0x2c00; void main() { init_dist_screen(SCREEN_DIST); diff --git a/src/test/kc/pointer-cast-2.kc b/src/test/kc/pointer-cast-2.kc index 0a90d1c36..7c1d1c16a 100644 --- a/src/test/kc/pointer-cast-2.kc +++ b/src/test/kc/pointer-cast-2.kc @@ -2,7 +2,7 @@ void main() { { - const byte* ub_screen = $400; + byte* const ub_screen = $400; byte ub = 0xff; signed byte* sb_ptr = (signed byte*) &ub; *sb_ptr = 1; @@ -10,7 +10,7 @@ void main() { } { - const signed byte* sb_screen = $428; + signed byte* const sb_screen = $428; signed byte sb = (signed byte)0x7f; byte* ub_ptr = (byte*) &sb; *ub_ptr = 1; diff --git a/src/test/kc/pointer-cast-3.kc b/src/test/kc/pointer-cast-3.kc index 9b2e1a40c..0582b436b 100644 --- a/src/test/kc/pointer-cast-3.kc +++ b/src/test/kc/pointer-cast-3.kc @@ -1,7 +1,7 @@ // Tests casting pointer types to other pointer types void main() { - const signed byte* sb_screen = $400; + signed byte* const sb_screen = $400; signed byte sb = (signed byte)0xff; *sb_screen = sb; } \ No newline at end of file diff --git a/src/test/kc/pointer-const-deep.kc b/src/test/kc/pointer-const-deep.kc new file mode 100644 index 000000000..e3c74912c --- /dev/null +++ b/src/test/kc/pointer-const-deep.kc @@ -0,0 +1,7 @@ +// Test error on deep const pointer + +// Deep const pointer +const char * * BASIC = 0xa004; + +void main() { +} \ No newline at end of file diff --git a/src/test/kc/pointer-const-typedef.kc b/src/test/kc/pointer-const-typedef.kc new file mode 100644 index 000000000..c0b1914af --- /dev/null +++ b/src/test/kc/pointer-const-typedef.kc @@ -0,0 +1,43 @@ +// Test pointer to const and const pointer combined with typedef + +// Const char typedef +typedef const char CC; + +// Pointer typedef +typedef char * P; + +// Pointer to const typedef +typedef char * const PC; + +// Const pointer typedef +typedef char * const CP; + +// Pointer to const +char * const pc0 = 0x0400; +CC *pc1 = 0x0400; +PC pc2 = 0x0400; + +// Const pointer +char * const cp0 = 0x0400; +CP cp1 = 0x0400; +const P cp2 = 0x0400; + +// Const pointer to const +char * const const cpc0 = 0x0400; +CC * const cpc1 = 0x0400; +const PC cpc2 = 0x0400; + +char* SCREEN = 0x0400; + +void main() { + char idx = 0; + SCREEN[idx++] = *pc0; + SCREEN[idx++] = *pc1; + SCREEN[idx++] = *pc2; + SCREEN[idx++] = *cp0; + SCREEN[idx++] = *cp1; + SCREEN[idx++] = *cp2; + SCREEN[idx++] = *cpc0; + SCREEN[idx++] = *cpc1; + SCREEN[idx++] = *cpc2; +} \ No newline at end of file diff --git a/src/test/kc/pointer-const.kc b/src/test/kc/pointer-const.kc new file mode 100644 index 000000000..f266ae7fb --- /dev/null +++ b/src/test/kc/pointer-const.kc @@ -0,0 +1,23 @@ +// Test pointer to const and const pointer + +// Pointer to const +char const * MSG = "hello world!"; + +// Const pointer +char * const SCREEN = 0x0400; + +// Const pointer to const +char const * const BASIC = 0xa004; + +void main() { + char i=0; + while(MSG[i]) { + SCREEN[i] = MSG[i]; + i++; + } + i=0; + while(BASIC[i]!='0') { + SCREEN[40+i] = BASIC[i]&0x3f; + i++; + } +} \ No newline at end of file diff --git a/src/test/kc/pointer-plus-0.kc b/src/test/kc/pointer-plus-0.kc index c5b3f5d66..cd1e2fd68 100644 --- a/src/test/kc/pointer-plus-0.kc +++ b/src/test/kc/pointer-plus-0.kc @@ -4,7 +4,7 @@ byte msg1[] = "hello world!"; byte msg2[] = "goodbye sky?"; void main() { - const byte* SCREEN = $0400; + byte* const SCREEN = $0400; SCREEN[0] = *(first(msg1)+0); SCREEN[1] = *(first(msg2)+0); } diff --git a/src/test/kc/pointer-pointer-1.kc b/src/test/kc/pointer-pointer-1.kc index e260f3902..896892bc8 100644 --- a/src/test/kc/pointer-pointer-1.kc +++ b/src/test/kc/pointer-pointer-1.kc @@ -1,7 +1,7 @@ // Tests a simple pointer to a pointer void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; byte b = 'a'; byte* pb = &b; diff --git a/src/test/kc/pointer-void-0.kc b/src/test/kc/pointer-void-0.kc index 89b7c4e1d..c4c101686 100644 --- a/src/test/kc/pointer-void-0.kc +++ b/src/test/kc/pointer-void-0.kc @@ -1,7 +1,7 @@ // Test simple void pointer (conversion without casting) void main() { - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; word w = 1234; word* wp = &w; void* vp = wp; diff --git a/src/test/kc/pointer-void-1.kc b/src/test/kc/pointer-void-1.kc index 50780286f..ace9554a6 100644 --- a/src/test/kc/pointer-void-1.kc +++ b/src/test/kc/pointer-void-1.kc @@ -12,7 +12,7 @@ void main() { print(vd); } -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; byte idx = 0; void print(void* ptr) { diff --git a/src/test/kc/pointer-void-2.kc b/src/test/kc/pointer-void-2.kc index 0e7cd0928..ed9c95bc0 100644 --- a/src/test/kc/pointer-void-2.kc +++ b/src/test/kc/pointer-void-2.kc @@ -9,7 +9,7 @@ void main() { print(&d); } -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; byte idx = 0; void print(void* ptr) { diff --git a/src/test/kc/pointer-void-3.kc b/src/test/kc/pointer-void-3.kc index 5f372ef25..b9660c91c 100644 --- a/src/test/kc/pointer-void-3.kc +++ b/src/test/kc/pointer-void-3.kc @@ -1,7 +1,7 @@ // Test void pointer - issues when assigning returns from malloc() -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { byte* buf1 = malloc(); diff --git a/src/test/kc/problem-array-struct-init.kc b/src/test/kc/problem-array-struct-init.kc index 60d2213c0..50e204245 100644 --- a/src/test/kc/problem-array-struct-init.kc +++ b/src/test/kc/problem-array-struct-init.kc @@ -25,7 +25,7 @@ struct List[] lists = { { 1, { 2, 3, 4 }}, { 5, { 6, 7, 8 }}, { 9, { 10, 11, 12 */ void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; char idx = 0; for ( char i: 0..2) { SCREEN[idx++] = points[i].x; diff --git a/src/test/kc/problem-inline-struct-return.kc b/src/test/kc/problem-inline-struct-return.kc index 0132cbfc1..fd3e2442d 100644 --- a/src/test/kc/problem-inline-struct-return.kc +++ b/src/test/kc/problem-inline-struct-return.kc @@ -9,7 +9,7 @@ void main() { struct SplineVector p1 = { 12, 24}; struct SplineVector p2 = splineDouble(p1); - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; SCREEN[0] = p2.x; SCREEN[1] = p2.y; diff --git a/src/test/kc/procedure-callingconvention-stack-0.kc b/src/test/kc/procedure-callingconvention-stack-0.kc index 9387ca647..6f79c6e6b 100644 --- a/src/test/kc/procedure-callingconvention-stack-0.kc +++ b/src/test/kc/procedure-callingconvention-stack-0.kc @@ -1,6 +1,6 @@ // Test a procedure with calling convention stack -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main(void) { SCREEN[0] = plus('0', 7); diff --git a/src/test/kc/procedure-callingconvention-stack-1.kc b/src/test/kc/procedure-callingconvention-stack-1.kc index 9eaab9292..0c8e06d2c 100644 --- a/src/test/kc/procedure-callingconvention-stack-1.kc +++ b/src/test/kc/procedure-callingconvention-stack-1.kc @@ -1,6 +1,6 @@ // Test a procedure with calling convention stack -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main(void) { SCREEN[0] = plus('0', 7); diff --git a/src/test/kc/procedure-callingconvention-stack-10.kc b/src/test/kc/procedure-callingconvention-stack-10.kc index d2ff78ed0..e35f868a4 100644 --- a/src/test/kc/procedure-callingconvention-stack-10.kc +++ b/src/test/kc/procedure-callingconvention-stack-10.kc @@ -3,7 +3,7 @@ #pragma calling(__stackcall) -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; struct Point { diff --git a/src/test/kc/procedure-callingconvention-stack-11.kc b/src/test/kc/procedure-callingconvention-stack-11.kc index 276582bcf..1f3696836 100644 --- a/src/test/kc/procedure-callingconvention-stack-11.kc +++ b/src/test/kc/procedure-callingconvention-stack-11.kc @@ -3,7 +3,7 @@ #pragma calling(__stackcall) -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; struct Point { diff --git a/src/test/kc/procedure-callingconvention-stack-12.kc b/src/test/kc/procedure-callingconvention-stack-12.kc index ae4e564d5..899af7210 100644 --- a/src/test/kc/procedure-callingconvention-stack-12.kc +++ b/src/test/kc/procedure-callingconvention-stack-12.kc @@ -3,7 +3,7 @@ #pragma calling(__stackcall) -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void main(void) { diff --git a/src/test/kc/procedure-callingconvention-stack-2.kc b/src/test/kc/procedure-callingconvention-stack-2.kc index 5003c879f..c7010a445 100644 --- a/src/test/kc/procedure-callingconvention-stack-2.kc +++ b/src/test/kc/procedure-callingconvention-stack-2.kc @@ -1,6 +1,6 @@ // Test a procedure with calling convention stack - and enough parameters to use fast ASM for cleaning stack -const word* SCREEN = 0x0400; +word* const SCREEN = 0x0400; void main(void) { SCREEN[0] = plus(0x1234, 0x2345); diff --git a/src/test/kc/procedure-callingconvention-stack-3.kc b/src/test/kc/procedure-callingconvention-stack-3.kc index b4de8df32..abdd3ac68 100644 --- a/src/test/kc/procedure-callingconvention-stack-3.kc +++ b/src/test/kc/procedure-callingconvention-stack-3.kc @@ -3,7 +3,7 @@ // Currently fails because the pushed are done based on the actual value instead of the declared parameter type // https://gitlab.com/camelot/kickc/issues/319 -const word* SCREEN = 0x0400; +word* const SCREEN = 0x0400; void main(void) { SCREEN[0] = plus('0', 7); diff --git a/src/test/kc/procedure-callingconvention-stack-4.kc b/src/test/kc/procedure-callingconvention-stack-4.kc index ee5c9cf53..e1fd9c50a 100644 --- a/src/test/kc/procedure-callingconvention-stack-4.kc +++ b/src/test/kc/procedure-callingconvention-stack-4.kc @@ -1,7 +1,7 @@ // Test a procedure with calling convention stack // A slightly more complex call -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char i = 0; diff --git a/src/test/kc/procedure-callingconvention-stack-5.kc b/src/test/kc/procedure-callingconvention-stack-5.kc index e8e960934..52be53538 100644 --- a/src/test/kc/procedure-callingconvention-stack-5.kc +++ b/src/test/kc/procedure-callingconvention-stack-5.kc @@ -1,7 +1,7 @@ // Test a procedure with calling convention stack // Return value larger than parameter -const int* SCREEN = 0x0400; +int* const SCREEN = 0x0400; void main(void) { SCREEN[0] = next(); diff --git a/src/test/kc/procedure-callingconvention-stack-6.kc b/src/test/kc/procedure-callingconvention-stack-6.kc index 5d4edb94e..b9c1deea8 100644 --- a/src/test/kc/procedure-callingconvention-stack-6.kc +++ b/src/test/kc/procedure-callingconvention-stack-6.kc @@ -1,7 +1,7 @@ // Test a procedure with calling convention stack // Recursive fibonacci -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main(void) { *SCREEN = fib(5); diff --git a/src/test/kc/procedure-callingconvention-stack-7.kc b/src/test/kc/procedure-callingconvention-stack-7.kc index 1f4e0aa63..c08b731ba 100644 --- a/src/test/kc/procedure-callingconvention-stack-7.kc +++ b/src/test/kc/procedure-callingconvention-stack-7.kc @@ -3,7 +3,7 @@ #pragma calling(__stackcall) -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main(void) { char val; diff --git a/src/test/kc/procedure-callingconvention-stack-8.kc b/src/test/kc/procedure-callingconvention-stack-8.kc index beb18b357..16e2907d8 100644 --- a/src/test/kc/procedure-callingconvention-stack-8.kc +++ b/src/test/kc/procedure-callingconvention-stack-8.kc @@ -3,7 +3,7 @@ #pragma calling(__stackcall) -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char val = 0; diff --git a/src/test/kc/procedure-callingconvention-stack-9.kc b/src/test/kc/procedure-callingconvention-stack-9.kc index 368ce875c..6cf831859 100644 --- a/src/test/kc/procedure-callingconvention-stack-9.kc +++ b/src/test/kc/procedure-callingconvention-stack-9.kc @@ -3,7 +3,7 @@ #pragma calling(__stackcall) -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char val = 0; diff --git a/src/test/kc/processor-port-test.kc b/src/test/kc/processor-port-test.kc index 71e46761b..1f882d907 100644 --- a/src/test/kc/processor-port-test.kc +++ b/src/test/kc/processor-port-test.kc @@ -4,10 +4,10 @@ import "c64" import "print" -const char* BASIC_ROM = $a000; -const char* KERNAL_ROM = $e000; -const char* IO_RAM = $d000; -const char* SCREEN = 0x400; +char* const BASIC_ROM = $a000; +char* const KERNAL_ROM = $e000; +char* const IO_RAM = $d000; +char* const SCREEN = 0x400; void main() { // Avoid interrupts diff --git a/src/test/kc/register-0.kc b/src/test/kc/register-0.kc index f19e86883..b43778483 100644 --- a/src/test/kc/register-0.kc +++ b/src/test/kc/register-0.kc @@ -7,7 +7,7 @@ void main() { print('l'); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; volatile char __address(0x03) idx; diff --git a/src/test/kc/register-1.kc b/src/test/kc/register-1.kc index b77dc5738..04c4a64cf 100644 --- a/src/test/kc/register-1.kc +++ b/src/test/kc/register-1.kc @@ -2,7 +2,7 @@ // Unknown hard-coded register void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; char register(Z) idx = 3; while(idx++<7) SCREEN[idx] = 'a'; diff --git a/src/test/kc/reserve-zp-global.kc b/src/test/kc/reserve-zp-global.kc index f2f3b04f3..4660d3066 100644 --- a/src/test/kc/reserve-zp-global.kc +++ b/src/test/kc/reserve-zp-global.kc @@ -3,7 +3,7 @@ #pragma reserve(2,5) void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for( volatile byte i : 0..2) { SCREEN[i] = sub1(i); } diff --git a/src/test/kc/reserve-zp-procedure-1.kc b/src/test/kc/reserve-zp-procedure-1.kc index e02594156..c2ee8cd24 100644 --- a/src/test/kc/reserve-zp-procedure-1.kc +++ b/src/test/kc/reserve-zp-procedure-1.kc @@ -1,7 +1,7 @@ // Demonstrates a procedure reserving addresses on zeropage void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for( volatile byte i : 0..2) { SCREEN[i] = sub1(i); } diff --git a/src/test/kc/reserve-zp-procedure-2.kc b/src/test/kc/reserve-zp-procedure-2.kc index 4482904b8..0111b05d7 100644 --- a/src/test/kc/reserve-zp-procedure-2.kc +++ b/src/test/kc/reserve-zp-procedure-2.kc @@ -1,7 +1,7 @@ // Demonstrates a procedure reserving addresses on zeropage void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for( volatile byte i : 0..2) { SCREEN[i] = sub1(i); (SCREEN+40)[i] = sub2(i); diff --git a/src/test/kc/reserve-zp-procedure-3.kc b/src/test/kc/reserve-zp-procedure-3.kc index 8d5de44f8..e898644a5 100644 --- a/src/test/kc/reserve-zp-procedure-3.kc +++ b/src/test/kc/reserve-zp-procedure-3.kc @@ -1,7 +1,7 @@ // Demonstrates a procedure reserving addresses on zeropage void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for( volatile byte i : 0..2) { SCREEN[i] = sub1(i); } diff --git a/src/test/kc/sandbox-ternary-error.kc b/src/test/kc/sandbox-ternary-error.kc index 6937ececb..f66610e2d 100644 --- a/src/test/kc/sandbox-ternary-error.kc +++ b/src/test/kc/sandbox-ternary-error.kc @@ -1,7 +1,7 @@ // Demonstrates error with nested ternary operator void main(void) { - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; for ( byte b: 0..2 ) { *SCREEN = (b == 0) ? 'a' : ((b == 1) ? 'b' : 'c'); } diff --git a/src/test/kc/sandbox.kc b/src/test/kc/sandbox.kc index 7ce56d6d4..28847c566 100644 --- a/src/test/kc/sandbox.kc +++ b/src/test/kc/sandbox.kc @@ -1,10 +1,10 @@ import "division" -const byte * zp1 = 0x61; // #define zp1 *(byte *)0x61 -- allows "zp1" vs "*zp1" below -- not supported -- https://gitlab.com/camelot/kickc/issues/169 -const byte * zp2 = 0x62; -const byte * TIMEHI = 0xA1; -const byte * TIMELO = 0xA2; -const byte * VICBANK = 0xD018; +byte * const zp1 = 0x61; // #define zp1 *(byte *)0x61 -- allows "zp1" vs "*zp1" below -- not supported -- https://gitlab.com/camelot/kickc/issues/169 +byte * const zp2 = 0x62; +byte * const TIMEHI = 0xA1; +byte * const TIMELO = 0xA2; +byte * const VICBANK = 0xD018; byte buf16[16]; // "char buf16[16]" is the normal way -- not supported -- https://gitlab.com/camelot/kickc/issues/162 byte strTemp[100]; diff --git a/src/test/kc/scan-desire-problem.kc b/src/test/kc/scan-desire-problem.kc index fc22c68f6..821c3ee7f 100644 --- a/src/test/kc/scan-desire-problem.kc +++ b/src/test/kc/scan-desire-problem.kc @@ -4,11 +4,11 @@ import "keyboard.kc" import "string.kc" import "multiply.kc" -const byte* screen = $400; -const byte* charset = $2000; -const byte* tileset = $2800; -const byte* colors = $d800; -const byte* level_address = $3000; +byte* const screen = $400; +byte* const charset = $2000; +byte* const tileset = $2800; +byte* const colors = $d800; +byte* const level_address = $3000; void main() { init(); diff --git a/src/test/kc/screen-center-angle.kc b/src/test/kc/screen-center-angle.kc index 6c911db1f..759d000ad 100644 --- a/src/test/kc/screen-center-angle.kc +++ b/src/test/kc/screen-center-angle.kc @@ -7,8 +7,8 @@ import "atan2" import "time" import "print" -const byte* CHARSET = 0x2000; -const byte* SCREEN = 0x2800; +byte* const CHARSET = 0x2000; +byte* const SCREEN = 0x2800; void main() { init_font_hex(CHARSET); diff --git a/src/test/kc/screen-center-distance.kc b/src/test/kc/screen-center-distance.kc index a5ec64060..7cc4a7350 100644 --- a/src/test/kc/screen-center-distance.kc +++ b/src/test/kc/screen-center-distance.kc @@ -9,8 +9,8 @@ import "print" #pragma reserve(08) -const byte* CHARSET = 0x2000; -const byte* SCREEN = 0x2800; +byte* const CHARSET = 0x2000; +byte* const SCREEN = 0x2800; void main() { init_font_hex(CHARSET); diff --git a/src/test/kc/screen-show-spiral-buckets.kc b/src/test/kc/screen-show-spiral-buckets.kc index 8bb7a75e0..0506b71ae 100644 --- a/src/test/kc/screen-show-spiral-buckets.kc +++ b/src/test/kc/screen-show-spiral-buckets.kc @@ -11,7 +11,7 @@ byte* SCREEN_DIST = malloc(1000); // Screen containing angle to center byte* SCREEN_ANGLE= malloc(1000); // Screen containing angle to center -const byte* SCREEN_FILL = 0x0400; +byte* const SCREEN_FILL = 0x0400; // Char to fill with const byte FILL_CHAR = '*'; diff --git a/src/test/kc/screen-show-spiral.kc b/src/test/kc/screen-show-spiral.kc index 90cfcce04..3a9188554 100644 --- a/src/test/kc/screen-show-spiral.kc +++ b/src/test/kc/screen-show-spiral.kc @@ -10,7 +10,7 @@ byte* SCREEN_DIST = malloc(1000); // Screen containing angle to center byte* SCREEN_ANGLE = malloc(1000); // Screen containing angle to center -const byte* SCREEN_FILL = 0x0400; +byte* const SCREEN_FILL = 0x0400; // Char to fill with const byte FILL_CHAR = '@'; diff --git a/src/test/kc/sequence-locality-0.kc b/src/test/kc/sequence-locality-0.kc index 0b4a23de6..11de6f470 100644 --- a/src/test/kc/sequence-locality-0.kc +++ b/src/test/kc/sequence-locality-0.kc @@ -2,7 +2,7 @@ void main() { - const byte* screen = 0x0400; + byte* const screen = 0x0400; byte idx = 0; for(byte i: 0..10) { diff --git a/src/test/kc/sequence-locality-1.kc b/src/test/kc/sequence-locality-1.kc index 1692fd8a0..8d850ffcd 100644 --- a/src/test/kc/sequence-locality-1.kc +++ b/src/test/kc/sequence-locality-1.kc @@ -2,7 +2,7 @@ void main() { - const byte* screen = 0x0400; + byte* const screen = 0x0400; byte idx = 0; for(byte i: 0..10) { diff --git a/src/test/kc/sid.kc b/src/test/kc/sid.kc index 6713cd2fc..96f176bf5 100644 --- a/src/test/kc/sid.kc +++ b/src/test/kc/sid.kc @@ -1,8 +1,8 @@ // SID registers for random number generation -const word* SID_VOICE3_FREQ = $d40e; -const byte* SID_VOICE3_FREQ_LOW = $d40e; -const byte* SID_VOICE3_FREQ_HIGH = $d40f; -const byte* SID_VOICE3_CONTROL = $d412; +word* const SID_VOICE3_FREQ = $d40e; +byte* const SID_VOICE3_FREQ_LOW = $d40e; +byte* const SID_VOICE3_FREQ_HIGH = $d40f; +byte* const SID_VOICE3_CONTROL = $d412; const byte SID_CONTROL_NOISE = $80; const byte SID_CONTROL_PULSE = $40; const byte SID_CONTROL_SAWTOOTH = $20; @@ -11,7 +11,7 @@ const byte SID_CONTROL_TEST = $08; const byte SID_CONTROL_RING = $04; const byte SID_CONTROL_SYNC = $02; const byte SID_CONTROL_GATE = $01; -const byte* SID_VOICE3_OSC = $d41b; +byte* const SID_VOICE3_OSC = $d41b; // Initialize SID voice 3 for random number generation void sid_rnd_init() { diff --git a/src/test/kc/sieve-min.kc b/src/test/kc/sieve-min.kc index 027eec790..43b266e43 100644 --- a/src/test/kc/sieve-min.kc +++ b/src/test/kc/sieve-min.kc @@ -6,7 +6,7 @@ import "c64" import "print" -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; const uint16_t COUNT = 16384; /* Up to what number? */ const uint8_t SQRT_COUNT = 128; /* Sqrt of COUNT */ uint8_t* sieve = 0x1000; diff --git a/src/test/kc/sieve.kc b/src/test/kc/sieve.kc index e17b3e9a8..2474aa7ef 100644 --- a/src/test/kc/sieve.kc +++ b/src/test/kc/sieve.kc @@ -6,7 +6,7 @@ import "c64" import "print" -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; const uint16_t COUNT = 16384; /* Up to what number? */ const uint8_t SQRT_COUNT = 128; /* Sqrt of COUNT */ diff --git a/src/test/kc/signed-words.kc b/src/test/kc/signed-words.kc index 7fd375c6a..ff4b35ccd 100644 --- a/src/test/kc/signed-words.kc +++ b/src/test/kc/signed-words.kc @@ -1,8 +1,8 @@ import "c64" -const byte* SCREEN = $0400; -const byte* SPRITES_PTR = SCREEN+$3f8; -const byte* SPRITE = $2000; +byte* const SCREEN = $0400; +byte* const SPRITES_PTR = SCREEN+$3f8; +byte* const SPRITE = $2000; void main() { init(); diff --git a/src/test/kc/simple-loop.kc b/src/test/kc/simple-loop.kc index 44546a147..127da4e0c 100644 --- a/src/test/kc/simple-loop.kc +++ b/src/test/kc/simple-loop.kc @@ -1,5 +1,5 @@ void main() { - const unsigned char* SCREEN = 0x0400; + unsigned char* const SCREEN = 0x0400; for( unsigned char i = 0; i<128; i+=2) { SCREEN[i] = 'a'; (*(unsigned char*)0xD020)=0; diff --git a/src/test/kc/sinus-basic.kc b/src/test/kc/sinus-basic.kc index 8de6084e8..7b6eb463f 100644 --- a/src/test/kc/sinus-basic.kc +++ b/src/test/kc/sinus-basic.kc @@ -4,7 +4,7 @@ import "basic-floats" void main() { byte f_i[] = {0, 0, 0, 0, 0}; byte f_127[] = {0, 0, 0, 0, 0}; - const byte* f_2pi = $e2e5; + byte* const f_2pi = $e2e5; setFAC(1275); divFACby10(); setMEMtoFAC(f_127); diff --git a/src/test/kc/sizeof-arrays.kc b/src/test/kc/sizeof-arrays.kc index 19fedaf8b..dc6817c0b 100644 --- a/src/test/kc/sizeof-arrays.kc +++ b/src/test/kc/sizeof-arrays.kc @@ -1,6 +1,6 @@ // Tests the sizeof() operator on arrays -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { byte idx = 0; diff --git a/src/test/kc/sizeof-expr.kc b/src/test/kc/sizeof-expr.kc index 9dceaf702..4e01cad47 100644 --- a/src/test/kc/sizeof-expr.kc +++ b/src/test/kc/sizeof-expr.kc @@ -1,6 +1,6 @@ // Tests the sizeof() operator on values/expressions -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { byte idx = 0; diff --git a/src/test/kc/sizeof-struct.kc b/src/test/kc/sizeof-struct.kc index 74eae0c46..fb4169831 100644 --- a/src/test/kc/sizeof-struct.kc +++ b/src/test/kc/sizeof-struct.kc @@ -10,7 +10,7 @@ struct Circle { byte radius; }; -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { byte idx = 0; diff --git a/src/test/kc/sizeof-types.kc b/src/test/kc/sizeof-types.kc index 0837af0d8..29876fd0e 100644 --- a/src/test/kc/sizeof-types.kc +++ b/src/test/kc/sizeof-types.kc @@ -1,6 +1,6 @@ // Tests the sizeof() operator on types -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { byte idx = 0; diff --git a/src/test/kc/sprite-font.kc b/src/test/kc/sprite-font.kc index fa51f2df6..a9b50eb69 100644 --- a/src/test/kc/sprite-font.kc +++ b/src/test/kc/sprite-font.kc @@ -3,11 +3,11 @@ import "c64" import "string" -const char* SCREEN = 0x0400; -const char* SPRITE = 0x2000; -const char* SPRITES = SCREEN+SPRITE_PTRS; +char* const SCREEN = 0x0400; +char* const SPRITE = 0x2000; +char* const SPRITES = SCREEN+SPRITE_PTRS; -const void* GENERATOR = 0x0900; +void* const GENERATOR = 0x0900; void main() { memset(SCREEN, ' ', 1000); diff --git a/src/test/kc/stack-relative-addressing.kc b/src/test/kc/stack-relative-addressing.kc index 9367f76b7..8c7024517 100644 --- a/src/test/kc/stack-relative-addressing.kc +++ b/src/test/kc/stack-relative-addressing.kc @@ -1,7 +1,7 @@ // Test stack-relative addressing (for passing parameters through the stack) /** The hardware stack. The offset 3 is to skip the return address and the fact that the pointer is to the next free position. */ -const char* STACK = 0x0103; +char* const STACK = 0x0103; void main() { @@ -26,7 +26,7 @@ void main() { } /** The screen. */ -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; // Peek values from the stack using stack-relative addressing void peek_stack() { diff --git a/src/test/kc/statement-sequence-1.kc b/src/test/kc/statement-sequence-1.kc index 396b7b3cf..ec91d5ef2 100644 --- a/src/test/kc/statement-sequence-1.kc +++ b/src/test/kc/statement-sequence-1.kc @@ -2,7 +2,7 @@ void main() { - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; for(byte i: 0..10) { byte c = i+5; diff --git a/src/test/kc/string-escapes-2.kc b/src/test/kc/string-escapes-2.kc index c4f710b3f..2e9feb48a 100644 --- a/src/test/kc/string-escapes-2.kc +++ b/src/test/kc/string-escapes-2.kc @@ -4,7 +4,7 @@ char MESSAGE[] = "hello\nworld\\"; -const char* memA = 0xff; +char* const memA = 0xff; void main() { byte i=0; diff --git a/src/test/kc/struct-0.kc b/src/test/kc/struct-0.kc index fd81f7594..106e0fae5 100644 --- a/src/test/kc/struct-0.kc +++ b/src/test/kc/struct-0.kc @@ -8,7 +8,7 @@ struct Point { void main() { point.x = 2; point.y = 3; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = point.x; SCREEN[1] = point.y; } \ No newline at end of file diff --git a/src/test/kc/struct-1.kc b/src/test/kc/struct-1.kc index ddbd4a942..2ead695dd 100644 --- a/src/test/kc/struct-1.kc +++ b/src/test/kc/struct-1.kc @@ -12,7 +12,7 @@ void main() { point1.y = 3; point2.x = point1.y; point2.y = point1.x; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = point2.x; SCREEN[1] = point2.y; } \ No newline at end of file diff --git a/src/test/kc/struct-10.kc b/src/test/kc/struct-10.kc index 6bd11e9a7..9c89850ef 100644 --- a/src/test/kc/struct-10.kc +++ b/src/test/kc/struct-10.kc @@ -7,7 +7,7 @@ struct RadixInfo { }; void main() { - const unsigned int* SCREEN = 0x400; + unsigned int* const SCREEN = 0x400; struct RadixInfo info = { RADIX_DECIMAL_VALUES }; SCREEN[0] = info.values[1]; SCREEN[1] = RADIX_DECIMAL_VALUES[1]; diff --git a/src/test/kc/struct-11.kc b/src/test/kc/struct-11.kc index 6959b525f..f5262f6e9 100644 --- a/src/test/kc/struct-11.kc +++ b/src/test/kc/struct-11.kc @@ -13,7 +13,7 @@ void main() { print_person(henriette); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; char DIGIT[] = "0123456789"; diff --git a/src/test/kc/struct-11b.kc b/src/test/kc/struct-11b.kc index 36cb5510a..7be88e6a8 100644 --- a/src/test/kc/struct-11b.kc +++ b/src/test/kc/struct-11b.kc @@ -11,7 +11,7 @@ void main() { print_person(henry_id, henry_initials); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void print_person(unsigned long person_id, char* person_initials) { diff --git a/src/test/kc/struct-12.kc b/src/test/kc/struct-12.kc index 31bb88848..95fcbcd75 100644 --- a/src/test/kc/struct-12.kc +++ b/src/test/kc/struct-12.kc @@ -14,7 +14,7 @@ void main() { print_person(henriette); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; char DIGIT[] = "0123456789"; diff --git a/src/test/kc/struct-13.kc b/src/test/kc/struct-13.kc index becdabb41..cd2903a95 100644 --- a/src/test/kc/struct-13.kc +++ b/src/test/kc/struct-13.kc @@ -7,7 +7,7 @@ struct Point { __ma struct Point point; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { point.x = 2; diff --git a/src/test/kc/struct-14.kc b/src/test/kc/struct-14.kc index 260e83f6d..f7f212ef4 100644 --- a/src/test/kc/struct-14.kc +++ b/src/test/kc/struct-14.kc @@ -7,7 +7,7 @@ struct Point { struct Point points[1]; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { points[0].x = 2; diff --git a/src/test/kc/struct-15.kc b/src/test/kc/struct-15.kc index 4ae663cf9..9840b2095 100644 --- a/src/test/kc/struct-15.kc +++ b/src/test/kc/struct-15.kc @@ -5,7 +5,7 @@ struct Point { char y; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1; diff --git a/src/test/kc/struct-16.kc b/src/test/kc/struct-16.kc index 14a7a2703..74503d733 100644 --- a/src/test/kc/struct-16.kc +++ b/src/test/kc/struct-16.kc @@ -5,7 +5,7 @@ struct Point { char y; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1 = { 2, 3 }; diff --git a/src/test/kc/struct-17.kc b/src/test/kc/struct-17.kc index ed44b96cd..8d71759e8 100644 --- a/src/test/kc/struct-17.kc +++ b/src/test/kc/struct-17.kc @@ -10,7 +10,7 @@ struct Vector { struct Point q; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Vector v; diff --git a/src/test/kc/struct-18.kc b/src/test/kc/struct-18.kc index 5f34a9939..d2ff79089 100644 --- a/src/test/kc/struct-18.kc +++ b/src/test/kc/struct-18.kc @@ -10,7 +10,7 @@ struct Vector { struct Point q; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Vector v = { {2, 3}, {4, 5} }; diff --git a/src/test/kc/struct-19.kc b/src/test/kc/struct-19.kc index 77e11cca1..1571a84c5 100644 --- a/src/test/kc/struct-19.kc +++ b/src/test/kc/struct-19.kc @@ -10,7 +10,7 @@ struct Vector { struct Point q; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Vector v; diff --git a/src/test/kc/struct-2.kc b/src/test/kc/struct-2.kc index dea677f60..56c32a7c2 100644 --- a/src/test/kc/struct-2.kc +++ b/src/test/kc/struct-2.kc @@ -12,7 +12,7 @@ void main() { point1.y = 3; point2 = point1; point2.x = 4; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = point1.x; SCREEN[1] = point1.y; SCREEN[2] = point2.x; diff --git a/src/test/kc/struct-20.kc b/src/test/kc/struct-20.kc index c370eb6c2..5c8580300 100644 --- a/src/test/kc/struct-20.kc +++ b/src/test/kc/struct-20.kc @@ -10,7 +10,7 @@ struct Vector { struct Point q; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point p1 = { 2, 3 }; diff --git a/src/test/kc/struct-21.kc b/src/test/kc/struct-21.kc index bc3908aa5..2bbede226 100644 --- a/src/test/kc/struct-21.kc +++ b/src/test/kc/struct-21.kc @@ -5,7 +5,7 @@ struct Point { char y; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1 = { 2, 3 }; diff --git a/src/test/kc/struct-22.kc b/src/test/kc/struct-22.kc index 7d32a3064..d8fb6a077 100644 --- a/src/test/kc/struct-22.kc +++ b/src/test/kc/struct-22.kc @@ -12,7 +12,7 @@ void main() { print(point2); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void print(struct Point p) { SCREEN[0] = p.x; diff --git a/src/test/kc/struct-23.kc b/src/test/kc/struct-23.kc index f074d43f6..fc0b9ea59 100644 --- a/src/test/kc/struct-23.kc +++ b/src/test/kc/struct-23.kc @@ -5,7 +5,7 @@ struct Point { char y; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1 = getPoint(2, 3); diff --git a/src/test/kc/struct-24.kc b/src/test/kc/struct-24.kc index fe7ac54ac..4f4af654d 100644 --- a/src/test/kc/struct-24.kc +++ b/src/test/kc/struct-24.kc @@ -5,7 +5,7 @@ struct Point { char initials[2]; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1; diff --git a/src/test/kc/struct-25.kc b/src/test/kc/struct-25.kc index 9d40c4400..68e821e61 100644 --- a/src/test/kc/struct-25.kc +++ b/src/test/kc/struct-25.kc @@ -5,7 +5,7 @@ struct Point { char initials[2]; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { SCREEN[0] = sizeof(struct Point); diff --git a/src/test/kc/struct-26.kc b/src/test/kc/struct-26.kc index b0d32cc10..ad52934f6 100644 --- a/src/test/kc/struct-26.kc +++ b/src/test/kc/struct-26.kc @@ -5,7 +5,7 @@ struct Point { char initials[2]; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1; diff --git a/src/test/kc/struct-27.kc b/src/test/kc/struct-27.kc index c4a534be5..63d399e0b 100644 --- a/src/test/kc/struct-27.kc +++ b/src/test/kc/struct-27.kc @@ -5,7 +5,7 @@ struct Point { char initials[3]; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1 = { 2, "jg" }; diff --git a/src/test/kc/struct-28.kc b/src/test/kc/struct-28.kc index f8e4c2609..f0c9445b9 100644 --- a/src/test/kc/struct-28.kc +++ b/src/test/kc/struct-28.kc @@ -5,7 +5,7 @@ struct Point { char initials[2]; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1 = { 2, { 'j', 'g' } }; diff --git a/src/test/kc/struct-29.kc b/src/test/kc/struct-29.kc index dcf7a9a42..c3d8f4450 100644 --- a/src/test/kc/struct-29.kc +++ b/src/test/kc/struct-29.kc @@ -7,7 +7,7 @@ struct Point { __mem __ma struct Point point1 = { 2, { 'j', 'g' } }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { SCREEN[0] = point1.x; diff --git a/src/test/kc/struct-3.kc b/src/test/kc/struct-3.kc index 7402d74c8..9b0b62da9 100644 --- a/src/test/kc/struct-3.kc +++ b/src/test/kc/struct-3.kc @@ -14,7 +14,7 @@ void main() { print(p1); } -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; byte idx = 0; void print(struct Point p) { diff --git a/src/test/kc/struct-30.kc b/src/test/kc/struct-30.kc index fe4b261b2..40076158b 100644 --- a/src/test/kc/struct-30.kc +++ b/src/test/kc/struct-30.kc @@ -5,7 +5,7 @@ struct Point { char initials[3]; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { diff --git a/src/test/kc/struct-31.kc b/src/test/kc/struct-31.kc index 753b78a70..518f804bc 100644 --- a/src/test/kc/struct-31.kc +++ b/src/test/kc/struct-31.kc @@ -5,7 +5,7 @@ struct Point { char y; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { diff --git a/src/test/kc/struct-32.kc b/src/test/kc/struct-32.kc index df0883eec..4440378c8 100644 --- a/src/test/kc/struct-32.kc +++ b/src/test/kc/struct-32.kc @@ -5,7 +5,7 @@ struct Point { char y; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { __ma struct Point point1; diff --git a/src/test/kc/struct-33.kc b/src/test/kc/struct-33.kc index 0ac0f91b5..1d9415927 100644 --- a/src/test/kc/struct-33.kc +++ b/src/test/kc/struct-33.kc @@ -7,7 +7,7 @@ struct Point { __mem __ma struct Point point; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { point.x = 2; diff --git a/src/test/kc/struct-34.kc b/src/test/kc/struct-34.kc index 03591245b..31406adf8 100644 --- a/src/test/kc/struct-34.kc +++ b/src/test/kc/struct-34.kc @@ -7,7 +7,7 @@ struct Point { __mem __ssa struct Point point; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { point.x = 2; diff --git a/src/test/kc/struct-35.kc b/src/test/kc/struct-35.kc index 1692a0ce0..d1c5c3065 100644 --- a/src/test/kc/struct-35.kc +++ b/src/test/kc/struct-35.kc @@ -8,7 +8,7 @@ struct Point { __mem __ma struct Point point1 = { 2, 3 }; __mem __ma struct Point point2; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { struct Point* p2 = &point2; diff --git a/src/test/kc/struct-36.kc b/src/test/kc/struct-36.kc index c4974ff16..7a3016348 100644 --- a/src/test/kc/struct-36.kc +++ b/src/test/kc/struct-36.kc @@ -7,7 +7,7 @@ struct Point { __mem __ma struct Point point1 = { 2, "jg" }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { SCREEN[0] = point1.x; diff --git a/src/test/kc/struct-37.kc b/src/test/kc/struct-37.kc index af39b0f23..e90ff3b0a 100644 --- a/src/test/kc/struct-37.kc +++ b/src/test/kc/struct-37.kc @@ -20,7 +20,7 @@ struct Segment letter_c[] = { { SPLINE_TO, {'e','f'}, {75,195} } }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { char j=0; diff --git a/src/test/kc/struct-38.kc b/src/test/kc/struct-38.kc index 96f6094f9..460a4a84b 100644 --- a/src/test/kc/struct-38.kc +++ b/src/test/kc/struct-38.kc @@ -20,7 +20,7 @@ struct Segment letter_c[] = { { SPLINE_TO, {'e','f'}, {75,195} } }; -const signed int* SCREEN = 0x0400; +signed int* const SCREEN = 0x0400; void main() { char j=0; diff --git a/src/test/kc/struct-39.kc b/src/test/kc/struct-39.kc index 7427f20ad..8e5942301 100644 --- a/src/test/kc/struct-39.kc +++ b/src/test/kc/struct-39.kc @@ -20,7 +20,7 @@ struct Segment letter_c[] = { { SPLINE_TO, {'e','f'}, {75,195} } }; -const signed int* SCREEN = 0x0400; +signed int* const SCREEN = 0x0400; void main() { char j=0; diff --git a/src/test/kc/struct-4.kc b/src/test/kc/struct-4.kc index 8d9619535..e03df3e02 100644 --- a/src/test/kc/struct-4.kc +++ b/src/test/kc/struct-4.kc @@ -11,7 +11,7 @@ void main() { byte y = 3; struct Point p = { x, y+1 }; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = p.x; SCREEN[1] = p.y; } diff --git a/src/test/kc/struct-40.kc b/src/test/kc/struct-40.kc index 8cb64a71a..69ca411bc 100644 --- a/src/test/kc/struct-40.kc +++ b/src/test/kc/struct-40.kc @@ -10,7 +10,7 @@ struct Vector { struct Point q; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { char idx = 0; diff --git a/src/test/kc/struct-41.kc b/src/test/kc/struct-41.kc index 4551d302c..182547696 100644 --- a/src/test/kc/struct-41.kc +++ b/src/test/kc/struct-41.kc @@ -10,7 +10,7 @@ struct Vector { struct Point q; }; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { char idx = 0; diff --git a/src/test/kc/struct-42.kc b/src/test/kc/struct-42.kc index 0bbff0638..9aa043b5e 100644 --- a/src/test/kc/struct-42.kc +++ b/src/test/kc/struct-42.kc @@ -7,7 +7,7 @@ struct Point { struct Point points[3]; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { for( char i: 0..2) diff --git a/src/test/kc/struct-5.kc b/src/test/kc/struct-5.kc index b26af0be8..24dee25cb 100644 --- a/src/test/kc/struct-5.kc +++ b/src/test/kc/struct-5.kc @@ -9,7 +9,7 @@ void main() { struct Point q; q = point(); - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = q.x; SCREEN[1] = q.y; } diff --git a/src/test/kc/struct-6.kc b/src/test/kc/struct-6.kc index cc41b3282..d3911d397 100644 --- a/src/test/kc/struct-6.kc +++ b/src/test/kc/struct-6.kc @@ -13,7 +13,7 @@ struct Circle { void main() { struct Point p = { 10, 10 }; struct Circle c = { p, 5 }; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = c.center.x; SCREEN[1] = c.center.y; SCREEN[2] = c.radius; diff --git a/src/test/kc/struct-7.kc b/src/test/kc/struct-7.kc index 09ea8aa02..06df23d0c 100644 --- a/src/test/kc/struct-7.kc +++ b/src/test/kc/struct-7.kc @@ -18,7 +18,7 @@ struct TwoCircles { void main() { struct TwoCircles t = { { { 1, 2}, 3 }, { { 4, 5}, 6 } }; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = t.c1.center.x; SCREEN[1] = t.c1.center.y; SCREEN[2] = t.c1.radius; diff --git a/src/test/kc/struct-8.kc b/src/test/kc/struct-8.kc index b4a4a44f9..034251aa3 100644 --- a/src/test/kc/struct-8.kc +++ b/src/test/kc/struct-8.kc @@ -14,7 +14,7 @@ void main() { struct Point p = { 10, 10 }; struct Circle c = { p, 5 }; struct Point point = c.center; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = point.x; SCREEN[1] = point.y; SCREEN[1] = c.radius; diff --git a/src/test/kc/struct-9.kc b/src/test/kc/struct-9.kc index 5fae7ca0e..b65ff1320 100644 --- a/src/test/kc/struct-9.kc +++ b/src/test/kc/struct-9.kc @@ -15,7 +15,7 @@ void main() { struct Circle c; c.center = p; c.radius = 12; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = c.center.x; SCREEN[1] = c.center.y; SCREEN[2] = c.radius; diff --git a/src/test/kc/struct-err-1.kc b/src/test/kc/struct-err-1.kc index 1e1944060..72b3f03df 100644 --- a/src/test/kc/struct-err-1.kc +++ b/src/test/kc/struct-err-1.kc @@ -15,7 +15,7 @@ void main() { struct Point2 p2; p1.x = 4; p2 = p1; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = p2.x; SCREEN[0] = p2.y; diff --git a/src/test/kc/struct-err-2.kc b/src/test/kc/struct-err-2.kc index 538129894..0c7a9e393 100644 --- a/src/test/kc/struct-err-2.kc +++ b/src/test/kc/struct-err-2.kc @@ -8,7 +8,7 @@ struct Point { void main() { struct Point p1; p1 = 4; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = p1.x; } diff --git a/src/test/kc/struct-err-3.kc b/src/test/kc/struct-err-3.kc index a2ba69e92..0f9c22190 100644 --- a/src/test/kc/struct-err-3.kc +++ b/src/test/kc/struct-err-3.kc @@ -9,7 +9,7 @@ void main() { print(7); } -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void print(struct Point p) { *SCREEN = p.x; diff --git a/src/test/kc/struct-err-4.kc b/src/test/kc/struct-err-4.kc index 04c61cc9f..e95685b4c 100644 --- a/src/test/kc/struct-err-4.kc +++ b/src/test/kc/struct-err-4.kc @@ -5,7 +5,7 @@ struct Point { byte y; }; -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { struct Point p; diff --git a/src/test/kc/struct-err-5.kc b/src/test/kc/struct-err-5.kc index 09dd6f015..d1c047d6d 100644 --- a/src/test/kc/struct-err-5.kc +++ b/src/test/kc/struct-err-5.kc @@ -5,7 +5,7 @@ struct Point { byte y; }; -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { struct Point p; diff --git a/src/test/kc/struct-error-6.kc b/src/test/kc/struct-error-6.kc index 84585cd4c..ccab336e7 100644 --- a/src/test/kc/struct-error-6.kc +++ b/src/test/kc/struct-error-6.kc @@ -8,7 +8,7 @@ struct Person { void main() { struct Person* jesper = { 4, 46, 2 }; - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; SCREEN[0] = jesper->id; } diff --git a/src/test/kc/struct-ptr-0.kc b/src/test/kc/struct-ptr-0.kc index 30a4eccea..a8bdb8530 100644 --- a/src/test/kc/struct-ptr-0.kc +++ b/src/test/kc/struct-ptr-0.kc @@ -12,7 +12,7 @@ void main() { points[i].x = i; points[i].y = i+1; } - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; for( byte i: 0..4) { SCREEN[i] = points[i].x; (SCREEN+40)[i] = points[i].y; diff --git a/src/test/kc/struct-ptr-1.kc b/src/test/kc/struct-ptr-1.kc index b3bfc03c7..24c9432ad 100644 --- a/src/test/kc/struct-ptr-1.kc +++ b/src/test/kc/struct-ptr-1.kc @@ -16,7 +16,7 @@ void main() { *((byte*)points+OFFS_X+i*SIZEOF_POINT) = i; // points[i].x = i; *((byte*)points+OFFS_Y+i*SIZEOF_POINT) = i+4; // points[i].y = i+4; } - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; for( byte i: 0..3) { SCREEN[i] = *((byte*)points+OFFS_X+i*SIZEOF_POINT); // SCREEN[i] = points[i].x; (SCREEN+40)[i] = *((byte*)points+OFFS_Y+i*SIZEOF_POINT); // (SCREEN+40)[i] = points[i].y; diff --git a/src/test/kc/struct-ptr-10.kc b/src/test/kc/struct-ptr-10.kc index 05e544c1c..45397defc 100644 --- a/src/test/kc/struct-ptr-10.kc +++ b/src/test/kc/struct-ptr-10.kc @@ -11,7 +11,7 @@ void main() { for( word i: 0..499) { points[i] = { 2, (byte)i }; } - const struct Point* SCREEN = 0x0400; + struct Point* const SCREEN = 0x0400; for( word i: 0..499) { SCREEN[i] = points[i]; } diff --git a/src/test/kc/struct-ptr-11.kc b/src/test/kc/struct-ptr-11.kc index f705e39c9..55cd8b889 100644 --- a/src/test/kc/struct-ptr-11.kc +++ b/src/test/kc/struct-ptr-11.kc @@ -12,7 +12,7 @@ void main() { for( byte i: 0..3) { points[i] = { (signed byte)i, -(signed byte)i, (signed byte)i }; } - const struct Point* SCREEN = 0x0400; + struct Point* const SCREEN = 0x0400; for( byte i: 0..3) { SCREEN[i] = points[i]; } diff --git a/src/test/kc/struct-ptr-12-ref.kc b/src/test/kc/struct-ptr-12-ref.kc index 92acc3271..e7f5b642a 100644 --- a/src/test/kc/struct-ptr-12-ref.kc +++ b/src/test/kc/struct-ptr-12-ref.kc @@ -3,7 +3,7 @@ void main() { word p = { 2, 3 }; word *q = &p; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = <*q; SCREEN[1] = >*q; } \ No newline at end of file diff --git a/src/test/kc/struct-ptr-12.kc b/src/test/kc/struct-ptr-12.kc index ef48015dc..f92dc8b1b 100644 --- a/src/test/kc/struct-ptr-12.kc +++ b/src/test/kc/struct-ptr-12.kc @@ -7,7 +7,7 @@ struct Point { void main() { volatile struct Point p = { 2, 3 }; struct Point *q = &p; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = q->x; SCREEN[1] = q->y; } \ No newline at end of file diff --git a/src/test/kc/struct-ptr-13.kc b/src/test/kc/struct-ptr-13.kc index d90891736..0c2d1c3d9 100644 --- a/src/test/kc/struct-ptr-13.kc +++ b/src/test/kc/struct-ptr-13.kc @@ -11,7 +11,7 @@ void main() { points->x += 5; points->y += 5; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = points->x; SCREEN[1] = points->y; } \ No newline at end of file diff --git a/src/test/kc/struct-ptr-14.kc b/src/test/kc/struct-ptr-14.kc index 0d8e0d5cf..e8224e557 100644 --- a/src/test/kc/struct-ptr-14.kc +++ b/src/test/kc/struct-ptr-14.kc @@ -8,7 +8,7 @@ void main() { volatile struct Point p = { 2, 3 }; struct Point *q = &p; set(q); - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = q->x; SCREEN[1] = q->y; } diff --git a/src/test/kc/struct-ptr-15.kc b/src/test/kc/struct-ptr-15.kc index 502a340a1..35fc41df0 100644 --- a/src/test/kc/struct-ptr-15.kc +++ b/src/test/kc/struct-ptr-15.kc @@ -20,7 +20,7 @@ void main() { circles[1].center.y = 9; circles[1].radius = 15; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; byte idx =0; struct Circle* ptr = circles; for(byte i:0..1) { diff --git a/src/test/kc/struct-ptr-16.kc b/src/test/kc/struct-ptr-16.kc index 51087464c..95d5b1daf 100644 --- a/src/test/kc/struct-ptr-16.kc +++ b/src/test/kc/struct-ptr-16.kc @@ -5,7 +5,7 @@ struct Point { char y; }; -const struct Point* SCREEN = 0x0400; +struct Point* const SCREEN = 0x0400; char idx = 0; void main() { diff --git a/src/test/kc/struct-ptr-17.kc b/src/test/kc/struct-ptr-17.kc index 3c45cf45d..ca5272637 100644 --- a/src/test/kc/struct-ptr-17.kc +++ b/src/test/kc/struct-ptr-17.kc @@ -5,7 +5,7 @@ struct Point { char y; }; -const struct Point* SCREEN = 0x0400; +struct Point* const SCREEN = 0x0400; char idx = 0; void main() { diff --git a/src/test/kc/struct-ptr-18.kc b/src/test/kc/struct-ptr-18.kc index 484abe049..c7c069c66 100644 --- a/src/test/kc/struct-ptr-18.kc +++ b/src/test/kc/struct-ptr-18.kc @@ -1,6 +1,6 @@ // Demonstrates problem with passing struct array element as parameter to call -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; struct Point { diff --git a/src/test/kc/struct-ptr-19.kc b/src/test/kc/struct-ptr-19.kc index 4cc1287c0..a230c809e 100644 --- a/src/test/kc/struct-ptr-19.kc +++ b/src/test/kc/struct-ptr-19.kc @@ -1,6 +1,6 @@ // Demonstrates problem with passing struct pointer deref as parameter to call -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; struct Point { diff --git a/src/test/kc/struct-ptr-2.kc b/src/test/kc/struct-ptr-2.kc index bc1b0ba13..2c829bc1f 100644 --- a/src/test/kc/struct-ptr-2.kc +++ b/src/test/kc/struct-ptr-2.kc @@ -17,7 +17,7 @@ void main() { *((byte*)point_i+OFFS_X) = i; // points[i].x = i; *((byte*)point_i+OFFS_Y) = i+4; // points[i].y = i+4; } - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; for( byte i: 0..3) { struct Point* point_i = points+i; SCREEN[i] = *((byte*)point_i+OFFS_X); // SCREEN[i] = points[i].x; diff --git a/src/test/kc/struct-ptr-20.kc b/src/test/kc/struct-ptr-20.kc index bb8611bcd..7e0555c1b 100644 --- a/src/test/kc/struct-ptr-20.kc +++ b/src/test/kc/struct-ptr-20.kc @@ -1,6 +1,6 @@ // Demonstrates problem with conditions using negated struct references -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; struct Setting { char off; diff --git a/src/test/kc/struct-ptr-21.kc b/src/test/kc/struct-ptr-21.kc index ba5d03bf8..b03798e1d 100644 --- a/src/test/kc/struct-ptr-21.kc +++ b/src/test/kc/struct-ptr-21.kc @@ -1,6 +1,6 @@ // Demonstrates problem with conditions using negated struct references -const unsigned int* SCREEN = 0x0400; +unsigned int* const SCREEN = 0x0400; struct Setting { char len; diff --git a/src/test/kc/struct-ptr-23.kc b/src/test/kc/struct-ptr-23.kc index 64dca0634..d383c38e5 100644 --- a/src/test/kc/struct-ptr-23.kc +++ b/src/test/kc/struct-ptr-23.kc @@ -17,7 +17,7 @@ void main() { print_person(person); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void print_person(struct Person *person) { diff --git a/src/test/kc/struct-ptr-28.kc b/src/test/kc/struct-ptr-28.kc index f83e3fbcb..997c1a730 100644 --- a/src/test/kc/struct-ptr-28.kc +++ b/src/test/kc/struct-ptr-28.kc @@ -15,7 +15,7 @@ void main() { print_person(&henriette); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; char DIGIT[] = "0123456789"; diff --git a/src/test/kc/struct-ptr-29.kc b/src/test/kc/struct-ptr-29.kc index 12659fd81..a89212f20 100644 --- a/src/test/kc/struct-ptr-29.kc +++ b/src/test/kc/struct-ptr-29.kc @@ -15,7 +15,7 @@ void main() { print_person(&persons[1]); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; char DIGIT[] = "0123456789"; diff --git a/src/test/kc/struct-ptr-3.kc b/src/test/kc/struct-ptr-3.kc index e1f2125a4..16d7d553d 100644 --- a/src/test/kc/struct-ptr-3.kc +++ b/src/test/kc/struct-ptr-3.kc @@ -8,7 +8,7 @@ struct Point { struct Point* points = 0x1000; void main() { - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = (*points).x; SCREEN[1] = (*points).y; points++; diff --git a/src/test/kc/struct-ptr-30.kc b/src/test/kc/struct-ptr-30.kc index 960c18395..a6b55cc4f 100644 --- a/src/test/kc/struct-ptr-30.kc +++ b/src/test/kc/struct-ptr-30.kc @@ -13,7 +13,7 @@ void main() { } } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; void print(struct Point p) { diff --git a/src/test/kc/struct-ptr-31.kc b/src/test/kc/struct-ptr-31.kc index 10a99ed6f..7028ff9ee 100644 --- a/src/test/kc/struct-ptr-31.kc +++ b/src/test/kc/struct-ptr-31.kc @@ -15,7 +15,7 @@ void main() { print_person(persons+1); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; char DIGIT[] = "0123456789"; diff --git a/src/test/kc/struct-ptr-32.kc b/src/test/kc/struct-ptr-32.kc index 5fc72c138..ff7968956 100644 --- a/src/test/kc/struct-ptr-32.kc +++ b/src/test/kc/struct-ptr-32.kc @@ -15,7 +15,7 @@ void main() { persons[1].name[8] = 'b'; persons[0].age = 321; persons[1].age = 123; - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; struct Person* person = persons; SCREEN[0] = person->name[8]; person++; diff --git a/src/test/kc/struct-ptr-33.kc b/src/test/kc/struct-ptr-33.kc index 21a8483e8..c8f24a4fa 100644 --- a/src/test/kc/struct-ptr-33.kc +++ b/src/test/kc/struct-ptr-33.kc @@ -12,7 +12,7 @@ struct Person persons[2] = { }; void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; struct Person* person = persons; SCREEN[0] = person->name[2]; person++; diff --git a/src/test/kc/struct-ptr-34.kc b/src/test/kc/struct-ptr-34.kc index 4c47c8cdc..6b693d8e0 100644 --- a/src/test/kc/struct-ptr-34.kc +++ b/src/test/kc/struct-ptr-34.kc @@ -13,7 +13,7 @@ void main() { print_person(henriette); } -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char idx = 0; char DIGIT[] = "0123456789"; diff --git a/src/test/kc/struct-ptr-4.kc b/src/test/kc/struct-ptr-4.kc index dbb36c1fa..7dc129d59 100644 --- a/src/test/kc/struct-ptr-4.kc +++ b/src/test/kc/struct-ptr-4.kc @@ -17,7 +17,7 @@ void main() { } // Print points - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; byte idx = 0; points = POINTS; for( byte i: 0..3) { diff --git a/src/test/kc/struct-ptr-5.kc b/src/test/kc/struct-ptr-5.kc index db98e967c..53a30e997 100644 --- a/src/test/kc/struct-ptr-5.kc +++ b/src/test/kc/struct-ptr-5.kc @@ -21,7 +21,7 @@ void main() { entry1->value = 3; // Run through the linked list - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; byte idx = 0; struct Entry* entry = ENTRIES; diff --git a/src/test/kc/struct-ptr-6.kc b/src/test/kc/struct-ptr-6.kc index fb29c8c56..4a3ff0bdc 100644 --- a/src/test/kc/struct-ptr-6.kc +++ b/src/test/kc/struct-ptr-6.kc @@ -8,7 +8,7 @@ struct Point { struct Point* points = 0x1000; void main() { - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = points->x; SCREEN[1] = points->y; points++; diff --git a/src/test/kc/struct-ptr-7.kc b/src/test/kc/struct-ptr-7.kc index 57871efd6..c5116d682 100644 --- a/src/test/kc/struct-ptr-7.kc +++ b/src/test/kc/struct-ptr-7.kc @@ -13,7 +13,7 @@ void main() { points[1].x = 5; points[1].y = 6; - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; SCREEN[0] = points[0].x; SCREEN[1] = points[0].y; SCREEN[3] = points[1].x; diff --git a/src/test/kc/struct-ptr-8.kc b/src/test/kc/struct-ptr-8.kc index a8fe84bca..a1c180e7d 100644 --- a/src/test/kc/struct-ptr-8.kc +++ b/src/test/kc/struct-ptr-8.kc @@ -13,7 +13,7 @@ void main() { points[i].y = 3+i; } - const byte* SCREEN = 0x0400; + byte* const SCREEN = 0x0400; byte idx = 0; for( byte i: 0..1) { SCREEN[idx++] = points[i].x; diff --git a/src/test/kc/struct-ptr-9.kc b/src/test/kc/struct-ptr-9.kc index 13916928f..c146cda09 100644 --- a/src/test/kc/struct-ptr-9.kc +++ b/src/test/kc/struct-ptr-9.kc @@ -12,7 +12,7 @@ void main() { points[i] = { 2, i }; } - const struct Point* SCREEN = 0x0400; + struct Point* const SCREEN = 0x0400; for( byte i: 0..1) { SCREEN[i] = points[i]; } diff --git a/src/test/kc/switch-0.kc b/src/test/kc/switch-0.kc index eb1d44b08..1cb413fc6 100644 --- a/src/test/kc/switch-0.kc +++ b/src/test/kc/switch-0.kc @@ -2,7 +2,7 @@ // Expected output 'd1444d' void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; for(char i:0..5) { // Test switching on a simple char diff --git a/src/test/kc/switch-1.kc b/src/test/kc/switch-1.kc index 5c3760bae..50d45084c 100644 --- a/src/test/kc/switch-1.kc +++ b/src/test/kc/switch-1.kc @@ -2,7 +2,7 @@ // Expected output 'a1aa1a' (numbers should be inverted) void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; for(char i:0..5) { // Test switching on a simple char switch(i) { diff --git a/src/test/kc/switch-4.kc b/src/test/kc/switch-4.kc index 2cf9ef647..cce06cecd 100644 --- a/src/test/kc/switch-4.kc +++ b/src/test/kc/switch-4.kc @@ -2,7 +2,7 @@ // Expected output " 1 4 " void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; for(char i:0..5) { // Test switching on a simple char switch(i) { diff --git a/src/test/kc/ternary-1.kc b/src/test/kc/ternary-1.kc index 5be0cc3d0..3983f9cf8 100644 --- a/src/test/kc/ternary-1.kc +++ b/src/test/kc/ternary-1.kc @@ -1,7 +1,7 @@ // Tests the ternary operator void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for( byte i: 0..9) { SCREEN[i] = i<5?'a':'b'; } diff --git a/src/test/kc/ternary-2.kc b/src/test/kc/ternary-2.kc index 7052a2575..38d534493 100644 --- a/src/test/kc/ternary-2.kc +++ b/src/test/kc/ternary-2.kc @@ -1,7 +1,7 @@ // Tests the ternary operator - when the condition is constant void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; SCREEN[0] = true?'a':'b'; SCREEN[1] = false?'a':'b'; } diff --git a/src/test/kc/ternary-3.kc b/src/test/kc/ternary-3.kc index e46cadb5c..39ddf0301 100644 --- a/src/test/kc/ternary-3.kc +++ b/src/test/kc/ternary-3.kc @@ -1,7 +1,7 @@ // Tests the ternary operator - when the condition is constant void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; for( byte i: 0..9) { SCREEN[i] = cond(i)?m1(i):m2(i); } diff --git a/src/test/kc/ternary-4.kc b/src/test/kc/ternary-4.kc index 3857c8180..6ace4c534 100644 --- a/src/test/kc/ternary-4.kc +++ b/src/test/kc/ternary-4.kc @@ -1,7 +1,7 @@ // Tests the ternary operator - complex nested conditional operators void main() { - const char* SCREEN = $400; + char* const SCREEN = $400; char i=0; for(char b: 0..3) { for( char v: 0..3) { diff --git a/src/test/kc/ternary-inference.kc b/src/test/kc/ternary-inference.kc index 30b892c79..a84af6fba 100644 --- a/src/test/kc/ternary-inference.kc +++ b/src/test/kc/ternary-inference.kc @@ -1,7 +1,7 @@ // Type inference into the ternary operator void main() { - const byte* screen = 0x400; + byte* const screen = 0x400; for(byte i: 0..10) { screen[i] = (i<5?0x57:'0')+i; } diff --git a/src/test/kc/test-comments-block.kc b/src/test/kc/test-comments-block.kc index 353bc34f6..661c23e99 100644 --- a/src/test/kc/test-comments-block.kc +++ b/src/test/kc/test-comments-block.kc @@ -3,7 +3,7 @@ */ // The C64 screen -const byte* SCREEN = $400; +byte* const SCREEN = $400; // One of the bytes used for addition byte a = 'a'; diff --git a/src/test/kc/test-comments-loop.kc b/src/test/kc/test-comments-loop.kc index 58aabbfb0..a42e8ebd7 100644 --- a/src/test/kc/test-comments-loop.kc +++ b/src/test/kc/test-comments-loop.kc @@ -1,5 +1,5 @@ void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; // Do some sums for(byte b: 0..10 ) { SCREEN[b] = 'a'; diff --git a/src/test/kc/test-comments-single.kc b/src/test/kc/test-comments-single.kc index f740f33e5..65d5f88d3 100644 --- a/src/test/kc/test-comments-single.kc +++ b/src/test/kc/test-comments-single.kc @@ -2,7 +2,7 @@ // Has a bunch of comments that will be moved into the generated ASM // The C64 screen -const byte* SCREEN = $400; +byte* const SCREEN = $400; // One of the bytes used for addition byte a = 'a'; diff --git a/src/test/kc/test-comments-usage.kc b/src/test/kc/test-comments-usage.kc index 251d9a469..a6b1f674b 100644 --- a/src/test/kc/test-comments-usage.kc +++ b/src/test/kc/test-comments-usage.kc @@ -1,6 +1,6 @@ // Tests that single-line comments are only included once in the output -const byte* SCREEN = $400; +byte* const SCREEN = $400; // The program entry point void main() { diff --git a/src/test/kc/test-interrupt-notype.kc b/src/test/kc/test-interrupt-notype.kc index da3493fae..ade39d81a 100644 --- a/src/test/kc/test-interrupt-notype.kc +++ b/src/test/kc/test-interrupt-notype.kc @@ -1,6 +1,6 @@ -const void()** KERNEL_IRQ = $0314; -const byte* BGCOL = $d020; -const byte* FGCOL = $d021; +void()** const KERNEL_IRQ = $0314; +byte* const BGCOL = $d020; +byte* const FGCOL = $d021; void main() { *KERNEL_IRQ = &irq; diff --git a/src/test/kc/test-interrupt-volatile-write.kc b/src/test/kc/test-interrupt-volatile-write.kc index 71d805c99..d182d2792 100644 --- a/src/test/kc/test-interrupt-volatile-write.kc +++ b/src/test/kc/test-interrupt-volatile-write.kc @@ -1,8 +1,8 @@ // Tests that volatile variables can be both read & written inside & outside interrupts // Currently fails because the modification is optimized away -const void()** KERNEL_IRQ = $0314; -const byte* BGCOL = $d020; +void()** const KERNEL_IRQ = $0314; +byte* const BGCOL = $d020; volatile byte col = 0; void main() { diff --git a/src/test/kc/test-interrupt-volatile.kc b/src/test/kc/test-interrupt-volatile.kc index 8c0f0a2e7..b5ac10450 100644 --- a/src/test/kc/test-interrupt-volatile.kc +++ b/src/test/kc/test-interrupt-volatile.kc @@ -1,5 +1,5 @@ -const void()** KERNEL_IRQ = $0314; -const byte* BGCOL = $d020; +void()** const KERNEL_IRQ = $0314; +byte* const BGCOL = $d020; volatile byte col = 0; void main() { diff --git a/src/test/kc/test-interrupt.kc b/src/test/kc/test-interrupt.kc index 2169472c7..c9f7c1c4e 100644 --- a/src/test/kc/test-interrupt.kc +++ b/src/test/kc/test-interrupt.kc @@ -1,6 +1,6 @@ -const void()** KERNEL_IRQ = $0314; -const byte* BGCOL = $d020; -const byte* FGCOL = $d021; +void()** const KERNEL_IRQ = $0314; +byte* const BGCOL = $d020; +byte* const FGCOL = $d021; void main() { *KERNEL_IRQ = &irq; diff --git a/src/test/kc/test-scroll-up.kc b/src/test/kc/test-scroll-up.kc index 2e77bbc3e..2af0f16dc 100644 --- a/src/test/kc/test-scroll-up.kc +++ b/src/test/kc/test-scroll-up.kc @@ -1,6 +1,6 @@ // Tests different ways of scrolling up the screen -const byte* screen = $400; +byte* const screen = $400; void main() { scrollup1(); diff --git a/src/test/kc/textbox.kc b/src/test/kc/textbox.kc index 0ff922f37..c99ca7d07 100644 --- a/src/test/kc/textbox.kc +++ b/src/test/kc/textbox.kc @@ -1,7 +1,7 @@ /* Textbox routine with word wrap for KickC by Scan/Desire */ import "c64.kc" -const byte* screen = $0400; +byte* const screen = $0400; const byte text[] = "this is a small test with word wrap, if a word is too long it moves it to the next line. isn't that supercalifragilisticexpialidocious? i think it's cool!"; const byte text2[] = "textbox by scan of desire"; diff --git a/src/test/kc/tod018-problem.kc b/src/test/kc/tod018-problem.kc index ae34ddc1f..e2e0bfa1d 100644 --- a/src/test/kc/tod018-problem.kc +++ b/src/test/kc/tod018-problem.kc @@ -1,8 +1,8 @@ // Tests a problem with tod018 not calculating types correctly void main() { - const byte *D018 = 0xd018; - const byte* screen = 0x0400; + byte * const D018 = 0xd018; + byte* const screen = 0x0400; byte d018val = >(screen&$3fff); *D018 = d018val; } diff --git a/src/test/kc/tofewparams.kc b/src/test/kc/tofewparams.kc index 926bdeaca..7072b647c 100644 --- a/src/test/kc/tofewparams.kc +++ b/src/test/kc/tofewparams.kc @@ -6,7 +6,7 @@ void main() { void plot(byte x, byte y) { - const byte* screen = $0400; + byte* const screen = $0400; byte* pos = screen+x+y; *pos = 1; } \ No newline at end of file diff --git a/src/test/kc/tomanyparams.kc b/src/test/kc/tomanyparams.kc index 0a82a1c4f..0270f03bb 100644 --- a/src/test/kc/tomanyparams.kc +++ b/src/test/kc/tomanyparams.kc @@ -6,7 +6,7 @@ void main() { void plot(byte x, byte y) { - const byte* screen = $0400; + byte* const screen = $0400; byte* pos = screen+x+y; *pos = 1; } \ No newline at end of file diff --git a/src/test/kc/type-inference.kc b/src/test/kc/type-inference.kc index 968ecdf1d..3fa991f2a 100644 --- a/src/test/kc/type-inference.kc +++ b/src/test/kc/type-inference.kc @@ -1,7 +1,7 @@ // Test inference of integer types in expressions void main() { - const word* screen = 0x0400; + word* const screen = 0x0400; for( byte b: 0..20) { screen[b] = -0x30+b; } diff --git a/src/test/kc/type-promotion-bool-param.kc b/src/test/kc/type-promotion-bool-param.kc index 6f286158a..f58cc1acc 100644 --- a/src/test/kc/type-promotion-bool-param.kc +++ b/src/test/kc/type-promotion-bool-param.kc @@ -1,6 +1,6 @@ // Test promoting a bool to a byte -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char i = 0; diff --git a/src/test/kc/type-promotion-schar-param.kc b/src/test/kc/type-promotion-schar-param.kc index 7fbcb52f5..32a266a58 100644 --- a/src/test/kc/type-promotion-schar-param.kc +++ b/src/test/kc/type-promotion-schar-param.kc @@ -1,6 +1,6 @@ // Test promotion of signed char parameter to word -const unsigned int* SCREEN = 0x0400; +unsigned int* const SCREEN = 0x0400; int i = 0; void main() { diff --git a/src/test/kc/typedef-2.kc b/src/test/kc/typedef-2.kc index 1703c1920..7ba59f90b 100644 --- a/src/test/kc/typedef-2.kc +++ b/src/test/kc/typedef-2.kc @@ -1,7 +1,7 @@ typedef unsigned int WORD; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; char* ptr = 0x1000; diff --git a/src/test/kc/typedef-3.kc b/src/test/kc/typedef-3.kc index dff5a5adb..fb6ae4482 100644 --- a/src/test/kc/typedef-3.kc +++ b/src/test/kc/typedef-3.kc @@ -1,6 +1,6 @@ // Typedef an array -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; typedef char STR[7]; diff --git a/src/test/kc/typeid-plus-byte-problem.kc b/src/test/kc/typeid-plus-byte-problem.kc index 1b7cc98c6..36abf0cbe 100644 --- a/src/test/kc/typeid-plus-byte-problem.kc +++ b/src/test/kc/typeid-plus-byte-problem.kc @@ -1,6 +1,6 @@ // Test that byte+byte creates a byte - even when there is a value overflow -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { unsigned byte ubc1 = 12+13+14; diff --git a/src/test/kc/typeid-plus-bytes.kc b/src/test/kc/typeid-plus-bytes.kc index d30efed35..e3bf867cd 100644 --- a/src/test/kc/typeid-plus-bytes.kc +++ b/src/test/kc/typeid-plus-bytes.kc @@ -1,7 +1,7 @@ // Test that plus creates the expected type for all legal combinations of bytes (signed/unsigned - constant/variable) -const byte* SCREEN = $400; -const signed byte* SSCREEN = $400; +byte* const SCREEN = $400; +signed byte* const SSCREEN = $400; byte idx = 0; void main() { diff --git a/src/test/kc/typeid-simple.kc b/src/test/kc/typeid-simple.kc index 03c0d3fd0..8ee95b5e3 100644 --- a/src/test/kc/typeid-simple.kc +++ b/src/test/kc/typeid-simple.kc @@ -1,6 +1,6 @@ // Test typeid() of the different types void main() { - const byte* SCREEN = $400; + byte* const SCREEN = $400; byte idx = 0; // Simple types SCREEN[idx++] = typeid(void); diff --git a/src/test/kc/typemismatch.kc b/src/test/kc/typemismatch.kc index d391e89a0..638efdaed 100644 --- a/src/test/kc/typemismatch.kc +++ b/src/test/kc/typemismatch.kc @@ -2,6 +2,6 @@ void main() { word w = 5000; byte b = w; - const byte* screen = 0x0400; + byte* const screen = 0x0400; screen[0] = b; } \ No newline at end of file diff --git a/src/test/kc/uninitialized.kc b/src/test/kc/uninitialized.kc index b5a41c4a8..67eac3c79 100644 --- a/src/test/kc/uninitialized.kc +++ b/src/test/kc/uninitialized.kc @@ -4,7 +4,7 @@ byte b; word w; byte* ptr; -const byte* SCREEN = $400; +byte* const SCREEN = $400; void main() { SCREEN[0] = b; diff --git a/src/test/kc/unused-irq.kc b/src/test/kc/unused-irq.kc index 9100e1695..96bdc73c8 100644 --- a/src/test/kc/unused-irq.kc +++ b/src/test/kc/unused-irq.kc @@ -1,12 +1,12 @@ // Unused interrupts pointing to each other but never used from main loop - should be optimized away -const byte* SCREEN = 0x0400; +byte* const SCREEN = 0x0400; void main() { *SCREEN = 'x'; } -const void()** HARDWARE_IRQ = $fffe; +void()** const HARDWARE_IRQ = $fffe; // Unused Interrupt Routine interrupt void irq1() { diff --git a/src/test/kc/unused-vars.kc b/src/test/kc/unused-vars.kc index f1bda036b..2c6961be3 100644 --- a/src/test/kc/unused-vars.kc +++ b/src/test/kc/unused-vars.kc @@ -1,9 +1,9 @@ // used vars -const byte* SCREEN = $0400; +byte* const SCREEN = $0400; byte b=2/2; // unused vars -const byte* BGCOL = $d021; +byte* const BGCOL = $d021; byte msg[] = "hello world"; byte arr[] = { 7, 8, 9}; byte c=1; diff --git a/src/test/kc/var-forward-problem.kc b/src/test/kc/var-forward-problem.kc index 6b3782051..ba21106db 100644 --- a/src/test/kc/var-forward-problem.kc +++ b/src/test/kc/var-forward-problem.kc @@ -4,5 +4,5 @@ void main() { *screen = b; } -const byte* screen = $400; +byte* const screen = $400; const byte b = 'a'; \ No newline at end of file diff --git a/src/test/kc/varmodel-ma_mem-5.kc b/src/test/kc/varmodel-ma_mem-5.kc index 5a7146c37..4bb47c1bf 100644 --- a/src/test/kc/varmodel-ma_mem-5.kc +++ b/src/test/kc/varmodel-ma_mem-5.kc @@ -3,7 +3,7 @@ #pragma var_model(ma_mem, pointer_ssa_zp) -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { char i=0; diff --git a/src/test/kc/varmodel-unknown.kc b/src/test/kc/varmodel-unknown.kc index 54e7050c8..7038473c4 100644 --- a/src/test/kc/varmodel-unknown.kc +++ b/src/test/kc/varmodel-unknown.kc @@ -2,6 +2,6 @@ #pragma var_model(qweasd) void main() { - const char* SCREEN = 0x0400; + char* const SCREEN = 0x0400; *SCREEN = 'a'; } \ No newline at end of file diff --git a/src/test/kc/void-parameter.kc b/src/test/kc/void-parameter.kc index 09fcde304..00bbd6381 100644 --- a/src/test/kc/void-parameter.kc +++ b/src/test/kc/void-parameter.kc @@ -7,7 +7,7 @@ void main(void) { print(); } -const byte* SCREEN = 0x400; +byte* const SCREEN = 0x400; byte idx = 0; void print(void) { diff --git a/src/test/kc/volatile-0.kc b/src/test/kc/volatile-0.kc index d2d284a77..4bada517c 100644 --- a/src/test/kc/volatile-0.kc +++ b/src/test/kc/volatile-0.kc @@ -2,7 +2,7 @@ volatile char i = 3; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { while(i<7) diff --git a/src/test/kc/volatile-1.kc b/src/test/kc/volatile-1.kc index a61949ae2..f11676a1e 100644 --- a/src/test/kc/volatile-1.kc +++ b/src/test/kc/volatile-1.kc @@ -1,6 +1,6 @@ // Test that volatile vars are turned into load/store -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; void main() { volatile char i = 3; diff --git a/src/test/kc/volatile-2.kc b/src/test/kc/volatile-2.kc index d7e7902b6..1ee9f3b1f 100644 --- a/src/test/kc/volatile-2.kc +++ b/src/test/kc/volatile-2.kc @@ -1,6 +1,6 @@ // Test that volatile const vars are turned into load/store -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; const volatile char ch = 3; diff --git a/src/test/kc/word-array-0.kc b/src/test/kc/word-array-0.kc index d4e95c76e..dcbf4060c 100644 --- a/src/test/kc/word-array-0.kc +++ b/src/test/kc/word-array-0.kc @@ -1,6 +1,6 @@ // Tests a simple word array void main() { - const byte* SCREEN = $400+6*40; + byte* const SCREEN = $400+6*40; word words[3] = $0400; word w1 = words[1]; SCREEN[0] = words[0]; SCREEN[1] = w1; diff --git a/src/test/kc/word-pointer-math-1.kc b/src/test/kc/word-pointer-math-1.kc index 6a267987d..43c96c2e7 100644 --- a/src/test/kc/word-pointer-math-1.kc +++ b/src/test/kc/word-pointer-math-1.kc @@ -3,6 +3,6 @@ void main() { word* w1 = 0x1000; word* w2 = 0x1140; word wd = w2 - w1; - const word* SCREEN = 0x0400; + word* const SCREEN = 0x0400; *SCREEN = wd; } diff --git a/src/test/kc/word-pointer-math.kc b/src/test/kc/word-pointer-math.kc index 523a92909..abf272e74 100644 --- a/src/test/kc/word-pointer-math.kc +++ b/src/test/kc/word-pointer-math.kc @@ -2,7 +2,7 @@ void main() { // Clever word array that represents C64 numbers 0-7 word words[] = { $3130, $3332, $3534, $3736}; - const byte* SCREEN = $400; + byte* const SCREEN = $400; byte idx = 0; for( byte i: 0..3) { word w = *(words+i); diff --git a/src/test/kc/zeropage-exhausted.kc b/src/test/kc/zeropage-exhausted.kc index d590f616e..680219f3a 100644 --- a/src/test/kc/zeropage-exhausted.kc +++ b/src/test/kc/zeropage-exhausted.kc @@ -5,7 +5,7 @@ // And then allocate a 2-byte-variable void main() { - const int* SCREEN = 0x0400; + int* const SCREEN = 0x0400; for(__zp int i=0;i<10;i++) SCREEN[(char)i] = i; } diff --git a/src/test/kc/zeropage-sinus.kc b/src/test/kc/zeropage-sinus.kc index b68e9a3a3..d30f79772 100644 --- a/src/test/kc/zeropage-sinus.kc +++ b/src/test/kc/zeropage-sinus.kc @@ -12,7 +12,7 @@ const unsigned char align(0x100) SINTABLE[0x100] = kickasm {{ // Storage for saving/restoring zeropage const unsigned char align(0x100) ZP_STORAGE[0x100]; -const char* SCREEN = 0x0400; +char* const SCREEN = 0x0400; // A single sprite to animate const align(0x40) char SPRITE[0x40] = kickasm {{ .fill $40,$ff }}; diff --git a/src/test/ref/pointer-const-typedef.asm b/src/test/ref/pointer-const-typedef.asm new file mode 100644 index 000000000..3566abd37 --- /dev/null +++ b/src/test/ref/pointer-const-typedef.asm @@ -0,0 +1,48 @@ +// Test pointer to const and const pointer combined with typedef +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Pointer to const + .label pc0 = $400 + // Const pointer + .label cp0 = $400 + .label cp2 = $400 + // Const pointer to const + .label cpc0 = $400 + .label cpc1 = $400 + .label cpc2 = $400 + .label pc1 = $400 + .label pc2 = $400 + .label cp1 = $400 + .label SCREEN = $400 +main: { + // SCREEN[idx++] = *pc0 + lda pc0 + sta SCREEN + // SCREEN[idx++] = *pc1 + lda pc1 + sta SCREEN+1 + // SCREEN[idx++] = *pc2 + lda pc2 + sta SCREEN+2 + // SCREEN[idx++] = *cp0 + lda cp0 + sta SCREEN+3 + // SCREEN[idx++] = *cp1 + lda cp1 + sta SCREEN+4 + // SCREEN[idx++] = *cp2 + lda cp2 + sta SCREEN+5 + // SCREEN[idx++] = *cpc0 + lda cpc0 + sta SCREEN+6 + // SCREEN[idx++] = *cpc1 + lda cpc1 + sta SCREEN+7 + // SCREEN[idx++] = *cpc2 + lda cpc2 + sta SCREEN+8 + // } + rts +} diff --git a/src/test/ref/pointer-const-typedef.cfg b/src/test/ref/pointer-const-typedef.cfg new file mode 100644 index 000000000..f3a444191 --- /dev/null +++ b/src/test/ref/pointer-const-typedef.cfg @@ -0,0 +1,25 @@ +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() + +(void()) main() +main: scope:[main] from @1 + [4] *((const byte*) SCREEN) ← *((const byte*) pc0) + [5] *((const byte*) SCREEN+(byte) 1) ← *((const byte*) pc1) + [6] *((const byte*) SCREEN+(byte) 2) ← *((const byte*) pc2) + [7] *((const byte*) SCREEN+(byte) 3) ← *((const byte*) cp0) + [8] *((const byte*) SCREEN+(byte) 4) ← *((const byte*) cp1) + [9] *((const byte*) SCREEN+(byte) 5) ← *((const byte*) cp2) + [10] *((const byte*) SCREEN+(byte) 6) ← *((const byte*) cpc0) + [11] *((const byte*) SCREEN+(byte) 7) ← *((const byte*) cpc1) + [12] *((const byte*) SCREEN+(byte) 8) ← *((const byte*) cpc2) + to:main::@return +main::@return: scope:[main] from main + [13] return + to:@return diff --git a/src/test/ref/pointer-const-typedef.log b/src/test/ref/pointer-const-typedef.log new file mode 100644 index 000000000..320816a55 --- /dev/null +++ b/src/test/ref/pointer-const-typedef.log @@ -0,0 +1,488 @@ +Identified constant variable (byte*) pc1 +Identified constant variable (byte*) pc2 +Identified constant variable (byte*) cp1 +Identified constant variable (byte*) SCREEN + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + to:@1 + +(void()) main() +main: scope:[main] from @1 + (byte) main::idx#0 ← (byte) 0 + *((const byte*) SCREEN + (byte) main::idx#0) ← *((const byte*) pc0) + (byte) main::idx#1 ← ++ (byte) main::idx#0 + *((const byte*) SCREEN + (byte) main::idx#1) ← *((const byte*) pc1) + (byte) main::idx#2 ← ++ (byte) main::idx#1 + *((const byte*) SCREEN + (byte) main::idx#2) ← *((const byte*) pc2) + (byte) main::idx#3 ← ++ (byte) main::idx#2 + *((const byte*) SCREEN + (byte) main::idx#3) ← *((const byte*) cp0) + (byte) main::idx#4 ← ++ (byte) main::idx#3 + *((const byte*) SCREEN + (byte) main::idx#4) ← *((const byte*) cp1) + (byte) main::idx#5 ← ++ (byte) main::idx#4 + *((const byte*) SCREEN + (byte) main::idx#5) ← *((const byte*) cp2) + (byte) main::idx#6 ← ++ (byte) main::idx#5 + *((const byte*) SCREEN + (byte) main::idx#6) ← *((const byte*) cpc0) + (byte) main::idx#7 ← ++ (byte) main::idx#6 + *((const byte*) SCREEN + (byte) main::idx#7) ← *((const byte*) cpc1) + (byte) main::idx#8 ← ++ (byte) main::idx#7 + *((const byte*) SCREEN + (byte) main::idx#8) ← *((const byte*) cpc2) + (byte) main::idx#9 ← ++ (byte) main::idx#8 + to:main::@return +main::@return: scope:[main] from main + return + to:@return +@1: scope:[] from @begin + call main + to:@2 +@2: scope:[] from @1 + to:@end +@end: scope:[] from @2 + +SYMBOL TABLE SSA +(label) @1 +(label) @2 +(label) @begin +(label) @end +(const byte*) SCREEN = (byte*)(number) $400 +(const byte*) cp0 = (byte*)(number) $400 +(const byte*) cp1 = (byte*)(number) $400 +(const byte*) cp2 = (byte*)(number) $400 +(const byte*) cpc0 = (byte*)(number) $400 +(const byte*) cpc1 = (byte*)(number) $400 +(const byte*) cpc2 = (byte*)(number) $400 +(void()) main() +(label) main::@return +(byte) main::idx +(byte) main::idx#0 +(byte) main::idx#1 +(byte) main::idx#2 +(byte) main::idx#3 +(byte) main::idx#4 +(byte) main::idx#5 +(byte) main::idx#6 +(byte) main::idx#7 +(byte) main::idx#8 +(byte) main::idx#9 +(const byte*) pc0 = (byte*)(number) $400 +(const byte*) pc1 = (byte*)(number) $400 +(const byte*) pc2 = (byte*)(number) $400 + +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 1024 +Successful SSA optimization PassNCastSimplification +Constant (const byte) main::idx#0 = 0 +Successful SSA optimization Pass2ConstantIdentification +Simplifying expression containing zero SCREEN in [1] *((const byte*) SCREEN + (const byte) main::idx#0) ← *((const byte*) pc0) +Successful SSA optimization PassNSimplifyExpressionWithZero +Eliminating unused variable (byte) main::idx#9 and assignment [17] (byte) main::idx#9 ← ++ (byte) main::idx#8 +Successful SSA optimization PassNEliminateUnusedVars +Constant right-side identified [1] (byte) main::idx#1 ← ++ (const byte) main::idx#0 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::idx#1 = ++main::idx#0 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [2] (byte) main::idx#2 ← ++ (const byte) main::idx#1 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::idx#2 = ++main::idx#1 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [3] (byte) main::idx#3 ← ++ (const byte) main::idx#2 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::idx#3 = ++main::idx#2 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [4] (byte) main::idx#4 ← ++ (const byte) main::idx#3 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::idx#4 = ++main::idx#3 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [5] (byte) main::idx#5 ← ++ (const byte) main::idx#4 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::idx#5 = ++main::idx#4 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [6] (byte) main::idx#6 ← ++ (const byte) main::idx#5 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::idx#6 = ++main::idx#5 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [7] (byte) main::idx#7 ← ++ (const byte) main::idx#6 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::idx#7 = ++main::idx#6 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [8] (byte) main::idx#8 ← ++ (const byte) main::idx#7 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::idx#8 = ++main::idx#7 +Successful SSA optimization Pass2ConstantIdentification +Inlining constant with different constant siblings (const byte) main::idx#0 +Inlining constant with different constant siblings (const byte) main::idx#1 +Inlining constant with different constant siblings (const byte) main::idx#2 +Inlining constant with different constant siblings (const byte) main::idx#3 +Inlining constant with different constant siblings (const byte) main::idx#4 +Inlining constant with different constant siblings (const byte) main::idx#5 +Inlining constant with different constant siblings (const byte) main::idx#6 +Inlining constant with different constant siblings (const byte) main::idx#7 +Inlining constant with different constant siblings (const byte) main::idx#8 +Constant inlined main::idx#0 = (byte) 0 +Constant inlined main::idx#1 = ++(byte) 0 +Constant inlined main::idx#2 = ++++(byte) 0 +Constant inlined main::idx#3 = ++++++(byte) 0 +Constant inlined main::idx#4 = ++++++++(byte) 0 +Constant inlined main::idx#5 = ++++++++++(byte) 0 +Constant inlined main::idx#6 = ++++++++++++(byte) 0 +Constant inlined main::idx#7 = ++++++++++++++(byte) 0 +Constant inlined main::idx#8 = ++++++++++++++++(byte) 0 +Successful SSA optimization Pass2ConstantInlining +Consolidated array index constant in *(SCREEN+++0) +Consolidated array index constant in *(SCREEN+++++0) +Consolidated array index constant in *(SCREEN+++++++0) +Consolidated array index constant in *(SCREEN+++++++++0) +Consolidated array index constant in *(SCREEN+++++++++++0) +Consolidated array index constant in *(SCREEN+++++++++++++0) +Consolidated array index constant in *(SCREEN+++++++++++++++0) +Consolidated array index constant in *(SCREEN+++++++++++++++++0) +Successful SSA optimization Pass2ConstantAdditionElimination +Simplifying constant integer increment ++0 +Simplifying constant integer increment ++0 +Simplifying constant integer increment ++1 +Simplifying constant integer increment ++2 +Simplifying constant integer increment ++3 +Simplifying constant integer increment ++4 +Simplifying constant integer increment ++5 +Simplifying constant integer increment ++6 +Successful SSA optimization Pass2ConstantSimplification +Simplifying constant integer increment ++1 +Simplifying constant integer increment ++2 +Simplifying constant integer increment ++3 +Simplifying constant integer increment ++4 +Simplifying constant integer increment ++5 +Simplifying constant integer increment ++6 +Simplifying constant integer increment ++7 +Successful SSA optimization Pass2ConstantSimplification +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @end +CALL GRAPH +Calls in [] to main:2 + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes +Culled Empty Block (label) @2 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @end + +FINAL CONTROL FLOW GRAPH +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() + +(void()) main() +main: scope:[main] from @1 + [4] *((const byte*) SCREEN) ← *((const byte*) pc0) + [5] *((const byte*) SCREEN+(byte) 1) ← *((const byte*) pc1) + [6] *((const byte*) SCREEN+(byte) 2) ← *((const byte*) pc2) + [7] *((const byte*) SCREEN+(byte) 3) ← *((const byte*) cp0) + [8] *((const byte*) SCREEN+(byte) 4) ← *((const byte*) cp1) + [9] *((const byte*) SCREEN+(byte) 5) ← *((const byte*) cp2) + [10] *((const byte*) SCREEN+(byte) 6) ← *((const byte*) cpc0) + [11] *((const byte*) SCREEN+(byte) 7) ← *((const byte*) cpc1) + [12] *((const byte*) SCREEN+(byte) 8) ← *((const byte*) cpc2) + to:main::@return +main::@return: scope:[main] from main + [13] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() +(byte) main::idx + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test pointer to const and const pointer combined with typedef + // Upstart +.pc = $801 "Basic" +:BasicUpstart(__bbegin) +.pc = $80d "Program" + // Global Constants & labels + // Pointer to const + .label pc0 = $400 + // Const pointer + .label cp0 = $400 + .label cp2 = $400 + // Const pointer to const + .label cpc0 = $400 + .label cpc1 = $400 + .label cpc2 = $400 + .label pc1 = $400 + .label pc2 = $400 + .label cp1 = $400 + .label SCREEN = $400 + // @begin +__bbegin: + // [1] phi from @begin to @1 [phi:@begin->@1] +__b1_from___bbegin: + jmp __b1 + // @1 +__b1: + // [2] call main + jsr main + // [3] phi from @1 to @end [phi:@1->@end] +__bend_from___b1: + jmp __bend + // @end +__bend: + // main +main: { + // [4] *((const byte*) SCREEN) ← *((const byte*) pc0) -- _deref_pbuc1=_deref_pbuc2 + lda pc0 + sta SCREEN + // [5] *((const byte*) SCREEN+(byte) 1) ← *((const byte*) pc1) -- _deref_pbuc1=_deref_pbuc2 + lda pc1 + sta SCREEN+1 + // [6] *((const byte*) SCREEN+(byte) 2) ← *((const byte*) pc2) -- _deref_pbuc1=_deref_pbuc2 + lda pc2 + sta SCREEN+2 + // [7] *((const byte*) SCREEN+(byte) 3) ← *((const byte*) cp0) -- _deref_pbuc1=_deref_pbuc2 + lda cp0 + sta SCREEN+3 + // [8] *((const byte*) SCREEN+(byte) 4) ← *((const byte*) cp1) -- _deref_pbuc1=_deref_pbuc2 + lda cp1 + sta SCREEN+4 + // [9] *((const byte*) SCREEN+(byte) 5) ← *((const byte*) cp2) -- _deref_pbuc1=_deref_pbuc2 + lda cp2 + sta SCREEN+5 + // [10] *((const byte*) SCREEN+(byte) 6) ← *((const byte*) cpc0) -- _deref_pbuc1=_deref_pbuc2 + lda cpc0 + sta SCREEN+6 + // [11] *((const byte*) SCREEN+(byte) 7) ← *((const byte*) cpc1) -- _deref_pbuc1=_deref_pbuc2 + lda cpc1 + sta SCREEN+7 + // [12] *((const byte*) SCREEN+(byte) 8) ← *((const byte*) cpc2) -- _deref_pbuc1=_deref_pbuc2 + lda cpc2 + sta SCREEN+8 + jmp __breturn + // main::@return + __breturn: + // [13] return + rts +} + // File Data + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [4] *((const byte*) SCREEN) ← *((const byte*) pc0) [ ] ( main:2 [ ] { } ) always clobbers reg byte a +Statement [5] *((const byte*) SCREEN+(byte) 1) ← *((const byte*) pc1) [ ] ( main:2 [ ] { } ) always clobbers reg byte a +Statement [6] *((const byte*) SCREEN+(byte) 2) ← *((const byte*) pc2) [ ] ( main:2 [ ] { } ) always clobbers reg byte a +Statement [7] *((const byte*) SCREEN+(byte) 3) ← *((const byte*) cp0) [ ] ( main:2 [ ] { } ) always clobbers reg byte a +Statement [8] *((const byte*) SCREEN+(byte) 4) ← *((const byte*) cp1) [ ] ( main:2 [ ] { } ) always clobbers reg byte a +Statement [9] *((const byte*) SCREEN+(byte) 5) ← *((const byte*) cp2) [ ] ( main:2 [ ] { } ) always clobbers reg byte a +Statement [10] *((const byte*) SCREEN+(byte) 6) ← *((const byte*) cpc0) [ ] ( main:2 [ ] { } ) always clobbers reg byte a +Statement [11] *((const byte*) SCREEN+(byte) 7) ← *((const byte*) cpc1) [ ] ( main:2 [ ] { } ) always clobbers reg byte a +Statement [12] *((const byte*) SCREEN+(byte) 8) ← *((const byte*) cpc2) [ ] ( main:2 [ ] { } ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [main] +Uplift Scope [] + +Uplifting [main] best 93 combination +Uplifting [] best 93 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test pointer to const and const pointer combined with typedef + // Upstart +.pc = $801 "Basic" +:BasicUpstart(__bbegin) +.pc = $80d "Program" + // Global Constants & labels + // Pointer to const + .label pc0 = $400 + // Const pointer + .label cp0 = $400 + .label cp2 = $400 + // Const pointer to const + .label cpc0 = $400 + .label cpc1 = $400 + .label cpc2 = $400 + .label pc1 = $400 + .label pc2 = $400 + .label cp1 = $400 + .label SCREEN = $400 + // @begin +__bbegin: + // [1] phi from @begin to @1 [phi:@begin->@1] +__b1_from___bbegin: + jmp __b1 + // @1 +__b1: + // [2] call main + jsr main + // [3] phi from @1 to @end [phi:@1->@end] +__bend_from___b1: + jmp __bend + // @end +__bend: + // main +main: { + // [4] *((const byte*) SCREEN) ← *((const byte*) pc0) -- _deref_pbuc1=_deref_pbuc2 + lda pc0 + sta SCREEN + // [5] *((const byte*) SCREEN+(byte) 1) ← *((const byte*) pc1) -- _deref_pbuc1=_deref_pbuc2 + lda pc1 + sta SCREEN+1 + // [6] *((const byte*) SCREEN+(byte) 2) ← *((const byte*) pc2) -- _deref_pbuc1=_deref_pbuc2 + lda pc2 + sta SCREEN+2 + // [7] *((const byte*) SCREEN+(byte) 3) ← *((const byte*) cp0) -- _deref_pbuc1=_deref_pbuc2 + lda cp0 + sta SCREEN+3 + // [8] *((const byte*) SCREEN+(byte) 4) ← *((const byte*) cp1) -- _deref_pbuc1=_deref_pbuc2 + lda cp1 + sta SCREEN+4 + // [9] *((const byte*) SCREEN+(byte) 5) ← *((const byte*) cp2) -- _deref_pbuc1=_deref_pbuc2 + lda cp2 + sta SCREEN+5 + // [10] *((const byte*) SCREEN+(byte) 6) ← *((const byte*) cpc0) -- _deref_pbuc1=_deref_pbuc2 + lda cpc0 + sta SCREEN+6 + // [11] *((const byte*) SCREEN+(byte) 7) ← *((const byte*) cpc1) -- _deref_pbuc1=_deref_pbuc2 + lda cpc1 + sta SCREEN+7 + // [12] *((const byte*) SCREEN+(byte) 8) ← *((const byte*) cpc2) -- _deref_pbuc1=_deref_pbuc2 + lda cpc2 + sta SCREEN+8 + jmp __breturn + // main::@return + __breturn: + // [13] return + rts +} + // File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __b1 +Removing instruction jmp __bend +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __b1_from___bbegin: +Removing instruction __b1: +Removing instruction __bend_from___b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction __bend: +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin +Removing instruction __bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @begin +(label) @end +(const byte*) SCREEN = (byte*) 1024 +(const byte*) cp0 = (byte*) 1024 +(const byte*) cp1 = (byte*) 1024 +(const byte*) cp2 = (byte*) 1024 +(const byte*) cpc0 = (byte*) 1024 +(const byte*) cpc1 = (byte*) 1024 +(const byte*) cpc2 = (byte*) 1024 +(void()) main() +(label) main::@return +(byte) main::idx +(const byte*) pc0 = (byte*) 1024 +(const byte*) pc1 = (byte*) 1024 +(const byte*) pc2 = (byte*) 1024 + + + +FINAL ASSEMBLER +Score: 78 + + // File Comments +// Test pointer to const and const pointer combined with typedef + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // Pointer to const + .label pc0 = $400 + // Const pointer + .label cp0 = $400 + .label cp2 = $400 + // Const pointer to const + .label cpc0 = $400 + .label cpc1 = $400 + .label cpc2 = $400 + .label pc1 = $400 + .label pc2 = $400 + .label cp1 = $400 + .label SCREEN = $400 + // @begin + // [1] phi from @begin to @1 [phi:@begin->@1] + // @1 + // [2] call main + // [3] phi from @1 to @end [phi:@1->@end] + // @end + // main +main: { + // SCREEN[idx++] = *pc0 + // [4] *((const byte*) SCREEN) ← *((const byte*) pc0) -- _deref_pbuc1=_deref_pbuc2 + lda pc0 + sta SCREEN + // SCREEN[idx++] = *pc1 + // [5] *((const byte*) SCREEN+(byte) 1) ← *((const byte*) pc1) -- _deref_pbuc1=_deref_pbuc2 + lda pc1 + sta SCREEN+1 + // SCREEN[idx++] = *pc2 + // [6] *((const byte*) SCREEN+(byte) 2) ← *((const byte*) pc2) -- _deref_pbuc1=_deref_pbuc2 + lda pc2 + sta SCREEN+2 + // SCREEN[idx++] = *cp0 + // [7] *((const byte*) SCREEN+(byte) 3) ← *((const byte*) cp0) -- _deref_pbuc1=_deref_pbuc2 + lda cp0 + sta SCREEN+3 + // SCREEN[idx++] = *cp1 + // [8] *((const byte*) SCREEN+(byte) 4) ← *((const byte*) cp1) -- _deref_pbuc1=_deref_pbuc2 + lda cp1 + sta SCREEN+4 + // SCREEN[idx++] = *cp2 + // [9] *((const byte*) SCREEN+(byte) 5) ← *((const byte*) cp2) -- _deref_pbuc1=_deref_pbuc2 + lda cp2 + sta SCREEN+5 + // SCREEN[idx++] = *cpc0 + // [10] *((const byte*) SCREEN+(byte) 6) ← *((const byte*) cpc0) -- _deref_pbuc1=_deref_pbuc2 + lda cpc0 + sta SCREEN+6 + // SCREEN[idx++] = *cpc1 + // [11] *((const byte*) SCREEN+(byte) 7) ← *((const byte*) cpc1) -- _deref_pbuc1=_deref_pbuc2 + lda cpc1 + sta SCREEN+7 + // SCREEN[idx++] = *cpc2 + // [12] *((const byte*) SCREEN+(byte) 8) ← *((const byte*) cpc2) -- _deref_pbuc1=_deref_pbuc2 + lda cpc2 + sta SCREEN+8 + // main::@return + // } + // [13] return + rts +} + // File Data + diff --git a/src/test/ref/pointer-const-typedef.sym b/src/test/ref/pointer-const-typedef.sym new file mode 100644 index 000000000..44ea81b86 --- /dev/null +++ b/src/test/ref/pointer-const-typedef.sym @@ -0,0 +1,17 @@ +(label) @1 +(label) @begin +(label) @end +(const byte*) SCREEN = (byte*) 1024 +(const byte*) cp0 = (byte*) 1024 +(const byte*) cp1 = (byte*) 1024 +(const byte*) cp2 = (byte*) 1024 +(const byte*) cpc0 = (byte*) 1024 +(const byte*) cpc1 = (byte*) 1024 +(const byte*) cpc2 = (byte*) 1024 +(void()) main() +(label) main::@return +(byte) main::idx +(const byte*) pc0 = (byte*) 1024 +(const byte*) pc1 = (byte*) 1024 +(const byte*) pc2 = (byte*) 1024 + diff --git a/src/test/ref/pointer-const.asm b/src/test/ref/pointer-const.asm new file mode 100644 index 000000000..40ef5c29a --- /dev/null +++ b/src/test/ref/pointer-const.asm @@ -0,0 +1,43 @@ +// Test pointer to const and const pointer +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Const pointer + .label SCREEN = $400 + // Const pointer to const + .label BASIC = $a004 +main: { + ldx #0 + __b1: + // while(MSG[i]) + lda MSG,x + cmp #0 + bne __b2 + ldx #0 + __b3: + // while(BASIC[i]!='0') + lda BASIC,x + cmp #'0' + bne __b4 + // } + rts + __b4: + // BASIC[i]&0x3f + lda #$3f + and BASIC,x + // SCREEN[40+i] = BASIC[i]&0x3f + sta SCREEN+$28,x + // i++; + inx + jmp __b3 + __b2: + // SCREEN[i] = MSG[i] + lda MSG,x + sta SCREEN,x + // i++; + inx + jmp __b1 +} + // Pointer to const + MSG: .text "hello world!" + .byte 0 diff --git a/src/test/ref/pointer-const.cfg b/src/test/ref/pointer-const.cfg new file mode 100644 index 000000000..c01f1f38b --- /dev/null +++ b/src/test/ref/pointer-const.cfg @@ -0,0 +1,34 @@ +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() + +(void()) main() +main: scope:[main] from @1 + [4] phi() + to:main::@1 +main::@1: scope:[main] from main main::@2 + [5] (byte) main::i#4 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 ) + [6] if((byte) 0!=*((const byte*) MSG + (byte) main::i#4)) goto main::@2 + to:main::@3 +main::@3: scope:[main] from main::@1 main::@4 + [7] (byte) main::i#6 ← phi( main::@1/(byte) 0 main::@4/(byte) main::i#3 ) + [8] if(*((const byte*) BASIC + (byte) main::i#6)!=(byte) '0') goto main::@4 + to:main::@return +main::@return: scope:[main] from main::@3 + [9] return + to:@return +main::@4: scope:[main] from main::@3 + [10] (byte~) main::$2 ← *((const byte*) BASIC + (byte) main::i#6) & (byte) $3f + [11] *((const byte*) SCREEN+(byte) $28 + (byte) main::i#6) ← (byte~) main::$2 + [12] (byte) main::i#3 ← ++ (byte) main::i#6 + to:main::@3 +main::@2: scope:[main] from main::@1 + [13] *((const byte*) SCREEN + (byte) main::i#4) ← *((const byte*) MSG + (byte) main::i#4) + [14] (byte) main::i#1 ← ++ (byte) main::i#4 + to:main::@1 diff --git a/src/test/ref/pointer-const.log b/src/test/ref/pointer-const.log new file mode 100644 index 000000000..06b074eae --- /dev/null +++ b/src/test/ref/pointer-const.log @@ -0,0 +1,542 @@ +Warning! Adding boolean cast to non-boolean condition *((byte*) MSG + (byte) main::i) +Identified constant variable (byte*) MSG +Culled Empty Block (label) main::@4 +Culled Empty Block (label) main::@5 +Culled Empty Block (label) main::@6 +Culled Empty Block (label) main::@10 +Culled Empty Block (label) main::@9 +Culled Empty Block (label) main::@11 +Culled Empty Block (label) main::@12 + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + to:@1 + +(void()) main() +main: scope:[main] from @1 + (byte) main::i#0 ← (byte) 0 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::i#4 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 ) + (bool~) main::$3 ← (number) 0 != *((const byte*) MSG + (byte) main::i#4) + if((bool~) main::$3) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 + (byte) main::i#5 ← phi( main::@1/(byte) main::i#4 ) + *((const byte*) SCREEN + (byte) main::i#5) ← *((const byte*) MSG + (byte) main::i#5) + (byte) main::i#1 ← ++ (byte) main::i#5 + to:main::@1 +main::@3: scope:[main] from main::@1 + (byte) main::i#2 ← (number) 0 + to:main::@7 +main::@7: scope:[main] from main::@3 main::@8 + (byte) main::i#6 ← phi( main::@3/(byte) main::i#2 main::@8/(byte) main::i#3 ) + (bool~) main::$0 ← *((const byte*) BASIC + (byte) main::i#6) != (byte) '0' + if((bool~) main::$0) goto main::@8 + to:main::@return +main::@8: scope:[main] from main::@7 + (byte) main::i#7 ← phi( main::@7/(byte) main::i#6 ) + (number~) main::$1 ← (number) $28 + (byte) main::i#7 + (number~) main::$2 ← *((const byte*) BASIC + (byte) main::i#7) & (number) $3f + *((const byte*) SCREEN + (number~) main::$1) ← (number~) main::$2 + (byte) main::i#3 ← ++ (byte) main::i#7 + to:main::@7 +main::@return: scope:[main] from main::@7 + return + to:@return +@1: scope:[] from @begin + call main + to:@2 +@2: scope:[] from @1 + to:@end +@end: scope:[] from @2 + +SYMBOL TABLE SSA +(label) @1 +(label) @2 +(label) @begin +(label) @end +(const byte*) BASIC = (byte*)(number) $a004 +(const byte*) MSG = (byte*) "hello world!" +(const byte*) SCREEN = (byte*)(number) $400 +(void()) main() +(bool~) main::$0 +(number~) main::$1 +(number~) main::$2 +(bool~) main::$3 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@7 +(label) main::@8 +(label) main::@return +(byte) main::i +(byte) main::i#0 +(byte) main::i#1 +(byte) main::i#2 +(byte) main::i#3 +(byte) main::i#4 +(byte) main::i#5 +(byte) main::i#6 +(byte) main::i#7 + +Adding number conversion cast (unumber) 0 in (bool~) main::$3 ← (number) 0 != *((const byte*) MSG + (byte) main::i#4) +Adding number conversion cast (unumber) 0 in (byte) main::i#2 ← (number) 0 +Adding number conversion cast (unumber) $28 in (number~) main::$1 ← (number) $28 + (byte) main::i#7 +Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (unumber)(number) $28 + (byte) main::i#7 +Adding number conversion cast (unumber) $3f in (number~) main::$2 ← *((const byte*) BASIC + (byte) main::i#7) & (number) $3f +Adding number conversion cast (unumber) main::$2 in (number~) main::$2 ← *((const byte*) BASIC + (byte) main::i#7) & (unumber)(number) $3f +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast (byte) main::i#2 ← (unumber)(number) 0 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 40964 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast $28 +Simplifying constant integer cast $3f +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $28 +Finalized unsigned number type (byte) $3f +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inferred type updated to byte in (unumber~) main::$1 ← (byte) $28 + (byte) main::i#7 +Inferred type updated to byte in (unumber~) main::$2 ← *((const byte*) BASIC + (byte) main::i#7) & (byte) $3f +Alias main::i#4 = main::i#5 +Alias main::i#6 = main::i#7 +Successful SSA optimization Pass2AliasElimination +Simple Condition (bool~) main::$3 [3] if((byte) 0!=*((const byte*) MSG + (byte) main::i#4)) goto main::@2 +Simple Condition (bool~) main::$0 [9] if(*((const byte*) BASIC + (byte) main::i#6)!=(byte) '0') goto main::@8 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte) main::i#0 = 0 +Constant (const byte) main::i#2 = 0 +Successful SSA optimization Pass2ConstantIdentification +Inlining constant with var siblings (const byte) main::i#0 +Inlining constant with var siblings (const byte) main::i#2 +Constant inlined main::i#0 = (byte) 0 +Constant inlined main::i#2 = (byte) 0 +Successful SSA optimization Pass2ConstantInlining +Consolidated array index constant in assignment *(SCREEN+$28 + main::$1) +Successful SSA optimization Pass2ConstantAdditionElimination +Alias main::i#6 = main::$1 +Successful SSA optimization Pass2AliasElimination +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of main::@3 +CALL GRAPH +Calls in [] to main:2 + +Created 2 initial phi equivalence classes +Coalesced [15] main::i#9 ← main::i#3 +Coalesced [18] main::i#8 ← main::i#1 +Coalesced down to 2 phi equivalence classes +Culled Empty Block (label) @2 +Culled Empty Block (label) main::@3 +Renumbering block main::@7 to main::@3 +Renumbering block main::@8 to main::@4 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main + +FINAL CONTROL FLOW GRAPH +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() + +(void()) main() +main: scope:[main] from @1 + [4] phi() + to:main::@1 +main::@1: scope:[main] from main main::@2 + [5] (byte) main::i#4 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 ) + [6] if((byte) 0!=*((const byte*) MSG + (byte) main::i#4)) goto main::@2 + to:main::@3 +main::@3: scope:[main] from main::@1 main::@4 + [7] (byte) main::i#6 ← phi( main::@1/(byte) 0 main::@4/(byte) main::i#3 ) + [8] if(*((const byte*) BASIC + (byte) main::i#6)!=(byte) '0') goto main::@4 + to:main::@return +main::@return: scope:[main] from main::@3 + [9] return + to:@return +main::@4: scope:[main] from main::@3 + [10] (byte~) main::$2 ← *((const byte*) BASIC + (byte) main::i#6) & (byte) $3f + [11] *((const byte*) SCREEN+(byte) $28 + (byte) main::i#6) ← (byte~) main::$2 + [12] (byte) main::i#3 ← ++ (byte) main::i#6 + to:main::@3 +main::@2: scope:[main] from main::@1 + [13] *((const byte*) SCREEN + (byte) main::i#4) ← *((const byte*) MSG + (byte) main::i#4) + [14] (byte) main::i#1 ← ++ (byte) main::i#4 + to:main::@1 + + +VARIABLE REGISTER WEIGHTS +(void()) main() +(byte~) main::$2 202.0 +(byte) main::i +(byte) main::i#1 202.0 +(byte) main::i#3 202.0 +(byte) main::i#4 168.33333333333331 +(byte) main::i#6 126.25 + +Initial phi equivalence classes +[ main::i#4 main::i#1 ] +[ main::i#6 main::i#3 ] +Added variable main::$2 to live range equivalence class [ main::$2 ] +Complete equivalence classes +[ main::i#4 main::i#1 ] +[ main::i#6 main::i#3 ] +[ main::$2 ] +Allocated zp[1]:2 [ main::i#4 main::i#1 ] +Allocated zp[1]:3 [ main::i#6 main::i#3 ] +Allocated zp[1]:4 [ main::$2 ] + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test pointer to const and const pointer + // Upstart +.pc = $801 "Basic" +:BasicUpstart(__bbegin) +.pc = $80d "Program" + // Global Constants & labels + // Const pointer + .label SCREEN = $400 + // Const pointer to const + .label BASIC = $a004 + // @begin +__bbegin: + // [1] phi from @begin to @1 [phi:@begin->@1] +__b1_from___bbegin: + jmp __b1 + // @1 +__b1: + // [2] call main + // [4] phi from @1 to main [phi:@1->main] +main_from___b1: + jsr main + // [3] phi from @1 to @end [phi:@1->@end] +__bend_from___b1: + jmp __bend + // @end +__bend: + // main +main: { + .label __2 = 4 + .label i = 2 + .label i_1 = 3 + // [5] phi from main to main::@1 [phi:main->main::@1] + __b1_from_main: + // [5] phi (byte) main::i#4 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 + lda #0 + sta.z i + jmp __b1 + // main::@1 + __b1: + // [6] if((byte) 0!=*((const byte*) MSG + (byte) main::i#4)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1 + lda #0 + ldy.z i + cmp MSG,y + bne __b2 + // [7] phi from main::@1 to main::@3 [phi:main::@1->main::@3] + __b3_from___b1: + // [7] phi (byte) main::i#6 = (byte) 0 [phi:main::@1->main::@3#0] -- vbuz1=vbuc1 + lda #0 + sta.z i_1 + jmp __b3 + // main::@3 + __b3: + // [8] if(*((const byte*) BASIC + (byte) main::i#6)!=(byte) '0') goto main::@4 -- pbuc1_derefidx_vbuz1_neq_vbuc2_then_la1 + lda #'0' + ldy.z i_1 + cmp BASIC,y + bne __b4 + jmp __breturn + // main::@return + __breturn: + // [9] return + rts + // main::@4 + __b4: + // [10] (byte~) main::$2 ← *((const byte*) BASIC + (byte) main::i#6) & (byte) $3f -- vbuz1=pbuc1_derefidx_vbuz2_band_vbuc2 + lda #$3f + ldy.z i_1 + and BASIC,y + sta.z __2 + // [11] *((const byte*) SCREEN+(byte) $28 + (byte) main::i#6) ← (byte~) main::$2 -- pbuc1_derefidx_vbuz1=vbuz2 + lda.z __2 + ldy.z i_1 + sta SCREEN+$28,y + // [12] (byte) main::i#3 ← ++ (byte) main::i#6 -- vbuz1=_inc_vbuz1 + inc.z i_1 + // [7] phi from main::@4 to main::@3 [phi:main::@4->main::@3] + __b3_from___b4: + // [7] phi (byte) main::i#6 = (byte) main::i#3 [phi:main::@4->main::@3#0] -- register_copy + jmp __b3 + // main::@2 + __b2: + // [13] *((const byte*) SCREEN + (byte) main::i#4) ← *((const byte*) MSG + (byte) main::i#4) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z i + lda MSG,y + sta SCREEN,y + // [14] (byte) main::i#1 ← ++ (byte) main::i#4 -- vbuz1=_inc_vbuz1 + inc.z i + // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + __b1_from___b2: + // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + jmp __b1 +} + // File Data + // Pointer to const + MSG: .text "hello world!" + .byte 0 + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [6] if((byte) 0!=*((const byte*) MSG + (byte) main::i#4)) goto main::@2 [ main::i#4 ] ( main:2 [ main::i#4 ] { } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#4 main::i#1 ] +Statement [8] if(*((const byte*) BASIC + (byte) main::i#6)!=(byte) '0') goto main::@4 [ main::i#6 ] ( main:2 [ main::i#6 ] { } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::i#6 main::i#3 ] +Statement [10] (byte~) main::$2 ← *((const byte*) BASIC + (byte) main::i#6) & (byte) $3f [ main::i#6 main::$2 ] ( main:2 [ main::i#6 main::$2 ] { } ) always clobbers reg byte a +Statement [13] *((const byte*) SCREEN + (byte) main::i#4) ← *((const byte*) MSG + (byte) main::i#4) [ main::i#4 ] ( main:2 [ main::i#4 ] { } ) always clobbers reg byte a +Statement [6] if((byte) 0!=*((const byte*) MSG + (byte) main::i#4)) goto main::@2 [ main::i#4 ] ( main:2 [ main::i#4 ] { } ) always clobbers reg byte a +Statement [8] if(*((const byte*) BASIC + (byte) main::i#6)!=(byte) '0') goto main::@4 [ main::i#6 ] ( main:2 [ main::i#6 ] { } ) always clobbers reg byte a +Statement [10] (byte~) main::$2 ← *((const byte*) BASIC + (byte) main::i#6) & (byte) $3f [ main::i#6 main::$2 ] ( main:2 [ main::i#6 main::$2 ] { } ) always clobbers reg byte a +Statement [13] *((const byte*) SCREEN + (byte) main::i#4) ← *((const byte*) MSG + (byte) main::i#4) [ main::i#4 ] ( main:2 [ main::i#4 ] { } ) always clobbers reg byte a +Potential registers zp[1]:2 [ main::i#4 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y , +Potential registers zp[1]:3 [ main::i#6 main::i#3 ] : zp[1]:3 , reg byte x , reg byte y , +Potential registers zp[1]:4 [ main::$2 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 370.33: zp[1]:2 [ main::i#4 main::i#1 ] 328.25: zp[1]:3 [ main::i#6 main::i#3 ] 202: zp[1]:4 [ main::$2 ] +Uplift Scope [] + +Uplifting [main] best 638 combination reg byte x [ main::i#4 main::i#1 ] reg byte x [ main::i#6 main::i#3 ] reg byte a [ main::$2 ] +Uplifting [] best 638 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test pointer to const and const pointer + // Upstart +.pc = $801 "Basic" +:BasicUpstart(__bbegin) +.pc = $80d "Program" + // Global Constants & labels + // Const pointer + .label SCREEN = $400 + // Const pointer to const + .label BASIC = $a004 + // @begin +__bbegin: + // [1] phi from @begin to @1 [phi:@begin->@1] +__b1_from___bbegin: + jmp __b1 + // @1 +__b1: + // [2] call main + // [4] phi from @1 to main [phi:@1->main] +main_from___b1: + jsr main + // [3] phi from @1 to @end [phi:@1->@end] +__bend_from___b1: + jmp __bend + // @end +__bend: + // main +main: { + // [5] phi from main to main::@1 [phi:main->main::@1] + __b1_from_main: + // [5] phi (byte) main::i#4 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 + jmp __b1 + // main::@1 + __b1: + // [6] if((byte) 0!=*((const byte*) MSG + (byte) main::i#4)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 + lda MSG,x + cmp #0 + bne __b2 + // [7] phi from main::@1 to main::@3 [phi:main::@1->main::@3] + __b3_from___b1: + // [7] phi (byte) main::i#6 = (byte) 0 [phi:main::@1->main::@3#0] -- vbuxx=vbuc1 + ldx #0 + jmp __b3 + // main::@3 + __b3: + // [8] if(*((const byte*) BASIC + (byte) main::i#6)!=(byte) '0') goto main::@4 -- pbuc1_derefidx_vbuxx_neq_vbuc2_then_la1 + lda BASIC,x + cmp #'0' + bne __b4 + jmp __breturn + // main::@return + __breturn: + // [9] return + rts + // main::@4 + __b4: + // [10] (byte~) main::$2 ← *((const byte*) BASIC + (byte) main::i#6) & (byte) $3f -- vbuaa=pbuc1_derefidx_vbuxx_band_vbuc2 + lda #$3f + and BASIC,x + // [11] *((const byte*) SCREEN+(byte) $28 + (byte) main::i#6) ← (byte~) main::$2 -- pbuc1_derefidx_vbuxx=vbuaa + sta SCREEN+$28,x + // [12] (byte) main::i#3 ← ++ (byte) main::i#6 -- vbuxx=_inc_vbuxx + inx + // [7] phi from main::@4 to main::@3 [phi:main::@4->main::@3] + __b3_from___b4: + // [7] phi (byte) main::i#6 = (byte) main::i#3 [phi:main::@4->main::@3#0] -- register_copy + jmp __b3 + // main::@2 + __b2: + // [13] *((const byte*) SCREEN + (byte) main::i#4) ← *((const byte*) MSG + (byte) main::i#4) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MSG,x + sta SCREEN,x + // [14] (byte) main::i#1 ← ++ (byte) main::i#4 -- vbuxx=_inc_vbuxx + inx + // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + __b1_from___b2: + // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + jmp __b1 +} + // File Data + // Pointer to const + MSG: .text "hello world!" + .byte 0 + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __b1 +Removing instruction jmp __bend +Removing instruction jmp __b1 +Removing instruction jmp __b3 +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __b1_from___bbegin: +Removing instruction __b1: +Removing instruction main_from___b1: +Removing instruction __bend_from___b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction __bend: +Removing instruction __b1_from_main: +Removing instruction __b3_from___b1: +Removing instruction __breturn: +Removing instruction __b3_from___b4: +Removing instruction __b1_from___b2: +Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin +Removing instruction __bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @begin +(label) @end +(const byte*) BASIC = (byte*) 40964 +(const byte*) MSG = (byte*) "hello world!" +(const byte*) SCREEN = (byte*) 1024 +(void()) main() +(byte~) main::$2 reg byte a 202.0 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@return +(byte) main::i +(byte) main::i#1 reg byte x 202.0 +(byte) main::i#3 reg byte x 202.0 +(byte) main::i#4 reg byte x 168.33333333333331 +(byte) main::i#6 reg byte x 126.25 + +reg byte x [ main::i#4 main::i#1 ] +reg byte x [ main::i#6 main::i#3 ] +reg byte a [ main::$2 ] + + +FINAL ASSEMBLER +Score: 536 + + // File Comments +// Test pointer to const and const pointer + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // Const pointer + .label SCREEN = $400 + // Const pointer to const + .label BASIC = $a004 + // @begin + // [1] phi from @begin to @1 [phi:@begin->@1] + // @1 + // [2] call main + // [4] phi from @1 to main [phi:@1->main] + // [3] phi from @1 to @end [phi:@1->@end] + // @end + // main +main: { + // [5] phi from main to main::@1 [phi:main->main::@1] + // [5] phi (byte) main::i#4 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 + // main::@1 + __b1: + // while(MSG[i]) + // [6] if((byte) 0!=*((const byte*) MSG + (byte) main::i#4)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 + lda MSG,x + cmp #0 + bne __b2 + // [7] phi from main::@1 to main::@3 [phi:main::@1->main::@3] + // [7] phi (byte) main::i#6 = (byte) 0 [phi:main::@1->main::@3#0] -- vbuxx=vbuc1 + ldx #0 + // main::@3 + __b3: + // while(BASIC[i]!='0') + // [8] if(*((const byte*) BASIC + (byte) main::i#6)!=(byte) '0') goto main::@4 -- pbuc1_derefidx_vbuxx_neq_vbuc2_then_la1 + lda BASIC,x + cmp #'0' + bne __b4 + // main::@return + // } + // [9] return + rts + // main::@4 + __b4: + // BASIC[i]&0x3f + // [10] (byte~) main::$2 ← *((const byte*) BASIC + (byte) main::i#6) & (byte) $3f -- vbuaa=pbuc1_derefidx_vbuxx_band_vbuc2 + lda #$3f + and BASIC,x + // SCREEN[40+i] = BASIC[i]&0x3f + // [11] *((const byte*) SCREEN+(byte) $28 + (byte) main::i#6) ← (byte~) main::$2 -- pbuc1_derefidx_vbuxx=vbuaa + sta SCREEN+$28,x + // i++; + // [12] (byte) main::i#3 ← ++ (byte) main::i#6 -- vbuxx=_inc_vbuxx + inx + // [7] phi from main::@4 to main::@3 [phi:main::@4->main::@3] + // [7] phi (byte) main::i#6 = (byte) main::i#3 [phi:main::@4->main::@3#0] -- register_copy + jmp __b3 + // main::@2 + __b2: + // SCREEN[i] = MSG[i] + // [13] *((const byte*) SCREEN + (byte) main::i#4) ← *((const byte*) MSG + (byte) main::i#4) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MSG,x + sta SCREEN,x + // i++; + // [14] (byte) main::i#1 ← ++ (byte) main::i#4 -- vbuxx=_inc_vbuxx + inx + // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy + jmp __b1 +} + // File Data + // Pointer to const + MSG: .text "hello world!" + .byte 0 + diff --git a/src/test/ref/pointer-const.sym b/src/test/ref/pointer-const.sym new file mode 100644 index 000000000..efc5c0955 --- /dev/null +++ b/src/test/ref/pointer-const.sym @@ -0,0 +1,22 @@ +(label) @1 +(label) @begin +(label) @end +(const byte*) BASIC = (byte*) 40964 +(const byte*) MSG = (byte*) "hello world!" +(const byte*) SCREEN = (byte*) 1024 +(void()) main() +(byte~) main::$2 reg byte a 202.0 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@return +(byte) main::i +(byte) main::i#1 reg byte x 202.0 +(byte) main::i#3 reg byte x 202.0 +(byte) main::i#4 reg byte x 168.33333333333331 +(byte) main::i#6 reg byte x 126.25 + +reg byte x [ main::i#4 main::i#1 ] +reg byte x [ main::i#6 main::i#3 ] +reg byte a [ main::$2 ]