From facd70053d205bedb292f419612e8171877a6887 Mon Sep 17 00:00:00 2001
From: jespergravgaard <jesper@balmangravgaard.dk>
Date: Thu, 30 Apr 2020 22:15:59 +0200
Subject: [PATCH] Added support for address-of pointers to members of structs.

---
 .../Pass0GenerateStatementSequence.java       |  14 +-
 .../kickc/passes/Pass4CodeGeneration.java     |  95 +++--
 .../dk/camelot64/kickc/test/TestPrograms.java |  10 +
 src/test/kc/sizeof-in-const-pointer.c         |   7 +
 src/test/kc/struct-pointer-to-member.c        |  23 ++
 src/test/ref/address-of-3.asm                 |   2 +-
 src/test/ref/address-of-3.log                 |   6 +-
 src/test/ref/assignment-compound.asm          |   4 +-
 src/test/ref/assignment-compound.log          |  12 +-
 src/test/ref/atoi-1.asm                       |   2 +-
 src/test/ref/atoi-1.log                       |   6 +-
 src/test/ref/bgblack.asm                      |   2 +-
 src/test/ref/bgblack.log                      |   6 +-
 src/test/ref/bitmap-circle-2.asm              |   6 +-
 src/test/ref/bitmap-circle-2.log              |  18 +-
 src/test/ref/bitmap-circle.asm                |   6 +-
 src/test/ref/bitmap-circle.log                |  18 +-
 src/test/ref/bitmap-line-anim-1.asm           |   6 +-
 src/test/ref/bitmap-line-anim-1.log           |  18 +-
 src/test/ref/bitmap-line-anim-2.asm           |   8 +-
 src/test/ref/bitmap-line-anim-2.log           |  24 +-
 src/test/ref/bitmap-plot-0.asm                |  26 +-
 src/test/ref/bitmap-plot-0.log                |  78 ++--
 src/test/ref/bitmap-plot-1.asm                |  36 +-
 src/test/ref/bitmap-plot-1.log                | 108 ++---
 src/test/ref/bitmap-plot-2.asm                |  38 +-
 src/test/ref/bitmap-plot-2.log                | 114 +++---
 src/test/ref/bitmap-plot-3.asm                |   4 +-
 src/test/ref/bitmap-plot-3.log                |  12 +-
 src/test/ref/bitmap-plotter.asm               |   6 +-
 src/test/ref/bitmap-plotter.log               |  18 +-
 src/test/ref/bresenham.asm                    |   2 +-
 src/test/ref/bresenham.log                    |   6 +-
 src/test/ref/bresenhamarr.asm                 |   2 +-
 src/test/ref/bresenhamarr.log                 |   6 +-
 src/test/ref/c64dtv-8bppcharstretch.asm       |  30 +-
 src/test/ref/c64dtv-8bppcharstretch.log       |  90 ++--
 src/test/ref/c64dtv-8bppchunkystretch.asm     |  32 +-
 src/test/ref/c64dtv-8bppchunkystretch.log     |  96 ++---
 src/test/ref/c64dtv-blitter-box.asm           |  38 +-
 src/test/ref/c64dtv-blitter-box.log           | 114 +++---
 src/test/ref/c64dtv-blittermin.asm            |  40 +-
 src/test/ref/c64dtv-blittermin.log            | 120 +++---
 src/test/ref/c64dtv-color.asm                 |   8 +-
 src/test/ref/c64dtv-color.log                 |  24 +-
 src/test/ref/c64dtv-gfxexplorer.asm           | 128 +++---
 src/test/ref/c64dtv-gfxexplorer.log           | 384 +++++++++---------
 src/test/ref/c64dtv-gfxmodes.asm              |  96 ++---
 src/test/ref/c64dtv-gfxmodes.log              | 288 ++++++-------
 src/test/ref/cast-precedence-problem.asm      |   4 +-
 src/test/ref/cast-precedence-problem.log      |  12 +-
 src/test/ref/cia-timer-cyclecount.asm         |  10 +-
 src/test/ref/cia-timer-cyclecount.log         |  30 +-
 src/test/ref/cia-timer-simple.asm             |   4 +-
 src/test/ref/cia-timer-simple.log             |  12 +-
 src/test/ref/clobber-a-problem.asm            |   4 +-
 src/test/ref/clobber-a-problem.log            |  12 +-
 src/test/ref/code-after-return-1.asm          |   2 +-
 src/test/ref/code-after-return-1.log          |   6 +-
 src/test/ref/comma-decl-2.asm                 |   2 +-
 src/test/ref/comma-decl-2.log                 |   6 +-
 src/test/ref/comma-decl.asm                   |   2 +-
 src/test/ref/comma-decl.log                   |   6 +-
 src/test/ref/comma-expr-1.asm                 |   2 +-
 src/test/ref/comma-expr-1.log                 |   6 +-
 src/test/ref/comma-expr-2.asm                 |   2 +-
 src/test/ref/comma-expr-2.log                 |   6 +-
 .../ref/complex/clearscreen/clearscreen.asm   |  60 +--
 .../ref/complex/clearscreen/clearscreen.log   | 180 ++++----
 src/test/ref/complex/medusa/medusa.asm        |   4 +-
 src/test/ref/complex/medusa/medusa.log        |  12 +-
 src/test/ref/complex/prebob/grid-bobs.asm     |  32 +-
 src/test/ref/complex/prebob/grid-bobs.log     |  96 ++---
 src/test/ref/complex/prebob/vogel-bobs.asm    |  32 +-
 src/test/ref/complex/prebob/vogel-bobs.log    |  96 ++---
 src/test/ref/complex/prebob/vogel-sprites.asm |  26 +-
 src/test/ref/complex/prebob/vogel-sprites.log |  78 ++--
 .../ref/complex/splines/truetype-splines.asm  |  14 +-
 .../ref/complex/splines/truetype-splines.log  |  42 +-
 .../complex/spritescroller/spritescroller.asm |  22 +-
 .../complex/spritescroller/spritescroller.log |  66 +--
 src/test/ref/complex/tetris/test-sprites.asm  |  30 +-
 src/test/ref/complex/tetris/test-sprites.log  |  90 ++--
 src/test/ref/complex/tetris/tetris.asm        |  98 ++---
 src/test/ref/complex/tetris/tetris.log        | 294 +++++++-------
 src/test/ref/complex/xmega65/xmega65.asm      |   8 +-
 src/test/ref/complex/xmega65/xmega65.log      |  24 +-
 src/test/ref/const-declaration.asm            |   2 +-
 src/test/ref/const-declaration.log            |   6 +-
 src/test/ref/constantmin.asm                  |   4 +-
 src/test/ref/constantmin.log                  |  12 +-
 src/test/ref/constants.asm                    |   2 +-
 src/test/ref/constants.log                    |   6 +-
 src/test/ref/cordic-atan2-16-ref.asm          |   2 +-
 src/test/ref/cordic-atan2-16-ref.log          |   6 +-
 src/test/ref/cordic-atan2-16.asm              |   2 +-
 src/test/ref/cordic-atan2-16.log              |   6 +-
 src/test/ref/cordic-atan2.asm                 |   6 +-
 src/test/ref/cordic-atan2.log                 |  18 +-
 src/test/ref/danny-joystick-problem.asm       |   2 +-
 src/test/ref/danny-joystick-problem.log       |   6 +-
 src/test/ref/default-font.asm                 |   2 +-
 src/test/ref/default-font.log                 |   6 +-
 src/test/ref/double-assignment.asm            |   2 +-
 src/test/ref/double-assignment.log            |   6 +-
 src/test/ref/double-import.asm                |   2 +-
 src/test/ref/double-import.log                |   6 +-
 src/test/ref/dword.asm                        |   2 +-
 src/test/ref/dword.log                        |   6 +-
 src/test/ref/enum-7.asm                       |   2 +-
 src/test/ref/enum-7.log                       |   6 +-
 src/test/ref/enum-8.asm                       |   2 +-
 src/test/ref/enum-8.log                       |   6 +-
 src/test/ref/examples/3d/3d.asm               |  12 +-
 src/test/ref/examples/3d/3d.log               |  36 +-
 .../examples/bresenham/bitmap-bresenham.asm   |   8 +-
 .../examples/bresenham/bitmap-bresenham.log   |  24 +-
 .../ref/examples/chargen/chargen-analysis.asm |  12 +-
 .../ref/examples/chargen/chargen-analysis.log |  36 +-
 src/test/ref/examples/conio/nacht-screen.asm  |  12 +-
 src/test/ref/examples/conio/nacht-screen.log  |  36 +-
 .../eightqueens/eightqueens-recursive.asm     |   8 +-
 .../eightqueens/eightqueens-recursive.log     |  24 +-
 .../ref/examples/eightqueens/eightqueens.asm  |   8 +-
 .../ref/examples/eightqueens/eightqueens.log  |  24 +-
 src/test/ref/examples/fire/fire.asm           |  14 +-
 src/test/ref/examples/fire/fire.log           |  42 +-
 src/test/ref/examples/font-2x2/font-2x2.asm   |   8 +-
 src/test/ref/examples/font-2x2/font-2x2.log   |  24 +-
 src/test/ref/examples/irq/irq-hyperscreen.asm |  14 +-
 src/test/ref/examples/irq/irq-hyperscreen.log |  42 +-
 .../ref/examples/kernalload/kernalload.asm    |   6 +-
 .../ref/examples/kernalload/kernalload.log    |  18 +-
 .../multiplexer/simple-multiplexer.asm        |  14 +-
 .../multiplexer/simple-multiplexer.log        |  42 +-
 src/test/ref/examples/music/music.asm         |   4 +-
 src/test/ref/examples/music/music.log         |  12 +-
 src/test/ref/examples/music/music_irq.asm     |  12 +-
 src/test/ref/examples/music/music_irq.log     |  36 +-
 .../ref/examples/nmisamples/nmisamples.asm    |  12 +-
 .../ref/examples/nmisamples/nmisamples.log    |  36 +-
 .../ref/examples/plasma/plasma-unroll.asm     |  18 +-
 .../ref/examples/plasma/plasma-unroll.log     |  54 +--
 src/test/ref/examples/plasma/plasma.asm       |  18 +-
 src/test/ref/examples/plasma/plasma.log       |  54 +--
 .../ref/examples/rasterbars/raster-bars.asm   |   4 +-
 .../ref/examples/rasterbars/raster-bars.log   |  12 +-
 src/test/ref/examples/rotate/rotate.asm       |  18 +-
 src/test/ref/examples/rotate/rotate.log       |  54 +--
 src/test/ref/examples/scroll/scroll.asm       |   6 +-
 src/test/ref/examples/scroll/scroll.log       |  18 +-
 src/test/ref/examples/scrollbig/scrollbig.asm |   6 +-
 src/test/ref/examples/scrollbig/scrollbig.log |  18 +-
 .../ref/examples/scrolllogo/scrolllogo.asm    |  12 +-
 .../ref/examples/scrolllogo/scrolllogo.log    |  36 +-
 src/test/ref/examples/showlogo/showlogo.asm   |  12 +-
 src/test/ref/examples/showlogo/showlogo.log   |  36 +-
 .../ref/examples/sinplotter/sine-plotter.asm  |  22 +-
 .../ref/examples/sinplotter/sine-plotter.log  |  66 +--
 .../ref/examples/sinsprites/sinus-sprites.asm |  16 +-
 .../ref/examples/sinsprites/sinus-sprites.log |  48 +--
 src/test/ref/gfxbank.asm                      |   2 +-
 src/test/ref/gfxbank.log                      |   6 +-
 src/test/ref/importing.asm                    |   2 +-
 src/test/ref/importing.log                    |   6 +-
 src/test/ref/int-conversion.asm               |   4 +-
 src/test/ref/int-conversion.log               |  12 +-
 src/test/ref/int-literals.asm                 |   4 +-
 src/test/ref/int-literals.log                 |  12 +-
 src/test/ref/irq-hardware-clobber-jsr.asm     |  20 +-
 src/test/ref/irq-hardware-clobber-jsr.log     |  60 +--
 src/test/ref/irq-hardware-clobber.asm         |  16 +-
 src/test/ref/irq-hardware-clobber.log         |  48 +--
 src/test/ref/irq-hardware-stack.asm           |  16 +-
 src/test/ref/irq-hardware-stack.log           |  48 +--
 src/test/ref/irq-hardware.asm                 |  16 +-
 src/test/ref/irq-hardware.log                 |  48 +--
 src/test/ref/irq-idx-problem.asm              |  10 +-
 src/test/ref/irq-idx-problem.log              |  30 +-
 src/test/ref/irq-kernel-minimal.asm           |   6 +-
 src/test/ref/irq-kernel-minimal.log           |  18 +-
 src/test/ref/irq-kernel.asm                   |   8 +-
 src/test/ref/irq-kernel.log                   |  24 +-
 .../ref/irq-local-var-overlap-problem.asm     |   4 +-
 .../ref/irq-local-var-overlap-problem.log     |  12 +-
 src/test/ref/irq-raster.asm                   |   8 +-
 src/test/ref/irq-raster.log                   |  24 +-
 src/test/ref/irq-volatile-bool-problem.asm    |   4 +-
 src/test/ref/irq-volatile-bool-problem.log    |  12 +-
 src/test/ref/keyboard-glitch.asm              |   6 +-
 src/test/ref/keyboard-glitch.log              |  18 +-
 .../ref/kickasm-uses-prevent-deletion.asm     |   4 +-
 .../ref/kickasm-uses-prevent-deletion.log     |  12 +-
 src/test/ref/line-anim.asm                    |  20 +-
 src/test/ref/line-anim.log                    |  60 +--
 src/test/ref/literals.asm                     |   2 +-
 src/test/ref/literals.log                     |   6 +-
 src/test/ref/loop-memset-min.asm              |   2 +-
 src/test/ref/loop-memset-min.log              |   6 +-
 src/test/ref/memcpy-0.asm                     |   6 +-
 src/test/ref/memcpy-0.log                     |  18 +-
 .../ref/millfork-benchmarks/plasma-kc.asm     |   4 +-
 .../ref/millfork-benchmarks/plasma-kc.log     |  12 +-
 .../simple-multiplexer-irq.asm                |  20 +-
 .../simple-multiplexer-irq.log                |  60 +--
 src/test/ref/number-inference-sum.asm         |   4 +-
 src/test/ref/number-inference-sum.log         |  12 +-
 src/test/ref/plasma-center.asm                |  20 +-
 src/test/ref/plasma-center.log                |  60 +--
 src/test/ref/pointer-cast-3.asm               |   2 +-
 src/test/ref/pointer-cast-3.log               |   6 +-
 src/test/ref/pointer-cast.asm                 |   8 +-
 src/test/ref/pointer-cast.log                 |  24 +-
 src/test/ref/printf-1.asm                     |   2 +-
 src/test/ref/printf-1.log                     |   6 +-
 src/test/ref/printf-12.asm                    |   4 +-
 src/test/ref/printf-12.log                    |  12 +-
 src/test/ref/printf-13.asm                    |   2 +-
 src/test/ref/printf-13.log                    |   6 +-
 src/test/ref/printf-14.asm                    |   2 +-
 src/test/ref/printf-14.log                    |   6 +-
 src/test/ref/printf-15.asm                    |   2 +-
 src/test/ref/printf-15.log                    |   6 +-
 src/test/ref/printf-16.asm                    |   2 +-
 src/test/ref/printf-16.log                    |   6 +-
 src/test/ref/printf-2.asm                     |   4 +-
 src/test/ref/printf-2.log                     |  12 +-
 .../procedure-callingconvention-stack-0.asm   |   2 +-
 .../procedure-callingconvention-stack-0.log   |   6 +-
 .../procedure-callingconvention-stack-1.asm   |   2 +-
 .../procedure-callingconvention-stack-1.log   |   6 +-
 .../procedure-callingconvention-stack-10.asm  |   2 +-
 .../procedure-callingconvention-stack-10.log  |   6 +-
 .../procedure-callingconvention-stack-11.asm  |   2 +-
 .../procedure-callingconvention-stack-11.log  |   6 +-
 .../procedure-callingconvention-stack-12.asm  |   2 +-
 .../procedure-callingconvention-stack-12.log  |   6 +-
 .../procedure-callingconvention-stack-13.asm  |   2 +-
 .../procedure-callingconvention-stack-13.log  |   6 +-
 .../procedure-callingconvention-stack-2.asm   |   2 +-
 .../procedure-callingconvention-stack-2.log   |   6 +-
 .../procedure-callingconvention-stack-3.asm   |   2 +-
 .../procedure-callingconvention-stack-3.log   |   6 +-
 .../procedure-callingconvention-stack-4.asm   |   2 +-
 .../procedure-callingconvention-stack-4.log   |   6 +-
 .../procedure-callingconvention-stack-5.asm   |   2 +-
 .../procedure-callingconvention-stack-5.log   |   6 +-
 src/test/ref/processor-port-test.asm          |   8 +-
 src/test/ref/processor-port-test.log          |  24 +-
 src/test/ref/scan-desire-problem.asm          |  14 +-
 src/test/ref/scan-desire-problem.log          |  42 +-
 src/test/ref/screen-center-angle.asm          |  18 +-
 src/test/ref/screen-center-angle.log          |  54 +--
 src/test/ref/screen-center-distance.asm       |  18 +-
 src/test/ref/screen-center-distance.log       |  54 +--
 src/test/ref/screen-show-spiral-buckets.asm   |  16 +-
 src/test/ref/screen-show-spiral-buckets.log   |  48 +--
 src/test/ref/screen-show-spiral.asm           |   8 +-
 src/test/ref/screen-show-spiral.log           |  24 +-
 src/test/ref/semi-struct-2.asm                |   4 +-
 src/test/ref/semi-struct-2.log                |  12 +-
 src/test/ref/sieve-min.asm                    |   4 +-
 src/test/ref/sieve-min.log                    |  12 +-
 src/test/ref/sieve.asm                        |  12 +-
 src/test/ref/sieve.log                        |  36 +-
 src/test/ref/signed-words.asm                 |   4 +-
 src/test/ref/signed-words.log                 |  12 +-
 src/test/ref/sinusgenscale8.asm               |   2 +-
 src/test/ref/sinusgenscale8.log               |   6 +-
 src/test/ref/sizeof-arrays.asm                |   2 +-
 src/test/ref/sizeof-arrays.log                |   6 +-
 src/test/ref/sizeof-expr.asm                  |   2 +-
 src/test/ref/sizeof-expr.log                  |   6 +-
 src/test/ref/sizeof-in-const-pointer.asm      |  14 +
 src/test/ref/sizeof-in-const-pointer.cfg      |  17 +
 src/test/ref/sizeof-in-const-pointer.log      | 232 +++++++++++
 src/test/ref/sizeof-in-const-pointer.sym      |   8 +
 src/test/ref/sizeof-struct.asm                |   2 +-
 src/test/ref/sizeof-struct.log                |   6 +-
 src/test/ref/sizeof-types.asm                 |   2 +-
 src/test/ref/sizeof-types.log                 |   6 +-
 src/test/ref/string-escapes-5.asm             |   2 +-
 src/test/ref/string-escapes-5.log             |   6 +-
 src/test/ref/struct-11.asm                    |   2 +-
 src/test/ref/struct-11.log                    |   6 +-
 src/test/ref/struct-13.asm                    |   2 +-
 src/test/ref/struct-13.log                    |   6 +-
 src/test/ref/struct-14.asm                    |   2 +-
 src/test/ref/struct-14.log                    |   6 +-
 src/test/ref/struct-15.asm                    |   2 +-
 src/test/ref/struct-15.log                    |   6 +-
 src/test/ref/struct-16.asm                    |   2 +-
 src/test/ref/struct-16.log                    |   6 +-
 src/test/ref/struct-17.asm                    |   2 +-
 src/test/ref/struct-17.log                    |   6 +-
 src/test/ref/struct-18.asm                    |   2 +-
 src/test/ref/struct-18.log                    |   6 +-
 src/test/ref/struct-19.asm                    |   2 +-
 src/test/ref/struct-19.log                    |   6 +-
 src/test/ref/struct-20.asm                    |   2 +-
 src/test/ref/struct-20.log                    |   6 +-
 src/test/ref/struct-21.asm                    |   2 +-
 src/test/ref/struct-21.log                    |   6 +-
 src/test/ref/struct-22.asm                    |   2 +-
 src/test/ref/struct-22.log                    |   6 +-
 src/test/ref/struct-23.asm                    |   2 +-
 src/test/ref/struct-23.log                    |   6 +-
 src/test/ref/struct-24.asm                    |   2 +-
 src/test/ref/struct-24.log                    |   6 +-
 src/test/ref/struct-25.asm                    |   2 +-
 src/test/ref/struct-25.log                    |   6 +-
 src/test/ref/struct-26.asm                    |   2 +-
 src/test/ref/struct-26.log                    |   6 +-
 src/test/ref/struct-27.asm                    |   2 +-
 src/test/ref/struct-27.log                    |   6 +-
 src/test/ref/struct-28.asm                    |   2 +-
 src/test/ref/struct-28.log                    |   6 +-
 src/test/ref/struct-29.asm                    |   2 +-
 src/test/ref/struct-29.log                    |   6 +-
 src/test/ref/struct-32.asm                    |   2 +-
 src/test/ref/struct-32.log                    |   6 +-
 src/test/ref/struct-33.asm                    |   2 +-
 src/test/ref/struct-33.log                    |   6 +-
 src/test/ref/struct-34.asm                    |   2 +-
 src/test/ref/struct-34.log                    |   6 +-
 src/test/ref/struct-35.asm                    |   2 +-
 src/test/ref/struct-35.log                    |   6 +-
 src/test/ref/struct-36.asm                    |   2 +-
 src/test/ref/struct-36.log                    |   6 +-
 src/test/ref/struct-37.asm                    |   2 +-
 src/test/ref/struct-37.log                    |   6 +-
 src/test/ref/struct-38.asm                    |   2 +-
 src/test/ref/struct-38.log                    |   6 +-
 src/test/ref/struct-39.asm                    |   2 +-
 src/test/ref/struct-39.log                    |   6 +-
 src/test/ref/struct-4.asm                     |   2 +-
 src/test/ref/struct-4.log                     |   6 +-
 src/test/ref/struct-41.asm                    |   2 +-
 src/test/ref/struct-41.log                    |   6 +-
 src/test/ref/struct-42.asm                    |   2 +-
 src/test/ref/struct-42.log                    |   6 +-
 src/test/ref/struct-6.asm                     |   2 +-
 src/test/ref/struct-6.log                     |   6 +-
 src/test/ref/struct-7.asm                     |   2 +-
 src/test/ref/struct-7.log                     |   6 +-
 src/test/ref/struct-8.asm                     |   2 +-
 src/test/ref/struct-8.log                     |   6 +-
 src/test/ref/struct-9.asm                     |   2 +-
 src/test/ref/struct-9.log                     |   6 +-
 src/test/ref/struct-pointer-to-member.asm     |  19 +
 src/test/ref/struct-pointer-to-member.cfg     |  18 +
 src/test/ref/struct-pointer-to-member.log     | 274 +++++++++++++
 src/test/ref/struct-pointer-to-member.sym     |  14 +
 src/test/ref/struct-ptr-16.asm                |   2 +-
 src/test/ref/struct-ptr-16.log                |   6 +-
 src/test/ref/struct-ptr-17.asm                |   2 +-
 src/test/ref/struct-ptr-17.log                |   6 +-
 src/test/ref/struct-ptr-18.asm                |   2 +-
 src/test/ref/struct-ptr-18.log                |   6 +-
 src/test/ref/struct-ptr-19.asm                |   2 +-
 src/test/ref/struct-ptr-19.log                |   6 +-
 src/test/ref/struct-ptr-20.asm                |   2 +-
 src/test/ref/struct-ptr-20.log                |   6 +-
 src/test/ref/struct-ptr-21.asm                |   2 +-
 src/test/ref/struct-ptr-21.log                |   6 +-
 src/test/ref/struct-ptr-23.asm                |   2 +-
 src/test/ref/struct-ptr-23.log                |   6 +-
 src/test/ref/struct-ptr-28.asm                |   2 +-
 src/test/ref/struct-ptr-28.log                |   6 +-
 src/test/ref/struct-ptr-30.asm                |   2 +-
 src/test/ref/struct-ptr-30.log                |   6 +-
 src/test/ref/struct-ptr-31.asm                |   2 +-
 src/test/ref/struct-ptr-31.log                |   6 +-
 src/test/ref/switch-2.asm                     |   2 +-
 src/test/ref/switch-2.log                     |   6 +-
 src/test/ref/test-comments-block.asm          |   4 +-
 src/test/ref/test-comments-block.log          |  12 +-
 src/test/ref/test-comments-single.asm         |   4 +-
 src/test/ref/test-comments-single.log         |  12 +-
 src/test/ref/test-keyboard-space.asm          |   8 +-
 src/test/ref/test-keyboard-space.log          |  24 +-
 src/test/ref/test-keyboard.asm                |   6 +-
 src/test/ref/test-keyboard.log                |  18 +-
 src/test/ref/tetris-npe.asm                   |   2 +-
 src/test/ref/tetris-npe.log                   |   6 +-
 src/test/ref/tod-1.asm                        |  12 +-
 src/test/ref/tod-1.log                        |  36 +-
 src/test/ref/tod018-problem.asm               |   2 +-
 src/test/ref/tod018-problem.log               |   6 +-
 src/test/ref/toupper-1.asm                    |   8 +-
 src/test/ref/toupper-1.log                    |  24 +-
 src/test/ref/true-inline-words.asm            |   4 +-
 src/test/ref/true-inline-words.log            |  12 +-
 src/test/ref/typedef-1.asm                    |   2 +-
 src/test/ref/typedef-1.log                    |   6 +-
 src/test/ref/typedef-4.asm                    |   2 +-
 src/test/ref/typedef-4.log                    |   6 +-
 src/test/ref/typeid-plus-bytes.asm            |   4 +-
 src/test/ref/typeid-plus-bytes.log            |  12 +-
 src/test/ref/unary-plus.asm                   |   4 +-
 src/test/ref/unary-plus.log                   |  12 +-
 src/test/ref/uninitialized.asm                |   2 +-
 src/test/ref/uninitialized.log                |   6 +-
 src/test/ref/var-forward-problem.asm          |   2 +-
 src/test/ref/var-forward-problem.log          |   6 +-
 src/test/ref/var-forward-problem2.asm         |   2 +-
 src/test/ref/var-forward-problem2.log         |   6 +-
 src/test/ref/voronoi.asm                      |   4 +-
 src/test/ref/voronoi.log                      |  12 +-
 src/test/ref/word-pointer-math-1.asm          |   2 +-
 src/test/ref/word-pointer-math-1.log          |   6 +-
 411 files changed, 4148 insertions(+), 3493 deletions(-)
 create mode 100644 src/test/kc/sizeof-in-const-pointer.c
 create mode 100644 src/test/kc/struct-pointer-to-member.c
 create mode 100644 src/test/ref/sizeof-in-const-pointer.asm
 create mode 100644 src/test/ref/sizeof-in-const-pointer.cfg
 create mode 100644 src/test/ref/sizeof-in-const-pointer.log
 create mode 100644 src/test/ref/sizeof-in-const-pointer.sym
 create mode 100644 src/test/ref/struct-pointer-to-member.asm
 create mode 100644 src/test/ref/struct-pointer-to-member.cfg
 create mode 100644 src/test/ref/struct-pointer-to-member.log
 create mode 100644 src/test/ref/struct-pointer-to-member.sym

diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java
index 9a0b37ecf..933f52905 100644
--- a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java
+++ b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java
@@ -8,10 +8,7 @@ import dk.camelot64.kickc.model.*;
 import dk.camelot64.kickc.model.operators.*;
 import dk.camelot64.kickc.model.statements.*;
 import dk.camelot64.kickc.model.symbols.*;
-import dk.camelot64.kickc.model.types.SymbolType;
-import dk.camelot64.kickc.model.types.SymbolTypeConversion;
-import dk.camelot64.kickc.model.types.SymbolTypePointer;
-import dk.camelot64.kickc.model.types.SymbolTypeProcedure;
+import dk.camelot64.kickc.model.types.*;
 import dk.camelot64.kickc.model.values.*;
 import dk.camelot64.kickc.parser.CParser;
 import dk.camelot64.kickc.parser.KickCParser;
@@ -2328,6 +2325,15 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
       } else if(operator.equals(Operators.ADDRESS_OF) && child instanceof PointerDereferenceIndexed && ((PointerDereferenceIndexed) child).getPointer() instanceof ConstantValue && ((PointerDereferenceIndexed) child).getIndex() instanceof ConstantValue) {
          PointerDereferenceIndexed pointerDeref = (PointerDereferenceIndexed) child;
          return new ConstantBinary((ConstantValue) pointerDeref.getPointer(), Operators.PLUS, (ConstantValue) pointerDeref.getIndex());
+      } else if(operator.equals(Operators.ADDRESS_OF) && child instanceof StructMemberRef && ((StructMemberRef) child).getStruct() instanceof PointerDereferenceSimple && ((PointerDereferenceSimple) ((StructMemberRef) child).getStruct()).getPointer() instanceof ConstantValue) {
+         final ConstantValue structPointer = (ConstantValue) ((PointerDereferenceSimple) ((StructMemberRef) child).getStruct()).getPointer();
+         final RValue structValue  = ((StructMemberRef) child).getStruct();
+         final SymbolTypeStruct structType = (SymbolTypeStruct) SymbolTypeInference.inferType(program.getScope(), structValue);
+         StructDefinition structDefinition = structType.getStructDefinition(program.getScope());
+         final String memberName = ((StructMemberRef) child).getMemberName();
+         final ConstantRef memberOffset = SizeOfConstants.getStructMemberOffsetConstant(program.getScope(), structDefinition, memberName);
+         final SymbolType memberType = structDefinition.getMember(memberName).getType();
+         return new ConstantCastValue(new SymbolTypePointer(memberType), new ConstantBinary(new ConstantCastValue(new SymbolTypePointer(SymbolType.BYTE), structPointer), Operators.PLUS, memberOffset));
       } else if(child instanceof ConstantValue) {
          return new ConstantUnary((OperatorUnary) operator, (ConstantValue) child);
       } else {
diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java
index db27cd8a7..85e4216f0 100644
--- a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java
+++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java
@@ -410,33 +410,50 @@ public class Pass4CodeGeneration {
       Set<String> added = new LinkedHashSet<>();
       Collection<Variable> scopeConstants = scope.getAllConstants(false);
 
-      // Add all constants without data
+      // First add all constants without data that can become constants in KickAsm
+      for(Variable constantVar : scopeConstants) {
+         if(!hasData(constantVar)) {
+            String asmName = constantVar.getAsmName() == null ? constantVar.getLocalName() : constantVar.getAsmName();
+            if(asmName != null && !added.contains(asmName)) {
+               if(SymbolType.isInteger(constantVar.getType()) && constantVar.getRef().getScopeDepth() > 0) {
+                  // Use label for integers referenced in other scope - to allow cross-scope referencing
+                  if(!useLabelForConst(scopeRef, constantVar)) {
+                     // Use constant for constant integers not referenced outside scope
+                     added.add(asmName);
+                     // Find the constant value calculation
+                     String asmConstant = AsmFormat.getAsmConstant(program, constantVar.getInitValue(), 99, scopeRef);
+                     addConstant(asmName, constantVar, asmConstant, asm);
+                  }
+               } else if(!(constantVar.getType() instanceof SymbolTypePointer)) {
+                  // Use constant otherwise
+                  added.add(asmName);
+                  // Find the constant value calculation
+                  String asmConstant = AsmFormat.getAsmConstant(program, constantVar.getInitValue(), 99, scopeRef);
+                  addConstant(asmName, constantVar, asmConstant, asm);
+               }
+            }
+         }
+      }
+
+      // Add constants without data that must be labels in KickAsm
       for(Variable constantVar : scopeConstants) {
          if(!hasData(constantVar)) {
             String asmName = constantVar.getAsmName() == null ? constantVar.getLocalName() : constantVar.getAsmName();
             if(asmName != null && !added.contains(asmName)) {
-               added.add(asmName);
-               // Add any comments
-               generateComments(asm, constantVar.getComments());
-               // Ensure encoding is good
-               ensureEncoding(asm, constantVar.getInitValue());
-               // Find the constant value calculation
-               String asmConstant = AsmFormat.getAsmConstant(program, constantVar.getInitValue(), 99, scopeRef);
                if(constantVar.getType() instanceof SymbolTypePointer) {
                   // Must use a label for pointers
-                  asm.addLabelDecl(AsmFormat.asmFix(asmName), asmConstant);
+                  added.add(asmName);
+                  String asmConstant = AsmFormat.getAsmConstant(program, constantVar.getInitValue(), 99, scopeRef);
+                  addConstantLabelDecl(asmName, constantVar, asmConstant, asm);
                } else if(SymbolType.isInteger(constantVar.getType()) && constantVar.getRef().getScopeDepth() > 0) {
                   // Use label for integers referenced in other scope - to allow cross-scope referencing
                   if(useLabelForConst(scopeRef, constantVar)) {
                      // Use label for integers referenced in other scope - to allow cross-scope referencing
-                     asm.addLabelDecl(AsmFormat.asmFix(asmName), asmConstant);
-                  } else {
-                     // Use constant for constant integers not referenced outside scope
-                     asm.addConstant(AsmFormat.asmFix(asmName), asmConstant);
+                     added.add(asmName);
+                     // Add any comments
+                     String asmConstant = AsmFormat.getAsmConstant(program, constantVar.getInitValue(), 99, scopeRef);
+                     addConstantLabelDecl(asmName, constantVar, asmConstant, asm);
                   }
-               } else {
-                  // Use constant otherwise
-                  asm.addConstant(AsmFormat.asmFix(asmName), asmConstant);
                }
             }
          }
@@ -451,25 +468,38 @@ public class Pass4CodeGeneration {
                Registers.RegisterZpMem registerZp = (Registers.RegisterZpMem) register;
                String asmName = scopeVar.getAsmName();
                if(asmName != null && !added.contains(asmName)) {
-                  // Add any comments
-                  generateComments(asm, scopeVar.getComments());
-                  // Add the label declaration
-                  asm.addLabelDecl(AsmFormat.asmFix(asmName), AsmFormat.getAsmNumber(registerZp.getZp()));
                   added.add(asmName);
+                  addConstantLabelDecl(asmName, scopeVar, AsmFormat.getAsmNumber(registerZp.getZp()), asm);
                }
             } else if(Registers.RegisterType.MAIN_MEM.equals(register.getType()) && ((Registers.RegisterMainMem) register).getAddress() != null) {
                String asmName = scopeVar.getAsmName();
                if(asmName != null && !added.contains(asmName)) {
-                  // Add any comments
-                  generateComments(asm, scopeVar.getComments());
+                  added.add(asmName);
                   // Add the label declaration
                   Long address = ((Registers.RegisterMainMem) register).getAddress();
-                  asm.addLabelDecl(AsmFormat.asmFix(asmName), AsmFormat.getAsmNumber(address));
-                  added.add(asmName);
+                  addConstantLabelDecl(asmName, scopeVar, AsmFormat.getAsmNumber(address), asm);
                }
             }
          }
       }
+
+   }
+
+   private void addConstant(String asmName, Variable constantVar, String asmConstant, AsmProgram asm) {
+      // Add any comments
+      generateComments(asm, constantVar.getComments());
+      // Ensure encoding is good
+      ensureEncoding(asm, constantVar.getInitValue());
+      asm.addConstant(AsmFormat.asmFix(asmName), asmConstant);
+   }
+
+   private void addConstantLabelDecl(String asmName, Variable variable, String asmConstant, AsmProgram asm) {
+      // Add any comments
+      generateComments(asm, variable.getComments());
+      // Ensure encoding is good
+      ensureEncoding(asm, variable.getInitValue());
+      // Find the constant value calculation
+      asm.addLabelDecl(AsmFormat.asmFix(asmName), asmConstant);
    }
 
    /**
@@ -662,23 +692,6 @@ public class Pass4CodeGeneration {
                dataChunk.addDataNumeric(AsmDataNumeric.Type.BYTE, "0", null);
             }
             dataNumElements = stringValue.getStringLength();
-            
-            /*
-            try {
-               ConstantLiteral literal = value.calculateLiteral(getScope());
-               if(literal instanceof ConstantString) {
-                  // Ensure encoding is good
-                  String asmConstant = AsmFormat.getAsmConstant(program, literal, 99, scopeRef);
-                  dataChunk.addDataString(asmConstant, getEncoding(literal));
-                  if(((ConstantString) literal).isZeroTerminated()) {
-                     dataChunk.addDataNumeric(AsmDataNumeric.Type.BYTE, "0", null);
-                  }
-                  dataNumElements = ((ConstantString) literal).getStringLength();
-               }
-            } catch(ConstantNotLiteral e) {
-               // can't calculate literal value, so it is not data - just return
-            }
-             */
          } else {
             // Assume we have a ConstantArrayList
             ConstantArrayList constantArrayList = (ConstantArrayList) value;
diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java
index cf068b11a..b44478aad 100644
--- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java
+++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java
@@ -40,6 +40,16 @@ public class TestPrograms {
    public TestPrograms() {
    }
 
+   @Test
+   public void testStructPointerToMember() throws IOException, URISyntaxException {
+      compileAndCompare("struct-pointer-to-member.c", log());
+   }
+
+   @Test
+   public void testSizeOfInConstPointer() throws IOException, URISyntaxException {
+      compileAndCompare("sizeof-in-const-pointer.c");
+   }
+
    @Test
    public void testTod1() throws IOException, URISyntaxException {
       compileAndCompare("tod-1.c");
diff --git a/src/test/kc/sizeof-in-const-pointer.c b/src/test/kc/sizeof-in-const-pointer.c
new file mode 100644
index 000000000..b81a63a84
--- /dev/null
+++ b/src/test/kc/sizeof-in-const-pointer.c
@@ -0,0 +1,7 @@
+// Support for sizeof() in const pointer definition
+
+// Commodore 64 processor port
+char * const SCREEN = 0x0400 +sizeof(char)*100;
+void main() {
+    SCREEN[0] = 'a';
+}
\ No newline at end of file
diff --git a/src/test/kc/struct-pointer-to-member.c b/src/test/kc/struct-pointer-to-member.c
new file mode 100644
index 000000000..dc0f3d995
--- /dev/null
+++ b/src/test/kc/struct-pointer-to-member.c
@@ -0,0 +1,23 @@
+// Support for pointer to struct member
+
+// Commodore 64 screen colors
+struct SCREEN_COLORS {
+    char BORDER;
+    char BG0;
+    char BG1;
+    char BG2;
+    char BG3;
+};
+
+// Commodore 64 processor port
+struct SCREEN_COLORS* const COLORS = 0xd020;
+
+// The border color
+char * const BORDERCOL = &COLORS->BORDER;
+// The background color
+char * const BGCOL = &COLORS->BG0;
+
+void main() {
+    COLORS->BORDER = 0;
+    *BGCOL = 6;
+}
\ No newline at end of file
diff --git a/src/test/ref/address-of-3.asm b/src/test/ref/address-of-3.asm
index 4c8aac328..1921c8dc6 100644
--- a/src/test/ref/address-of-3.asm
+++ b/src/test/ref/address-of-3.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_SIGNED_WORD = 2
+  .label SCREEN = $400
   .label idx = 3
 main: {
     .label i = 2
diff --git a/src/test/ref/address-of-3.log b/src/test/ref/address-of-3.log
index 5e7a46e71..c7b13fd8e 100644
--- a/src/test/ref/address-of-3.log
+++ b/src/test/ref/address-of-3.log
@@ -294,8 +294,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_SIGNED_WORD = 2
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
@@ -457,8 +457,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_SIGNED_WORD = 2
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
@@ -653,8 +653,8 @@ Score: 457
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_SIGNED_WORD = 2
+  .label SCREEN = $400
   .label idx = 3
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/assignment-compound.asm b/src/test/ref/assignment-compound.asm
index 2873d2702..fa501dff2 100644
--- a/src/test/ref/assignment-compound.asm
+++ b/src/test/ref/assignment-compound.asm
@@ -2,10 +2,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label screen1 = $400
-  .label cols = $d800
   .const GREEN = 5
   .const RED = 2
+  .label screen1 = $400
+  .label cols = $d800
   .label screen2 = screen1+$28
 main: {
     // test(i++, a)
diff --git a/src/test/ref/assignment-compound.log b/src/test/ref/assignment-compound.log
index d87ffa9a0..1ae3a74cc 100644
--- a/src/test/ref/assignment-compound.log
+++ b/src/test/ref/assignment-compound.log
@@ -699,10 +699,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen1 = $400
-  .label cols = $d800
   .const GREEN = 5
   .const RED = 2
+  .label screen1 = $400
+  .label cols = $d800
   .label screen2 = screen1+$28
   // @begin
 __bbegin:
@@ -974,10 +974,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen1 = $400
-  .label cols = $d800
   .const GREEN = 5
   .const RED = 2
+  .label screen1 = $400
+  .label cols = $d800
   .label screen2 = screen1+$28
   // @begin
 __bbegin:
@@ -1312,10 +1312,10 @@ Score: 202
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen1 = $400
-  .label cols = $d800
   .const GREEN = 5
   .const RED = 2
+  .label screen1 = $400
+  .label cols = $d800
   .label screen2 = screen1+$28
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/atoi-1.asm b/src/test/ref/atoi-1.asm
index 6481526ad..1d07de020 100644
--- a/src/test/ref/atoi-1.asm
+++ b/src/test/ref/atoi-1.asm
@@ -208,9 +208,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 5
diff --git a/src/test/ref/atoi-1.log b/src/test/ref/atoi-1.log
index da5e0ab04..dda5aedc0 100644
--- a/src/test/ref/atoi-1.log
+++ b/src/test/ref/atoi-1.log
@@ -3665,9 +3665,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $d
     .label src = $b
@@ -4869,9 +4869,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 5
@@ -6157,9 +6157,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 5
diff --git a/src/test/ref/bgblack.asm b/src/test/ref/bgblack.asm
index 8bcec5ce9..b0eb92dcc 100644
--- a/src/test/ref/bgblack.asm
+++ b/src/test/ref/bgblack.asm
@@ -1,8 +1,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BGCOL = $d021
   .const BLACK = 0
+  .label BGCOL = $d021
 main: {
     // *BGCOL = BLACK
     lda #BLACK
diff --git a/src/test/ref/bgblack.log b/src/test/ref/bgblack.log
index 2ce4a3b58..2928ea021 100644
--- a/src/test/ref/bgblack.log
+++ b/src/test/ref/bgblack.log
@@ -77,8 +77,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const BLACK = 0
+  .label BGCOL = $d021
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -123,8 +123,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const BLACK = 0
+  .label BGCOL = $d021
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -190,8 +190,8 @@ Score: 12
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const BLACK = 0
+  .label BGCOL = $d021
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/bitmap-circle-2.asm b/src/test/ref/bitmap-circle-2.asm
index 12424d2ab..5787e4c85 100644
--- a/src/test/ref/bitmap-circle-2.asm
+++ b/src/test/ref/bitmap-circle-2.asm
@@ -1,13 +1,13 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const BLUE = 6
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
 main: {
diff --git a/src/test/ref/bitmap-circle-2.log b/src/test/ref/bitmap-circle-2.log
index e0fa11815..0a5d6ebb4 100644
--- a/src/test/ref/bitmap-circle-2.log
+++ b/src/test/ref/bitmap-circle-2.log
@@ -1301,13 +1301,13 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const BLUE = 6
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   // @begin
@@ -2181,13 +2181,13 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const BLUE = 6
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   // @begin
@@ -3167,13 +3167,13 @@ Score: 51752
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const BLUE = 6
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   // @begin
diff --git a/src/test/ref/bitmap-circle.asm b/src/test/ref/bitmap-circle.asm
index f00a2e940..9c5d003ef 100644
--- a/src/test/ref/bitmap-circle.asm
+++ b/src/test/ref/bitmap-circle.asm
@@ -4,13 +4,13 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const BLUE = 6
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
 main: {
diff --git a/src/test/ref/bitmap-circle.log b/src/test/ref/bitmap-circle.log
index ff6a8f6a9..929afae2d 100644
--- a/src/test/ref/bitmap-circle.log
+++ b/src/test/ref/bitmap-circle.log
@@ -1198,13 +1198,13 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const BLUE = 6
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   // @begin
@@ -1975,13 +1975,13 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const BLUE = 6
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   // @begin
@@ -2851,13 +2851,13 @@ Score: 6073
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const BLUE = 6
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   // @begin
diff --git a/src/test/ref/bitmap-line-anim-1.asm b/src/test/ref/bitmap-line-anim-1.asm
index 4ad75faad..61f97c422 100644
--- a/src/test/ref/bitmap-line-anim-1.asm
+++ b/src/test/ref/bitmap-line-anim-1.asm
@@ -3,12 +3,12 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label D011 = $d011
   .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
diff --git a/src/test/ref/bitmap-line-anim-1.log b/src/test/ref/bitmap-line-anim-1.log
index 7d1febb99..d9addf704 100644
--- a/src/test/ref/bitmap-line-anim-1.log
+++ b/src/test/ref/bitmap-line-anim-1.log
@@ -2572,12 +2572,12 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label D011 = $d011
   .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
@@ -3701,12 +3701,12 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label D011 = $d011
   .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
@@ -4954,12 +4954,12 @@ Score: 30221
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label D011 = $d011
   .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
diff --git a/src/test/ref/bitmap-line-anim-2.asm b/src/test/ref/bitmap-line-anim-2.asm
index b4ec99a78..a438c5d30 100644
--- a/src/test/ref/bitmap-line-anim-2.asm
+++ b/src/test/ref/bitmap-line-anim-2.asm
@@ -3,15 +3,15 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const WHITE = 1
   .const PURPLE = 4
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   .label next = 2
diff --git a/src/test/ref/bitmap-line-anim-2.log b/src/test/ref/bitmap-line-anim-2.log
index 2d8e26180..171dffff6 100644
--- a/src/test/ref/bitmap-line-anim-2.log
+++ b/src/test/ref/bitmap-line-anim-2.log
@@ -2289,15 +2289,15 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const WHITE = 1
   .const PURPLE = 4
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   .label next = 2
@@ -3399,15 +3399,15 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const WHITE = 1
   .const PURPLE = 4
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   .label next = 2
@@ -4679,15 +4679,15 @@ Score: 30186
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_MEMORY = $d018
   .const WHITE = 1
   .const PURPLE = 4
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label D011 = $d011
+  .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BITMAP = $2000
   .label next = 2
diff --git a/src/test/ref/bitmap-plot-0.asm b/src/test/ref/bitmap-plot-0.asm
index f808af4d0..236734b49 100644
--- a/src/test/ref/bitmap-plot-0.asm
+++ b/src/test/ref/bitmap-plot-0.asm
@@ -5,36 +5,36 @@
 .pc = $80d "Program"
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const VIC_BMM = $20
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label BGCOL = $d021
   .label VIC_CONTROL = $d011
   .label D011 = $d011
-  .const VIC_BMM = $20
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   .label D018 = $d018
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = 8
diff --git a/src/test/ref/bitmap-plot-0.log b/src/test/ref/bitmap-plot-0.log
index 294e6c9b5..18ac0e246 100644
--- a/src/test/ref/bitmap-plot-0.log
+++ b/src/test/ref/bitmap-plot-0.log
@@ -1688,36 +1688,36 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const VIC_BMM = $20
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label BGCOL = $d021
   .label VIC_CONTROL = $d011
   .label D011 = $d011
-  .const VIC_BMM = $20
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   .label D018 = $d018
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $14
@@ -2462,36 +2462,36 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const VIC_BMM = $20
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label BGCOL = $d021
   .label VIC_CONTROL = $d011
   .label D011 = $d011
-  .const VIC_BMM = $20
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   .label D018 = $d018
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = 8
@@ -3377,36 +3377,36 @@ Score: 3175
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const VIC_BMM = $20
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label BGCOL = $d021
   .label VIC_CONTROL = $d011
   .label D011 = $d011
-  .const VIC_BMM = $20
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   .label D018 = $d018
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = 8
diff --git a/src/test/ref/bitmap-plot-1.asm b/src/test/ref/bitmap-plot-1.asm
index d83074b8d..1ef9d80b1 100644
--- a/src/test/ref/bitmap-plot-1.asm
+++ b/src/test/ref/bitmap-plot-1.asm
@@ -5,32 +5,15 @@
 .pc = $80d "Program"
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
-  .label RASTER = $d012
-  .label BGCOL = $d021
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -42,6 +25,23 @@
   .const PI_HALF_u4f28 = $1921fb54
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label RASTER = $d012
+  .label BGCOL = $d021
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $16
@@ -587,10 +587,10 @@ bitmap_init: {
 // wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
 // sin16s_gen2(signed word* zp($19) sintab)
 sin16s_gen2: {
-    .label wavelength = $200
     .const min = -$1001
     .const max = $1001
     .const ampl = max-min
+    .label wavelength = $200
     .label __6 = 8
     .label __8 = $24
     .label step = $20
diff --git a/src/test/ref/bitmap-plot-1.log b/src/test/ref/bitmap-plot-1.log
index 99cff0999..aba50f5a4 100644
--- a/src/test/ref/bitmap-plot-1.log
+++ b/src/test/ref/bitmap-plot-1.log
@@ -3822,32 +3822,15 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
-  .label RASTER = $d012
-  .label BGCOL = $d021
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -3859,6 +3842,23 @@ Target platform is c64basic / MOS6502X
   .const PI_HALF_u4f28 = $1921fb54
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label RASTER = $d012
+  .label BGCOL = $d021
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $41
@@ -4808,10 +4808,10 @@ bitmap_init: {
 // wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
 // sin16s_gen2(signed word* zp($2c) sintab)
 sin16s_gen2: {
-    .label wavelength = $200
     .const min = -$1001
     .const max = $1001
     .const ampl = max-min
+    .label wavelength = $200
     .label __6 = $9d
     .label __8 = $a1
     .label step = $93
@@ -6183,32 +6183,15 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
-  .label RASTER = $d012
-  .label BGCOL = $d021
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -6220,6 +6203,23 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const PI_HALF_u4f28 = $1921fb54
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label RASTER = $d012
+  .label BGCOL = $d021
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $16
@@ -7035,10 +7035,10 @@ bitmap_init: {
 // wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
 // sin16s_gen2(signed word* zp($19) sintab)
 sin16s_gen2: {
-    .label wavelength = $200
     .const min = -$1001
     .const max = $1001
     .const ampl = max-min
+    .label wavelength = $200
     .label __6 = 8
     .label __8 = $24
     .label step = $20
@@ -8488,32 +8488,15 @@ Score: 20648
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
-  .label RASTER = $d012
-  .label BGCOL = $d021
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -8525,6 +8508,23 @@ Score: 20648
   .const PI_HALF_u4f28 = $1921fb54
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label RASTER = $d012
+  .label BGCOL = $d021
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $16
@@ -9302,10 +9302,10 @@ bitmap_init: {
 // wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
 // sin16s_gen2(signed word* zp($19) sintab)
 sin16s_gen2: {
-    .label wavelength = $200
     .const min = -$1001
     .const max = $1001
     .const ampl = max-min
+    .label wavelength = $200
     .label __6 = 8
     .label __8 = $24
     .label step = $20
diff --git a/src/test/ref/bitmap-plot-2.asm b/src/test/ref/bitmap-plot-2.asm
index 0b64389cd..5259f6fd9 100644
--- a/src/test/ref/bitmap-plot-2.asm
+++ b/src/test/ref/bitmap-plot-2.asm
@@ -5,33 +5,15 @@
 .pc = $80d "Program"
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -43,6 +25,24 @@
   .const PI_HALF_u4f28 = $1921fb54
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $1b
@@ -624,10 +624,10 @@ bitmap_init: {
 // wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
 // sin16s_gen2(signed word* zp($1c) sintab)
 sin16s_gen2: {
-    .label wavelength = $200
     .const min = -$1001
     .const max = $1001
     .const ampl = max-min
+    .label wavelength = $200
     .label __6 = $b
     .label __8 = $25
     .label step = $21
diff --git a/src/test/ref/bitmap-plot-2.log b/src/test/ref/bitmap-plot-2.log
index feb724e79..74a33c6a4 100644
--- a/src/test/ref/bitmap-plot-2.log
+++ b/src/test/ref/bitmap-plot-2.log
@@ -4028,33 +4028,15 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -4066,6 +4048,24 @@ Target platform is c64basic / MOS6502X
   .const PI_HALF_u4f28 = $1921fb54
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $44
@@ -5062,10 +5062,10 @@ bitmap_init: {
 // wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
 // sin16s_gen2(signed word* zp($2f) sintab)
 sin16s_gen2: {
-    .label wavelength = $200
     .const min = -$1001
     .const max = $1001
     .const ampl = max-min
+    .label wavelength = $200
     .label __6 = $9c
     .label __8 = $a0
     .label step = $92
@@ -6464,33 +6464,15 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -6502,6 +6484,24 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const PI_HALF_u4f28 = $1921fb54
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $1b
@@ -7376,10 +7376,10 @@ bitmap_init: {
 // wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
 // sin16s_gen2(signed word* zp($1c) sintab)
 sin16s_gen2: {
-    .label wavelength = $200
     .const min = -$1001
     .const max = $1001
     .const ampl = max-min
+    .label wavelength = $200
     .label __6 = $b
     .label __8 = $25
     .label step = $21
@@ -8860,33 +8860,15 @@ Score: 20833
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -8898,6 +8880,24 @@ Score: 20833
   .const PI_HALF_u4f28 = $1921fb54
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
   .label BITMAP = $2000
   .label SCREEN = $400
   .label frame_cnt = $1b
@@ -9730,10 +9730,10 @@ bitmap_init: {
 // wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
 // sin16s_gen2(signed word* zp($1c) sintab)
 sin16s_gen2: {
-    .label wavelength = $200
     .const min = -$1001
     .const max = $1001
     .const ampl = max-min
+    .label wavelength = $200
     .label __6 = $b
     .label __8 = $25
     .label step = $21
diff --git a/src/test/ref/bitmap-plot-3.asm b/src/test/ref/bitmap-plot-3.asm
index 98cce9be7..a636202d5 100644
--- a/src/test/ref/bitmap-plot-3.asm
+++ b/src/test/ref/bitmap-plot-3.asm
@@ -3,12 +3,12 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
   .const WHITE = 1
+  .label D011 = $d011
+  .label D018 = $d018
   .label BITMAP = $2000
   .label SCREEN = $400
   .label COSTAB = SINTAB+$40
diff --git a/src/test/ref/bitmap-plot-3.log b/src/test/ref/bitmap-plot-3.log
index 921679808..4e93820b1 100644
--- a/src/test/ref/bitmap-plot-3.log
+++ b/src/test/ref/bitmap-plot-3.log
@@ -2439,12 +2439,12 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
   .const WHITE = 1
+  .label D011 = $d011
+  .label D018 = $d018
   .label BITMAP = $2000
   .label SCREEN = $400
   .label COSTAB = SINTAB+$40
@@ -3663,12 +3663,12 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
   .const WHITE = 1
+  .label D011 = $d011
+  .label D018 = $d018
   .label BITMAP = $2000
   .label SCREEN = $400
   .label COSTAB = SINTAB+$40
@@ -4974,12 +4974,12 @@ Score: 26883
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
   .const WHITE = 1
+  .label D011 = $d011
+  .label D018 = $d018
   .label BITMAP = $2000
   .label SCREEN = $400
   .label COSTAB = SINTAB+$40
diff --git a/src/test/ref/bitmap-plotter.asm b/src/test/ref/bitmap-plotter.asm
index 7b32c3c2d..649ca949f 100644
--- a/src/test/ref/bitmap-plotter.asm
+++ b/src/test/ref/bitmap-plotter.asm
@@ -1,17 +1,17 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BITMAP = $2000
-  .label D011 = $d011
   .const BMM = $20
   .const DEN = $10
   .const RSEL = 8
+  .const plots_cnt = 8
+  .label BITMAP = $2000
+  .label D011 = $d011
   .label RASTER = $d012
   .label D018 = $d018
   .label BGCOL = $d020
   .label FGCOL = $d021
   .label SCREEN = $400
-  .const plots_cnt = 8
 main: {
     // *BGCOL = 0
     lda #0
diff --git a/src/test/ref/bitmap-plotter.log b/src/test/ref/bitmap-plotter.log
index 548473066..c502fade8 100644
--- a/src/test/ref/bitmap-plotter.log
+++ b/src/test/ref/bitmap-plotter.log
@@ -860,17 +860,17 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BITMAP = $2000
-  .label D011 = $d011
   .const BMM = $20
   .const DEN = $10
   .const RSEL = 8
+  .const plots_cnt = 8
+  .label BITMAP = $2000
+  .label D011 = $d011
   .label RASTER = $d012
   .label D018 = $d018
   .label BGCOL = $d020
   .label FGCOL = $d021
   .label SCREEN = $400
-  .const plots_cnt = 8
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1400,17 +1400,17 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BITMAP = $2000
-  .label D011 = $d011
   .const BMM = $20
   .const DEN = $10
   .const RSEL = 8
+  .const plots_cnt = 8
+  .label BITMAP = $2000
+  .label D011 = $d011
   .label RASTER = $d012
   .label D018 = $d018
   .label BGCOL = $d020
   .label FGCOL = $d021
   .label SCREEN = $400
-  .const plots_cnt = 8
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1969,17 +1969,17 @@ Score: 6531
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BITMAP = $2000
-  .label D011 = $d011
   .const BMM = $20
   .const DEN = $10
   .const RSEL = 8
+  .const plots_cnt = 8
+  .label BITMAP = $2000
+  .label D011 = $d011
   .label RASTER = $d012
   .label D018 = $d018
   .label BGCOL = $d020
   .label FGCOL = $d021
   .label SCREEN = $400
-  .const plots_cnt = 8
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/bresenham.asm b/src/test/ref/bresenham.asm
index 7f38bebfd..998100826 100644
--- a/src/test/ref/bresenham.asm
+++ b/src/test/ref/bresenham.asm
@@ -1,8 +1,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STAR = $51
+  .label SCREEN = $400
 main: {
     .const x0 = 4
     .const y0 = 4
diff --git a/src/test/ref/bresenham.log b/src/test/ref/bresenham.log
index 08d7a1252..d8c2a90af 100644
--- a/src/test/ref/bresenham.log
+++ b/src/test/ref/bresenham.log
@@ -354,8 +354,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STAR = $51
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -510,8 +510,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STAR = $51
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -701,8 +701,8 @@ Score: 926
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STAR = $51
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/bresenhamarr.asm b/src/test/ref/bresenhamarr.asm
index 44000b7c0..c8f66f36e 100644
--- a/src/test/ref/bresenhamarr.asm
+++ b/src/test/ref/bresenhamarr.asm
@@ -2,12 +2,12 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label screen = $400
     .const STAR = $51
     .const x0 = 0
     .const y0 = 0
     .const x1 = $27
     .const y1 = $18
+    .label screen = $400
     .label x = 4
     .label idx = 2
     .label y = 5
diff --git a/src/test/ref/bresenhamarr.log b/src/test/ref/bresenhamarr.log
index 0ea1bf40e..fcd702ef6 100644
--- a/src/test/ref/bresenhamarr.log
+++ b/src/test/ref/bresenhamarr.log
@@ -383,12 +383,12 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label screen = $400
     .const STAR = $51
     .const x0 = 0
     .const y0 = 0
     .const x1 = $27
     .const y1 = $18
+    .label screen = $400
     .label x = 4
     .label idx = 2
     .label e = 5
@@ -550,12 +550,12 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label screen = $400
     .const STAR = $51
     .const x0 = 0
     .const y0 = 0
     .const x1 = $27
     .const y1 = $18
+    .label screen = $400
     .label x = 4
     .label idx = 2
     .label y = 5
@@ -743,12 +743,12 @@ Score: 1111
   // @end
   // main
 main: {
-    .label screen = $400
     .const STAR = $51
     .const x0 = 0
     .const y0 = 0
     .const x1 = $27
     .const y1 = $18
+    .label screen = $400
     .label x = 4
     .label idx = 2
     .label y = 5
diff --git a/src/test/ref/c64dtv-8bppcharstretch.asm b/src/test/ref/c64dtv-8bppcharstretch.asm
index 8b29e47bd..2476f2201 100644
--- a/src/test/ref/c64dtv-8bppcharstretch.asm
+++ b/src/test/ref/c64dtv-8bppcharstretch.asm
@@ -2,39 +2,40 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_LINEAR = 1
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_BADLINE_OFF = $20
+  .const DTV_CHUNKY = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_LINEAR = 1
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_BADLINE_OFF = $20
-  .const DTV_CHUNKY = $40
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane A Counter Control
@@ -55,7 +56,6 @@
   .label SCREEN = $7c00
   // Plane with all pixels
   .label CHARSET8 = $8000
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
 main: {
     // asm
     sei
diff --git a/src/test/ref/c64dtv-8bppcharstretch.log b/src/test/ref/c64dtv-8bppcharstretch.log
index bd90c6c95..da5e087f1 100644
--- a/src/test/ref/c64dtv-8bppcharstretch.log
+++ b/src/test/ref/c64dtv-8bppcharstretch.log
@@ -1303,39 +1303,40 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_LINEAR = 1
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_BADLINE_OFF = $20
+  .const DTV_CHUNKY = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_LINEAR = 1
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_BADLINE_OFF = $20
-  .const DTV_CHUNKY = $40
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane A Counter Control
@@ -1356,7 +1357,6 @@ Target platform is c64basic / MOS6502X
   .label SCREEN = $7c00
   // Plane with all pixels
   .label CHARSET8 = $8000
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -2093,39 +2093,40 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_LINEAR = 1
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_BADLINE_OFF = $20
+  .const DTV_CHUNKY = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_LINEAR = 1
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_BADLINE_OFF = $20
-  .const DTV_CHUNKY = $40
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane A Counter Control
@@ -2146,7 +2147,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label SCREEN = $7c00
   // Plane with all pixels
   .label CHARSET8 = $8000
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -3015,39 +3015,40 @@ Score: 75375
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_LINEAR = 1
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_BADLINE_OFF = $20
+  .const DTV_CHUNKY = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_LINEAR = 1
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_BADLINE_OFF = $20
-  .const DTV_CHUNKY = $40
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane A Counter Control
@@ -3068,7 +3069,6 @@ Score: 75375
   .label SCREEN = $7c00
   // Plane with all pixels
   .label CHARSET8 = $8000
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/c64dtv-8bppchunkystretch.asm b/src/test/ref/c64dtv-8bppchunkystretch.asm
index fa32e3a90..5ff21b7d5 100644
--- a/src/test/ref/c64dtv-8bppchunkystretch.asm
+++ b/src/test/ref/c64dtv-8bppchunkystretch.asm
@@ -2,36 +2,37 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // Feature enables or disables the extra C64 DTV features
-  .label DTV_FEATURE = $d03f
   .const DTV_FEATURE_ENABLE = 1
-  // Controls the graphics modes of the C64 DTV
-  .label DTV_CONTROL = $d03c
   .const DTV_LINEAR = 1
   .const DTV_HIGHCOLOR = 4
   .const DTV_COLORRAM_OFF = $10
   .const DTV_BADLINE_OFF = $20
   .const DTV_CHUNKY = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // Feature enables or disables the extra C64 DTV features
+  .label DTV_FEATURE = $d03f
+  // Controls the graphics modes of the C64 DTV
+  .label DTV_CONTROL = $d03c
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane B Counter Control
@@ -43,7 +44,6 @@
   .label DTV_PLANEB_MODULO_HI = $d048
   // Plane with all pixels
   .label CHUNKY = $8000
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
 main: {
     // asm
     sei
diff --git a/src/test/ref/c64dtv-8bppchunkystretch.log b/src/test/ref/c64dtv-8bppchunkystretch.log
index 9e58ed34a..fd0e876da 100644
--- a/src/test/ref/c64dtv-8bppchunkystretch.log
+++ b/src/test/ref/c64dtv-8bppchunkystretch.log
@@ -898,36 +898,37 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // Feature enables or disables the extra C64 DTV features
-  .label DTV_FEATURE = $d03f
   .const DTV_FEATURE_ENABLE = 1
-  // Controls the graphics modes of the C64 DTV
-  .label DTV_CONTROL = $d03c
   .const DTV_LINEAR = 1
   .const DTV_HIGHCOLOR = 4
   .const DTV_COLORRAM_OFF = $10
   .const DTV_BADLINE_OFF = $20
   .const DTV_CHUNKY = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // Feature enables or disables the extra C64 DTV features
+  .label DTV_FEATURE = $d03f
+  // Controls the graphics modes of the C64 DTV
+  .label DTV_CONTROL = $d03c
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane B Counter Control
@@ -939,7 +940,6 @@ Target platform is c64basic / MOS6502X
   .label DTV_PLANEB_MODULO_HI = $d048
   // Plane with all pixels
   .label CHUNKY = $8000
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1460,36 +1460,37 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // Feature enables or disables the extra C64 DTV features
-  .label DTV_FEATURE = $d03f
   .const DTV_FEATURE_ENABLE = 1
-  // Controls the graphics modes of the C64 DTV
-  .label DTV_CONTROL = $d03c
   .const DTV_LINEAR = 1
   .const DTV_HIGHCOLOR = 4
   .const DTV_COLORRAM_OFF = $10
   .const DTV_BADLINE_OFF = $20
   .const DTV_CHUNKY = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // Feature enables or disables the extra C64 DTV features
+  .label DTV_FEATURE = $d03f
+  // Controls the graphics modes of the C64 DTV
+  .label DTV_CONTROL = $d03c
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane B Counter Control
@@ -1501,7 +1502,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label DTV_PLANEB_MODULO_HI = $d048
   // Plane with all pixels
   .label CHUNKY = $8000
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -2148,36 +2148,37 @@ Score: 19882
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // Feature enables or disables the extra C64 DTV features
-  .label DTV_FEATURE = $d03f
   .const DTV_FEATURE_ENABLE = 1
-  // Controls the graphics modes of the C64 DTV
-  .label DTV_CONTROL = $d03c
   .const DTV_LINEAR = 1
   .const DTV_HIGHCOLOR = 4
   .const DTV_COLORRAM_OFF = $10
   .const DTV_BADLINE_OFF = $20
   .const DTV_CHUNKY = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // Feature enables or disables the extra C64 DTV features
+  .label DTV_FEATURE = $d03f
+  // Controls the graphics modes of the C64 DTV
+  .label DTV_CONTROL = $d03c
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane B Counter Control
@@ -2189,7 +2190,6 @@ Score: 19882
   .label DTV_PLANEB_MODULO_HI = $d048
   // Plane with all pixels
   .label CHUNKY = $8000
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/c64dtv-blitter-box.asm b/src/test/ref/c64dtv-blitter-box.asm
index 322a7c1f7..e74306c0c 100644
--- a/src/test/ref/c64dtv-blitter-box.asm
+++ b/src/test/ref/c64dtv-blitter-box.asm
@@ -2,9 +2,27 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const DTV_FEATURE_ENABLE = 1
+  // Bit[0] Force Start Strobe when set
+  .const DTV_BLIT_FORCE_START = 1
+  // Bit[1] Source A Direction Positive when set
+  .const DTV_BLIT_SRCA_FWD = 2
+  // Bit[2] Source B Direction Positive when set
+  .const DTV_BLIT_SRCB_FWD = 4
+  // Bit[3] Destination Direction Positive when set
+  .const DTV_BLIT_DEST_FWD = 8
+  // No transparancy
+  // Bit[2]==Bit[1]==0: write in any case
+  .const DTV_BLIT_TRANSPARANCY_NONE = 0
+  .const DTV_BLIT_ADD = $30
+  // Bit[0] Clear Blitter IRQ
+  .const DTV_BLIT_CLEAR_IRQ = 1
+  // Bit[3] Destination Continue
+  .const DTV_BLIT_DEST_CONT = 8
+  // Bit[0] Busy when set (When reading)
+  .const DTV_BLIT_STATUS_BUSY = 1
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Blitter Source A Start
   .label DTV_BLITTER_SRCA_LO = $d320
   .label DTV_BLITTER_SRCA_MI = $d321
@@ -46,28 +64,10 @@
   .label DTV_BLITTER_LEN_HI = $d339
   // Blitter Control
   .label DTV_BLITTER_CONTROL = $d33a
-  // Bit[0] Force Start Strobe when set
-  .const DTV_BLIT_FORCE_START = 1
-  // Bit[1] Source A Direction Positive when set
-  .const DTV_BLIT_SRCA_FWD = 2
-  // Bit[2] Source B Direction Positive when set
-  .const DTV_BLIT_SRCB_FWD = 4
-  // Bit[3] Destination Direction Positive when set
-  .const DTV_BLIT_DEST_FWD = 8
   // Blitter Transparency
   .label DTV_BLITTER_TRANSPARANCY = $d33b
-  // No transparancy
-  // Bit[2]==Bit[1]==0: write in any case
-  .const DTV_BLIT_TRANSPARANCY_NONE = 0
-  .const DTV_BLIT_ADD = $30
   // Blitter Control 2
   .label DTV_BLITTER_CONTROL2 = $d33f
-  // Bit[0] Clear Blitter IRQ
-  .const DTV_BLIT_CLEAR_IRQ = 1
-  // Bit[3] Destination Continue
-  .const DTV_BLIT_DEST_CONT = 8
-  // Bit[0] Busy when set (When reading)
-  .const DTV_BLIT_STATUS_BUSY = 1
   .label SCREEN = $400
   // Controls the ALU operation
   .label DTV_BLITTER_ALU = $d33e
diff --git a/src/test/ref/c64dtv-blitter-box.log b/src/test/ref/c64dtv-blitter-box.log
index 1398bed93..ae0a33488 100644
--- a/src/test/ref/c64dtv-blitter-box.log
+++ b/src/test/ref/c64dtv-blitter-box.log
@@ -476,9 +476,27 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  // Bit[0] Force Start Strobe when set
+  .const DTV_BLIT_FORCE_START = 1
+  // Bit[1] Source A Direction Positive when set
+  .const DTV_BLIT_SRCA_FWD = 2
+  // Bit[2] Source B Direction Positive when set
+  .const DTV_BLIT_SRCB_FWD = 4
+  // Bit[3] Destination Direction Positive when set
+  .const DTV_BLIT_DEST_FWD = 8
+  // No transparancy
+  // Bit[2]==Bit[1]==0: write in any case
+  .const DTV_BLIT_TRANSPARANCY_NONE = 0
+  .const DTV_BLIT_ADD = $30
+  // Bit[0] Clear Blitter IRQ
+  .const DTV_BLIT_CLEAR_IRQ = 1
+  // Bit[3] Destination Continue
+  .const DTV_BLIT_DEST_CONT = 8
+  // Bit[0] Busy when set (When reading)
+  .const DTV_BLIT_STATUS_BUSY = 1
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Blitter Source A Start
   .label DTV_BLITTER_SRCA_LO = $d320
   .label DTV_BLITTER_SRCA_MI = $d321
@@ -520,28 +538,10 @@ Target platform is c64basic / MOS6502X
   .label DTV_BLITTER_LEN_HI = $d339
   // Blitter Control
   .label DTV_BLITTER_CONTROL = $d33a
-  // Bit[0] Force Start Strobe when set
-  .const DTV_BLIT_FORCE_START = 1
-  // Bit[1] Source A Direction Positive when set
-  .const DTV_BLIT_SRCA_FWD = 2
-  // Bit[2] Source B Direction Positive when set
-  .const DTV_BLIT_SRCB_FWD = 4
-  // Bit[3] Destination Direction Positive when set
-  .const DTV_BLIT_DEST_FWD = 8
   // Blitter Transparency
   .label DTV_BLITTER_TRANSPARANCY = $d33b
-  // No transparancy
-  // Bit[2]==Bit[1]==0: write in any case
-  .const DTV_BLIT_TRANSPARANCY_NONE = 0
-  .const DTV_BLIT_ADD = $30
   // Blitter Control 2
   .label DTV_BLITTER_CONTROL2 = $d33f
-  // Bit[0] Clear Blitter IRQ
-  .const DTV_BLIT_CLEAR_IRQ = 1
-  // Bit[3] Destination Continue
-  .const DTV_BLIT_DEST_CONT = 8
-  // Bit[0] Busy when set (When reading)
-  .const DTV_BLIT_STATUS_BUSY = 1
   .label SCREEN = $400
   // Controls the ALU operation
   .label DTV_BLITTER_ALU = $d33e
@@ -744,9 +744,27 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  // Bit[0] Force Start Strobe when set
+  .const DTV_BLIT_FORCE_START = 1
+  // Bit[1] Source A Direction Positive when set
+  .const DTV_BLIT_SRCA_FWD = 2
+  // Bit[2] Source B Direction Positive when set
+  .const DTV_BLIT_SRCB_FWD = 4
+  // Bit[3] Destination Direction Positive when set
+  .const DTV_BLIT_DEST_FWD = 8
+  // No transparancy
+  // Bit[2]==Bit[1]==0: write in any case
+  .const DTV_BLIT_TRANSPARANCY_NONE = 0
+  .const DTV_BLIT_ADD = $30
+  // Bit[0] Clear Blitter IRQ
+  .const DTV_BLIT_CLEAR_IRQ = 1
+  // Bit[3] Destination Continue
+  .const DTV_BLIT_DEST_CONT = 8
+  // Bit[0] Busy when set (When reading)
+  .const DTV_BLIT_STATUS_BUSY = 1
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Blitter Source A Start
   .label DTV_BLITTER_SRCA_LO = $d320
   .label DTV_BLITTER_SRCA_MI = $d321
@@ -788,28 +806,10 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label DTV_BLITTER_LEN_HI = $d339
   // Blitter Control
   .label DTV_BLITTER_CONTROL = $d33a
-  // Bit[0] Force Start Strobe when set
-  .const DTV_BLIT_FORCE_START = 1
-  // Bit[1] Source A Direction Positive when set
-  .const DTV_BLIT_SRCA_FWD = 2
-  // Bit[2] Source B Direction Positive when set
-  .const DTV_BLIT_SRCB_FWD = 4
-  // Bit[3] Destination Direction Positive when set
-  .const DTV_BLIT_DEST_FWD = 8
   // Blitter Transparency
   .label DTV_BLITTER_TRANSPARANCY = $d33b
-  // No transparancy
-  // Bit[2]==Bit[1]==0: write in any case
-  .const DTV_BLIT_TRANSPARANCY_NONE = 0
-  .const DTV_BLIT_ADD = $30
   // Blitter Control 2
   .label DTV_BLITTER_CONTROL2 = $d33f
-  // Bit[0] Clear Blitter IRQ
-  .const DTV_BLIT_CLEAR_IRQ = 1
-  // Bit[3] Destination Continue
-  .const DTV_BLIT_DEST_CONT = 8
-  // Bit[0] Busy when set (When reading)
-  .const DTV_BLIT_STATUS_BUSY = 1
   .label SCREEN = $400
   // Controls the ALU operation
   .label DTV_BLITTER_ALU = $d33e
@@ -1128,9 +1128,27 @@ Score: 291
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  // Bit[0] Force Start Strobe when set
+  .const DTV_BLIT_FORCE_START = 1
+  // Bit[1] Source A Direction Positive when set
+  .const DTV_BLIT_SRCA_FWD = 2
+  // Bit[2] Source B Direction Positive when set
+  .const DTV_BLIT_SRCB_FWD = 4
+  // Bit[3] Destination Direction Positive when set
+  .const DTV_BLIT_DEST_FWD = 8
+  // No transparancy
+  // Bit[2]==Bit[1]==0: write in any case
+  .const DTV_BLIT_TRANSPARANCY_NONE = 0
+  .const DTV_BLIT_ADD = $30
+  // Bit[0] Clear Blitter IRQ
+  .const DTV_BLIT_CLEAR_IRQ = 1
+  // Bit[3] Destination Continue
+  .const DTV_BLIT_DEST_CONT = 8
+  // Bit[0] Busy when set (When reading)
+  .const DTV_BLIT_STATUS_BUSY = 1
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Blitter Source A Start
   .label DTV_BLITTER_SRCA_LO = $d320
   .label DTV_BLITTER_SRCA_MI = $d321
@@ -1172,28 +1190,10 @@ Score: 291
   .label DTV_BLITTER_LEN_HI = $d339
   // Blitter Control
   .label DTV_BLITTER_CONTROL = $d33a
-  // Bit[0] Force Start Strobe when set
-  .const DTV_BLIT_FORCE_START = 1
-  // Bit[1] Source A Direction Positive when set
-  .const DTV_BLIT_SRCA_FWD = 2
-  // Bit[2] Source B Direction Positive when set
-  .const DTV_BLIT_SRCB_FWD = 4
-  // Bit[3] Destination Direction Positive when set
-  .const DTV_BLIT_DEST_FWD = 8
   // Blitter Transparency
   .label DTV_BLITTER_TRANSPARANCY = $d33b
-  // No transparancy
-  // Bit[2]==Bit[1]==0: write in any case
-  .const DTV_BLIT_TRANSPARANCY_NONE = 0
-  .const DTV_BLIT_ADD = $30
   // Blitter Control 2
   .label DTV_BLITTER_CONTROL2 = $d33f
-  // Bit[0] Clear Blitter IRQ
-  .const DTV_BLIT_CLEAR_IRQ = 1
-  // Bit[3] Destination Continue
-  .const DTV_BLIT_DEST_CONT = 8
-  // Bit[0] Busy when set (When reading)
-  .const DTV_BLIT_STATUS_BUSY = 1
   .label SCREEN = $400
   // Controls the ALU operation
   .label DTV_BLITTER_ALU = $d33e
diff --git a/src/test/ref/c64dtv-blittermin.asm b/src/test/ref/c64dtv-blittermin.asm
index b6158700f..a72bacce6 100644
--- a/src/test/ref/c64dtv-blittermin.asm
+++ b/src/test/ref/c64dtv-blittermin.asm
@@ -1,9 +1,28 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const DTV_FEATURE_ENABLE = 1
+  // Bit[0] Force Start Strobe when set
+  .const DTV_BLIT_FORCE_START = 1
+  // Bit[1] Source A Direction Positive when set
+  .const DTV_BLIT_SRCA_FWD = 2
+  // Bit[2] Source B Direction Positive when set
+  .const DTV_BLIT_SRCB_FWD = 4
+  // Bit[3] Destination Direction Positive when set
+  .const DTV_BLIT_DEST_FWD = 8
+  // No transparancy
+  // Bit[2]==Bit[1]==0: write in any case
+  .const DTV_BLIT_TRANSPARANCY_NONE = 0
+  .const DTV_BLIT_ADD = $30
+  // Bit[0] Clear Blitter IRQ
+  .const DTV_BLIT_CLEAR_IRQ = 1
+  // Bit[3] Destination Continue
+  .const DTV_BLIT_DEST_CONT = 8
+  // Bit[0] Busy when set (When reading)
+  .const DTV_BLIT_STATUS_BUSY = 1
+  .const SRCA_LEN = 9
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Blitter Source A Start
   .label DTV_BLITTER_SRCA_LO = $d320
   .label DTV_BLITTER_SRCA_MI = $d321
@@ -45,30 +64,11 @@
   .label DTV_BLITTER_LEN_HI = $d339
   // Blitter Control
   .label DTV_BLITTER_CONTROL = $d33a
-  // Bit[0] Force Start Strobe when set
-  .const DTV_BLIT_FORCE_START = 1
-  // Bit[1] Source A Direction Positive when set
-  .const DTV_BLIT_SRCA_FWD = 2
-  // Bit[2] Source B Direction Positive when set
-  .const DTV_BLIT_SRCB_FWD = 4
-  // Bit[3] Destination Direction Positive when set
-  .const DTV_BLIT_DEST_FWD = 8
   // Blitter Transparency
   .label DTV_BLITTER_TRANSPARANCY = $d33b
-  // No transparancy
-  // Bit[2]==Bit[1]==0: write in any case
-  .const DTV_BLIT_TRANSPARANCY_NONE = 0
-  .const DTV_BLIT_ADD = $30
   // Blitter Control 2
   .label DTV_BLITTER_CONTROL2 = $d33f
-  // Bit[0] Clear Blitter IRQ
-  .const DTV_BLIT_CLEAR_IRQ = 1
-  // Bit[3] Destination Continue
-  .const DTV_BLIT_DEST_CONT = 8
-  // Bit[0] Busy when set (When reading)
-  .const DTV_BLIT_STATUS_BUSY = 1
   .label SCREEN = $400
-  .const SRCA_LEN = 9
   // Controls the ALU operation
   .label DTV_BLITTER_ALU = $d33e
 main: {
diff --git a/src/test/ref/c64dtv-blittermin.log b/src/test/ref/c64dtv-blittermin.log
index 4926b211f..f3523f604 100644
--- a/src/test/ref/c64dtv-blittermin.log
+++ b/src/test/ref/c64dtv-blittermin.log
@@ -513,9 +513,28 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  // Bit[0] Force Start Strobe when set
+  .const DTV_BLIT_FORCE_START = 1
+  // Bit[1] Source A Direction Positive when set
+  .const DTV_BLIT_SRCA_FWD = 2
+  // Bit[2] Source B Direction Positive when set
+  .const DTV_BLIT_SRCB_FWD = 4
+  // Bit[3] Destination Direction Positive when set
+  .const DTV_BLIT_DEST_FWD = 8
+  // No transparancy
+  // Bit[2]==Bit[1]==0: write in any case
+  .const DTV_BLIT_TRANSPARANCY_NONE = 0
+  .const DTV_BLIT_ADD = $30
+  // Bit[0] Clear Blitter IRQ
+  .const DTV_BLIT_CLEAR_IRQ = 1
+  // Bit[3] Destination Continue
+  .const DTV_BLIT_DEST_CONT = 8
+  // Bit[0] Busy when set (When reading)
+  .const DTV_BLIT_STATUS_BUSY = 1
+  .const SRCA_LEN = 9
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Blitter Source A Start
   .label DTV_BLITTER_SRCA_LO = $d320
   .label DTV_BLITTER_SRCA_MI = $d321
@@ -557,30 +576,11 @@ Target platform is c64basic / MOS6502X
   .label DTV_BLITTER_LEN_HI = $d339
   // Blitter Control
   .label DTV_BLITTER_CONTROL = $d33a
-  // Bit[0] Force Start Strobe when set
-  .const DTV_BLIT_FORCE_START = 1
-  // Bit[1] Source A Direction Positive when set
-  .const DTV_BLIT_SRCA_FWD = 2
-  // Bit[2] Source B Direction Positive when set
-  .const DTV_BLIT_SRCB_FWD = 4
-  // Bit[3] Destination Direction Positive when set
-  .const DTV_BLIT_DEST_FWD = 8
   // Blitter Transparency
   .label DTV_BLITTER_TRANSPARANCY = $d33b
-  // No transparancy
-  // Bit[2]==Bit[1]==0: write in any case
-  .const DTV_BLIT_TRANSPARANCY_NONE = 0
-  .const DTV_BLIT_ADD = $30
   // Blitter Control 2
   .label DTV_BLITTER_CONTROL2 = $d33f
-  // Bit[0] Clear Blitter IRQ
-  .const DTV_BLIT_CLEAR_IRQ = 1
-  // Bit[3] Destination Continue
-  .const DTV_BLIT_DEST_CONT = 8
-  // Bit[0] Busy when set (When reading)
-  .const DTV_BLIT_STATUS_BUSY = 1
   .label SCREEN = $400
-  .const SRCA_LEN = 9
   // Controls the ALU operation
   .label DTV_BLITTER_ALU = $d33e
   // @begin
@@ -841,9 +841,28 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  // Bit[0] Force Start Strobe when set
+  .const DTV_BLIT_FORCE_START = 1
+  // Bit[1] Source A Direction Positive when set
+  .const DTV_BLIT_SRCA_FWD = 2
+  // Bit[2] Source B Direction Positive when set
+  .const DTV_BLIT_SRCB_FWD = 4
+  // Bit[3] Destination Direction Positive when set
+  .const DTV_BLIT_DEST_FWD = 8
+  // No transparancy
+  // Bit[2]==Bit[1]==0: write in any case
+  .const DTV_BLIT_TRANSPARANCY_NONE = 0
+  .const DTV_BLIT_ADD = $30
+  // Bit[0] Clear Blitter IRQ
+  .const DTV_BLIT_CLEAR_IRQ = 1
+  // Bit[3] Destination Continue
+  .const DTV_BLIT_DEST_CONT = 8
+  // Bit[0] Busy when set (When reading)
+  .const DTV_BLIT_STATUS_BUSY = 1
+  .const SRCA_LEN = 9
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Blitter Source A Start
   .label DTV_BLITTER_SRCA_LO = $d320
   .label DTV_BLITTER_SRCA_MI = $d321
@@ -885,30 +904,11 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label DTV_BLITTER_LEN_HI = $d339
   // Blitter Control
   .label DTV_BLITTER_CONTROL = $d33a
-  // Bit[0] Force Start Strobe when set
-  .const DTV_BLIT_FORCE_START = 1
-  // Bit[1] Source A Direction Positive when set
-  .const DTV_BLIT_SRCA_FWD = 2
-  // Bit[2] Source B Direction Positive when set
-  .const DTV_BLIT_SRCB_FWD = 4
-  // Bit[3] Destination Direction Positive when set
-  .const DTV_BLIT_DEST_FWD = 8
   // Blitter Transparency
   .label DTV_BLITTER_TRANSPARANCY = $d33b
-  // No transparancy
-  // Bit[2]==Bit[1]==0: write in any case
-  .const DTV_BLIT_TRANSPARANCY_NONE = 0
-  .const DTV_BLIT_ADD = $30
   // Blitter Control 2
   .label DTV_BLITTER_CONTROL2 = $d33f
-  // Bit[0] Clear Blitter IRQ
-  .const DTV_BLIT_CLEAR_IRQ = 1
-  // Bit[3] Destination Continue
-  .const DTV_BLIT_DEST_CONT = 8
-  // Bit[0] Busy when set (When reading)
-  .const DTV_BLIT_STATUS_BUSY = 1
   .label SCREEN = $400
-  .const SRCA_LEN = 9
   // Controls the ALU operation
   .label DTV_BLITTER_ALU = $d33e
   // @begin
@@ -1264,9 +1264,28 @@ Score: 1553
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  // Bit[0] Force Start Strobe when set
+  .const DTV_BLIT_FORCE_START = 1
+  // Bit[1] Source A Direction Positive when set
+  .const DTV_BLIT_SRCA_FWD = 2
+  // Bit[2] Source B Direction Positive when set
+  .const DTV_BLIT_SRCB_FWD = 4
+  // Bit[3] Destination Direction Positive when set
+  .const DTV_BLIT_DEST_FWD = 8
+  // No transparancy
+  // Bit[2]==Bit[1]==0: write in any case
+  .const DTV_BLIT_TRANSPARANCY_NONE = 0
+  .const DTV_BLIT_ADD = $30
+  // Bit[0] Clear Blitter IRQ
+  .const DTV_BLIT_CLEAR_IRQ = 1
+  // Bit[3] Destination Continue
+  .const DTV_BLIT_DEST_CONT = 8
+  // Bit[0] Busy when set (When reading)
+  .const DTV_BLIT_STATUS_BUSY = 1
+  .const SRCA_LEN = 9
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Blitter Source A Start
   .label DTV_BLITTER_SRCA_LO = $d320
   .label DTV_BLITTER_SRCA_MI = $d321
@@ -1308,30 +1327,11 @@ Score: 1553
   .label DTV_BLITTER_LEN_HI = $d339
   // Blitter Control
   .label DTV_BLITTER_CONTROL = $d33a
-  // Bit[0] Force Start Strobe when set
-  .const DTV_BLIT_FORCE_START = 1
-  // Bit[1] Source A Direction Positive when set
-  .const DTV_BLIT_SRCA_FWD = 2
-  // Bit[2] Source B Direction Positive when set
-  .const DTV_BLIT_SRCB_FWD = 4
-  // Bit[3] Destination Direction Positive when set
-  .const DTV_BLIT_DEST_FWD = 8
   // Blitter Transparency
   .label DTV_BLITTER_TRANSPARANCY = $d33b
-  // No transparancy
-  // Bit[2]==Bit[1]==0: write in any case
-  .const DTV_BLIT_TRANSPARANCY_NONE = 0
-  .const DTV_BLIT_ADD = $30
   // Blitter Control 2
   .label DTV_BLITTER_CONTROL2 = $d33f
-  // Bit[0] Clear Blitter IRQ
-  .const DTV_BLIT_CLEAR_IRQ = 1
-  // Bit[3] Destination Continue
-  .const DTV_BLIT_DEST_CONT = 8
-  // Bit[0] Busy when set (When reading)
-  .const DTV_BLIT_STATUS_BUSY = 1
   .label SCREEN = $400
-  .const SRCA_LEN = 9
   // Controls the ALU operation
   .label DTV_BLITTER_ALU = $d33e
   // @begin
diff --git a/src/test/ref/c64dtv-color.asm b/src/test/ref/c64dtv-color.asm
index 204cce866..67ff75942 100644
--- a/src/test/ref/c64dtv-color.asm
+++ b/src/test/ref/c64dtv-color.asm
@@ -2,16 +2,16 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_BORDER_OFF = 2
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_BADLINE_OFF = $20
   .label RASTER = $d012
   .label BGCOL = $d021
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_BORDER_OFF = 2
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_BADLINE_OFF = $20
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
 main: {
diff --git a/src/test/ref/c64dtv-color.log b/src/test/ref/c64dtv-color.log
index 10ecaa1ce..fe1fef7b6 100644
--- a/src/test/ref/c64dtv-color.log
+++ b/src/test/ref/c64dtv-color.log
@@ -392,16 +392,16 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_BORDER_OFF = 2
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_BADLINE_OFF = $20
   .label RASTER = $d012
   .label BGCOL = $d021
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_BORDER_OFF = 2
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_BADLINE_OFF = $20
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // @begin
@@ -557,16 +557,16 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_BORDER_OFF = 2
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_BADLINE_OFF = $20
   .label RASTER = $d012
   .label BGCOL = $d021
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_BORDER_OFF = 2
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_BADLINE_OFF = $20
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // @begin
@@ -832,16 +832,16 @@ Score: 10174
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_BORDER_OFF = 2
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_BADLINE_OFF = $20
   .label RASTER = $d012
   .label BGCOL = $d021
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_BORDER_OFF = 2
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_BADLINE_OFF = $20
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // @begin
diff --git a/src/test/ref/c64dtv-gfxexplorer.asm b/src/test/ref/c64dtv-gfxexplorer.asm
index 9d093789e..8174e5a24 100644
--- a/src/test/ref/c64dtv-gfxexplorer.asm
+++ b/src/test/ref/c64dtv-gfxexplorer.asm
@@ -2,25 +2,82 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_LINEAR = 1
+  .const DTV_BORDER_OFF = 2
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_OVERSCAN = 8
+  .const DTV_COLORRAM_OFF = $10
+  .const DTV_CHUNKY = $40
+  .const DTV_COLOR_BANK_DEFAULT = $1d800
+  .const KEY_CRSR_RIGHT = 2
+  .const KEY_CRSR_DOWN = 7
+  .const KEY_LSHIFT = $f
+  .const KEY_RSHIFT = $34
+  .const KEY_CTRL = $3a
+  .const KEY_SPACE = $3c
+  .const KEY_COMMODORE = $3d
+  // Left shift is pressed
+  .const KEY_MODIFIER_LSHIFT = 1
+  // Right shift is pressed
+  .const KEY_MODIFIER_RSHIFT = 2
+  // CTRL is pressed
+  .const KEY_MODIFIER_CTRL = 4
+  // Commodore is pressed
+  .const KEY_MODIFIER_COMMODORE = 8
+  // Any shift is pressed
+  .const KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT
+  // 8BPP Chunky Bitmap (contains 8bpp pixels)
+  .const PLANE_8BPP_CHUNKY = $20000
+  // Plane with horisontal stripes
+  .const PLANE_HORISONTAL = $30000
+  // Plane with vertical stripes
+  .const PLANE_VERTICAL = $32000
+  // Plane with horisontal stripes every 2 pixels
+  .const PLANE_HORISONTAL2 = $34000
+  // Plane with vertical stripes every 2 pixels
+  .const PLANE_VERTICAL2 = $36000
+  // Plane with blank pixels
+  .const PLANE_BLANK = $38000
+  // Plane with all pixels
+  .const PLANE_FULL = $3a000
+  // Plane with all pixels
+  .const PLANE_CHARSET8 = $3c000
+  // The number of frames to use for a full blink cycle
+  .const FORM_CURSOR_BLINK = $28
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR3 = $24
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
+  .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
+  // Number of form fields
+  .const form_fields_cnt = $24
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The VIC-II MOS 6567/6569
@@ -33,15 +90,8 @@
   .label CIA2 = $dd00
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_LINEAR = 1
-  .const DTV_BORDER_OFF = 2
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_OVERSCAN = 8
-  .const DTV_COLORRAM_OFF = $10
-  .const DTV_CHUNKY = $40
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane A Counter Control
@@ -62,27 +112,9 @@
   // Memory address of Color RAM is ColorBank*$400
   .label DTV_COLOR_BANK_LO = $d036
   .label DTV_COLOR_BANK_HI = $d037
-  .const DTV_COLOR_BANK_DEFAULT = $1d800
   // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
   // Memory address of VIC Graphics is GraphicsBank*$10000
   .label DTV_GRAPHICS_VIC_BANK = $d03d
-  .const KEY_CRSR_RIGHT = 2
-  .const KEY_CRSR_DOWN = 7
-  .const KEY_LSHIFT = $f
-  .const KEY_RSHIFT = $34
-  .const KEY_CTRL = $3a
-  .const KEY_SPACE = $3c
-  .const KEY_COMMODORE = $3d
-  // Left shift is pressed
-  .const KEY_MODIFIER_LSHIFT = 1
-  // Right shift is pressed
-  .const KEY_MODIFIER_RSHIFT = 2
-  // CTRL is pressed
-  .const KEY_MODIFIER_CTRL = 4
-  // Commodore is pressed
-  .const KEY_MODIFIER_COMMODORE = 8
-  // Any shift is pressed
-  .const KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT
   // VIC Screens
   .label VIC_SCREEN0 = $4000
   .label VIC_SCREEN1 = $4400
@@ -93,22 +125,6 @@
   .label VIC_CHARSET_ROM = $5800
   // VIC Bitmap
   .label VIC_BITMAP = $6000
-  // 8BPP Chunky Bitmap (contains 8bpp pixels)
-  .const PLANE_8BPP_CHUNKY = $20000
-  // Plane with horisontal stripes
-  .const PLANE_HORISONTAL = $30000
-  // Plane with vertical stripes
-  .const PLANE_VERTICAL = $32000
-  // Plane with horisontal stripes every 2 pixels
-  .const PLANE_HORISONTAL2 = $34000
-  // Plane with vertical stripes every 2 pixels
-  .const PLANE_VERTICAL2 = $36000
-  // Plane with blank pixels
-  .const PLANE_BLANK = $38000
-  // Plane with all pixels
-  .const PLANE_FULL = $3a000
-  // Plane with all pixels
-  .const PLANE_CHARSET8 = $3c000
   // Screen containing the FORM
   .label FORM_SCREEN = $400
   // Charset used for the FORM
@@ -148,22 +164,6 @@
   .label form_vic_bg2_lo = form_fields_val+$21
   .label form_vic_bg3_hi = form_fields_val+$22
   .label form_vic_bg3_lo = form_fields_val+$23
-  // The number of frames to use for a full blink cycle
-  .const FORM_CURSOR_BLINK = $28
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR3 = $24
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
-  .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
-  // Number of form fields
-  .const form_fields_cnt = $24
   .label print_line_cursor = 7
   // Keyboard event buffer size. The number of events currently in the event buffer
   .label keyboard_events_size = 2
diff --git a/src/test/ref/c64dtv-gfxexplorer.log b/src/test/ref/c64dtv-gfxexplorer.log
index e829c44ee..da7f59edf 100644
--- a/src/test/ref/c64dtv-gfxexplorer.log
+++ b/src/test/ref/c64dtv-gfxexplorer.log
@@ -13034,25 +13034,82 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_LINEAR = 1
+  .const DTV_BORDER_OFF = 2
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_OVERSCAN = 8
+  .const DTV_COLORRAM_OFF = $10
+  .const DTV_CHUNKY = $40
+  .const DTV_COLOR_BANK_DEFAULT = $1d800
+  .const KEY_CRSR_RIGHT = 2
+  .const KEY_CRSR_DOWN = 7
+  .const KEY_LSHIFT = $f
+  .const KEY_RSHIFT = $34
+  .const KEY_CTRL = $3a
+  .const KEY_SPACE = $3c
+  .const KEY_COMMODORE = $3d
+  // Left shift is pressed
+  .const KEY_MODIFIER_LSHIFT = 1
+  // Right shift is pressed
+  .const KEY_MODIFIER_RSHIFT = 2
+  // CTRL is pressed
+  .const KEY_MODIFIER_CTRL = 4
+  // Commodore is pressed
+  .const KEY_MODIFIER_COMMODORE = 8
+  // Any shift is pressed
+  .const KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT
+  // 8BPP Chunky Bitmap (contains 8bpp pixels)
+  .const PLANE_8BPP_CHUNKY = $20000
+  // Plane with horisontal stripes
+  .const PLANE_HORISONTAL = $30000
+  // Plane with vertical stripes
+  .const PLANE_VERTICAL = $32000
+  // Plane with horisontal stripes every 2 pixels
+  .const PLANE_HORISONTAL2 = $34000
+  // Plane with vertical stripes every 2 pixels
+  .const PLANE_VERTICAL2 = $36000
+  // Plane with blank pixels
+  .const PLANE_BLANK = $38000
+  // Plane with all pixels
+  .const PLANE_FULL = $3a000
+  // Plane with all pixels
+  .const PLANE_CHARSET8 = $3c000
+  // The number of frames to use for a full blink cycle
+  .const FORM_CURSOR_BLINK = $28
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR3 = $24
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
+  .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
+  // Number of form fields
+  .const form_fields_cnt = $24
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The VIC-II MOS 6567/6569
@@ -13065,15 +13122,8 @@ Target platform is c64basic / MOS6502X
   .label CIA2 = $dd00
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_LINEAR = 1
-  .const DTV_BORDER_OFF = 2
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_OVERSCAN = 8
-  .const DTV_COLORRAM_OFF = $10
-  .const DTV_CHUNKY = $40
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane A Counter Control
@@ -13094,27 +13144,9 @@ Target platform is c64basic / MOS6502X
   // Memory address of Color RAM is ColorBank*$400
   .label DTV_COLOR_BANK_LO = $d036
   .label DTV_COLOR_BANK_HI = $d037
-  .const DTV_COLOR_BANK_DEFAULT = $1d800
   // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
   // Memory address of VIC Graphics is GraphicsBank*$10000
   .label DTV_GRAPHICS_VIC_BANK = $d03d
-  .const KEY_CRSR_RIGHT = 2
-  .const KEY_CRSR_DOWN = 7
-  .const KEY_LSHIFT = $f
-  .const KEY_RSHIFT = $34
-  .const KEY_CTRL = $3a
-  .const KEY_SPACE = $3c
-  .const KEY_COMMODORE = $3d
-  // Left shift is pressed
-  .const KEY_MODIFIER_LSHIFT = 1
-  // Right shift is pressed
-  .const KEY_MODIFIER_RSHIFT = 2
-  // CTRL is pressed
-  .const KEY_MODIFIER_CTRL = 4
-  // Commodore is pressed
-  .const KEY_MODIFIER_COMMODORE = 8
-  // Any shift is pressed
-  .const KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT
   // VIC Screens
   .label VIC_SCREEN0 = $4000
   .label VIC_SCREEN1 = $4400
@@ -13125,22 +13157,6 @@ Target platform is c64basic / MOS6502X
   .label VIC_CHARSET_ROM = $5800
   // VIC Bitmap
   .label VIC_BITMAP = $6000
-  // 8BPP Chunky Bitmap (contains 8bpp pixels)
-  .const PLANE_8BPP_CHUNKY = $20000
-  // Plane with horisontal stripes
-  .const PLANE_HORISONTAL = $30000
-  // Plane with vertical stripes
-  .const PLANE_VERTICAL = $32000
-  // Plane with horisontal stripes every 2 pixels
-  .const PLANE_HORISONTAL2 = $34000
-  // Plane with vertical stripes every 2 pixels
-  .const PLANE_VERTICAL2 = $36000
-  // Plane with blank pixels
-  .const PLANE_BLANK = $38000
-  // Plane with all pixels
-  .const PLANE_FULL = $3a000
-  // Plane with all pixels
-  .const PLANE_CHARSET8 = $3c000
   // Screen containing the FORM
   .label FORM_SCREEN = $400
   // Charset used for the FORM
@@ -13180,22 +13196,6 @@ Target platform is c64basic / MOS6502X
   .label form_vic_bg2_lo = form_fields_val+$21
   .label form_vic_bg3_hi = form_fields_val+$22
   .label form_vic_bg3_lo = form_fields_val+$23
-  // The number of frames to use for a full blink cycle
-  .const FORM_CURSOR_BLINK = $28
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR3 = $24
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
-  .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
-  // Number of form fields
-  .const form_fields_cnt = $24
   .label print_line_cursor = $36
   // Keyboard event buffer size. The number of events currently in the event buffer
   .label keyboard_events_size = $12
@@ -20337,25 +20337,82 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_LINEAR = 1
+  .const DTV_BORDER_OFF = 2
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_OVERSCAN = 8
+  .const DTV_COLORRAM_OFF = $10
+  .const DTV_CHUNKY = $40
+  .const DTV_COLOR_BANK_DEFAULT = $1d800
+  .const KEY_CRSR_RIGHT = 2
+  .const KEY_CRSR_DOWN = 7
+  .const KEY_LSHIFT = $f
+  .const KEY_RSHIFT = $34
+  .const KEY_CTRL = $3a
+  .const KEY_SPACE = $3c
+  .const KEY_COMMODORE = $3d
+  // Left shift is pressed
+  .const KEY_MODIFIER_LSHIFT = 1
+  // Right shift is pressed
+  .const KEY_MODIFIER_RSHIFT = 2
+  // CTRL is pressed
+  .const KEY_MODIFIER_CTRL = 4
+  // Commodore is pressed
+  .const KEY_MODIFIER_COMMODORE = 8
+  // Any shift is pressed
+  .const KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT
+  // 8BPP Chunky Bitmap (contains 8bpp pixels)
+  .const PLANE_8BPP_CHUNKY = $20000
+  // Plane with horisontal stripes
+  .const PLANE_HORISONTAL = $30000
+  // Plane with vertical stripes
+  .const PLANE_VERTICAL = $32000
+  // Plane with horisontal stripes every 2 pixels
+  .const PLANE_HORISONTAL2 = $34000
+  // Plane with vertical stripes every 2 pixels
+  .const PLANE_VERTICAL2 = $36000
+  // Plane with blank pixels
+  .const PLANE_BLANK = $38000
+  // Plane with all pixels
+  .const PLANE_FULL = $3a000
+  // Plane with all pixels
+  .const PLANE_CHARSET8 = $3c000
+  // The number of frames to use for a full blink cycle
+  .const FORM_CURSOR_BLINK = $28
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR3 = $24
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
+  .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
+  // Number of form fields
+  .const form_fields_cnt = $24
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The VIC-II MOS 6567/6569
@@ -20368,15 +20425,8 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label CIA2 = $dd00
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_LINEAR = 1
-  .const DTV_BORDER_OFF = 2
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_OVERSCAN = 8
-  .const DTV_COLORRAM_OFF = $10
-  .const DTV_CHUNKY = $40
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane A Counter Control
@@ -20397,27 +20447,9 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Memory address of Color RAM is ColorBank*$400
   .label DTV_COLOR_BANK_LO = $d036
   .label DTV_COLOR_BANK_HI = $d037
-  .const DTV_COLOR_BANK_DEFAULT = $1d800
   // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
   // Memory address of VIC Graphics is GraphicsBank*$10000
   .label DTV_GRAPHICS_VIC_BANK = $d03d
-  .const KEY_CRSR_RIGHT = 2
-  .const KEY_CRSR_DOWN = 7
-  .const KEY_LSHIFT = $f
-  .const KEY_RSHIFT = $34
-  .const KEY_CTRL = $3a
-  .const KEY_SPACE = $3c
-  .const KEY_COMMODORE = $3d
-  // Left shift is pressed
-  .const KEY_MODIFIER_LSHIFT = 1
-  // Right shift is pressed
-  .const KEY_MODIFIER_RSHIFT = 2
-  // CTRL is pressed
-  .const KEY_MODIFIER_CTRL = 4
-  // Commodore is pressed
-  .const KEY_MODIFIER_COMMODORE = 8
-  // Any shift is pressed
-  .const KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT
   // VIC Screens
   .label VIC_SCREEN0 = $4000
   .label VIC_SCREEN1 = $4400
@@ -20428,22 +20460,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label VIC_CHARSET_ROM = $5800
   // VIC Bitmap
   .label VIC_BITMAP = $6000
-  // 8BPP Chunky Bitmap (contains 8bpp pixels)
-  .const PLANE_8BPP_CHUNKY = $20000
-  // Plane with horisontal stripes
-  .const PLANE_HORISONTAL = $30000
-  // Plane with vertical stripes
-  .const PLANE_VERTICAL = $32000
-  // Plane with horisontal stripes every 2 pixels
-  .const PLANE_HORISONTAL2 = $34000
-  // Plane with vertical stripes every 2 pixels
-  .const PLANE_VERTICAL2 = $36000
-  // Plane with blank pixels
-  .const PLANE_BLANK = $38000
-  // Plane with all pixels
-  .const PLANE_FULL = $3a000
-  // Plane with all pixels
-  .const PLANE_CHARSET8 = $3c000
   // Screen containing the FORM
   .label FORM_SCREEN = $400
   // Charset used for the FORM
@@ -20483,22 +20499,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label form_vic_bg2_lo = form_fields_val+$21
   .label form_vic_bg3_hi = form_fields_val+$22
   .label form_vic_bg3_lo = form_fields_val+$23
-  // The number of frames to use for a full blink cycle
-  .const FORM_CURSOR_BLINK = $28
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR3 = $24
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
-  .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
-  // Number of form fields
-  .const form_fields_cnt = $24
   .label print_line_cursor = 7
   // Keyboard event buffer size. The number of events currently in the event buffer
   .label keyboard_events_size = 2
@@ -28202,25 +28202,82 @@ Score: 10118890
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
+  .const DTV_FEATURE_ENABLE = 1
+  .const DTV_LINEAR = 1
+  .const DTV_BORDER_OFF = 2
+  .const DTV_HIGHCOLOR = 4
+  .const DTV_OVERSCAN = 8
+  .const DTV_COLORRAM_OFF = $10
+  .const DTV_CHUNKY = $40
+  .const DTV_COLOR_BANK_DEFAULT = $1d800
+  .const KEY_CRSR_RIGHT = 2
+  .const KEY_CRSR_DOWN = 7
+  .const KEY_LSHIFT = $f
+  .const KEY_RSHIFT = $34
+  .const KEY_CTRL = $3a
+  .const KEY_SPACE = $3c
+  .const KEY_COMMODORE = $3d
+  // Left shift is pressed
+  .const KEY_MODIFIER_LSHIFT = 1
+  // Right shift is pressed
+  .const KEY_MODIFIER_RSHIFT = 2
+  // CTRL is pressed
+  .const KEY_MODIFIER_CTRL = 4
+  // Commodore is pressed
+  .const KEY_MODIFIER_COMMODORE = 8
+  // Any shift is pressed
+  .const KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT
+  // 8BPP Chunky Bitmap (contains 8bpp pixels)
+  .const PLANE_8BPP_CHUNKY = $20000
+  // Plane with horisontal stripes
+  .const PLANE_HORISONTAL = $30000
+  // Plane with vertical stripes
+  .const PLANE_VERTICAL = $32000
+  // Plane with horisontal stripes every 2 pixels
+  .const PLANE_HORISONTAL2 = $34000
+  // Plane with vertical stripes every 2 pixels
+  .const PLANE_VERTICAL2 = $36000
+  // Plane with blank pixels
+  .const PLANE_BLANK = $38000
+  // Plane with all pixels
+  .const PLANE_FULL = $3a000
+  // Plane with all pixels
+  .const PLANE_CHARSET8 = $3c000
+  // The number of frames to use for a full blink cycle
+  .const FORM_CURSOR_BLINK = $28
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR3 = $24
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
+  .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
+  // Number of form fields
+  .const form_fields_cnt = $24
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The VIC-II MOS 6567/6569
@@ -28233,15 +28290,8 @@ Score: 10118890
   .label CIA2 = $dd00
   // Feature enables or disables the extra C64 DTV features
   .label DTV_FEATURE = $d03f
-  .const DTV_FEATURE_ENABLE = 1
   // Controls the graphics modes of the C64 DTV
   .label DTV_CONTROL = $d03c
-  .const DTV_LINEAR = 1
-  .const DTV_BORDER_OFF = 2
-  .const DTV_HIGHCOLOR = 4
-  .const DTV_OVERSCAN = 8
-  .const DTV_COLORRAM_OFF = $10
-  .const DTV_CHUNKY = $40
   // Defines colors for the 16 first colors ($00-$0f)
   .label DTV_PALETTE = $d200
   // Linear Graphics Plane A Counter Control
@@ -28262,27 +28312,9 @@ Score: 10118890
   // Memory address of Color RAM is ColorBank*$400
   .label DTV_COLOR_BANK_LO = $d036
   .label DTV_COLOR_BANK_HI = $d037
-  .const DTV_COLOR_BANK_DEFAULT = $1d800
   // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
   // Memory address of VIC Graphics is GraphicsBank*$10000
   .label DTV_GRAPHICS_VIC_BANK = $d03d
-  .const KEY_CRSR_RIGHT = 2
-  .const KEY_CRSR_DOWN = 7
-  .const KEY_LSHIFT = $f
-  .const KEY_RSHIFT = $34
-  .const KEY_CTRL = $3a
-  .const KEY_SPACE = $3c
-  .const KEY_COMMODORE = $3d
-  // Left shift is pressed
-  .const KEY_MODIFIER_LSHIFT = 1
-  // Right shift is pressed
-  .const KEY_MODIFIER_RSHIFT = 2
-  // CTRL is pressed
-  .const KEY_MODIFIER_CTRL = 4
-  // Commodore is pressed
-  .const KEY_MODIFIER_COMMODORE = 8
-  // Any shift is pressed
-  .const KEY_MODIFIER_SHIFT = KEY_MODIFIER_LSHIFT|KEY_MODIFIER_RSHIFT
   // VIC Screens
   .label VIC_SCREEN0 = $4000
   .label VIC_SCREEN1 = $4400
@@ -28293,22 +28325,6 @@ Score: 10118890
   .label VIC_CHARSET_ROM = $5800
   // VIC Bitmap
   .label VIC_BITMAP = $6000
-  // 8BPP Chunky Bitmap (contains 8bpp pixels)
-  .const PLANE_8BPP_CHUNKY = $20000
-  // Plane with horisontal stripes
-  .const PLANE_HORISONTAL = $30000
-  // Plane with vertical stripes
-  .const PLANE_VERTICAL = $32000
-  // Plane with horisontal stripes every 2 pixels
-  .const PLANE_HORISONTAL2 = $34000
-  // Plane with vertical stripes every 2 pixels
-  .const PLANE_VERTICAL2 = $36000
-  // Plane with blank pixels
-  .const PLANE_BLANK = $38000
-  // Plane with all pixels
-  .const PLANE_FULL = $3a000
-  // Plane with all pixels
-  .const PLANE_CHARSET8 = $3c000
   // Screen containing the FORM
   .label FORM_SCREEN = $400
   // Charset used for the FORM
@@ -28348,22 +28364,6 @@ Score: 10118890
   .label form_vic_bg2_lo = form_fields_val+$21
   .label form_vic_bg3_hi = form_fields_val+$22
   .label form_vic_bg3_lo = form_fields_val+$23
-  // The number of frames to use for a full blink cycle
-  .const FORM_CURSOR_BLINK = $28
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR3 = $24
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
-  .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18
-  // Number of form fields
-  .const form_fields_cnt = $24
   .label print_line_cursor = 7
   // Keyboard event buffer size. The number of events currently in the event buffer
   .label keyboard_events_size = 2
diff --git a/src/test/ref/c64dtv-gfxmodes.asm b/src/test/ref/c64dtv-gfxmodes.asm
index a92976191..d136005d4 100644
--- a/src/test/ref/c64dtv-gfxmodes.asm
+++ b/src/test/ref/c64dtv-gfxmodes.asm
@@ -2,78 +2,31 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label BGCOL1 = $d021
-  .label BGCOL2 = $d022
-  .label BGCOL3 = $d023
-  .label BGCOL4 = $d024
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   // The colors of the C64
   .const BLACK = 0
   .const GREEN = 5
   .const BLUE = 6
   .const LIGHT_GREEN = $d
-  // Feature enables or disables the extra C64 DTV features
-  .label DTV_FEATURE = $d03f
   .const DTV_FEATURE_ENABLE = 1
-  // Controls the graphics modes of the C64 DTV
-  .label DTV_CONTROL = $d03c
   .const DTV_LINEAR = 1
   .const DTV_BORDER_OFF = 2
   .const DTV_HIGHCOLOR = 4
   .const DTV_OVERSCAN = 8
   .const DTV_COLORRAM_OFF = $10
   .const DTV_CHUNKY = $40
-  // Defines colors for the 16 first colors ($00-$0f)
-  .label DTV_PALETTE = $d200
-  // Linear Graphics Plane A Counter Control
-  .label DTV_PLANEA_START_LO = $d03a
-  .label DTV_PLANEA_START_MI = $d03b
-  .label DTV_PLANEA_START_HI = $d045
-  .label DTV_PLANEA_STEP = $d046
-  .label DTV_PLANEA_MODULO_LO = $d038
-  .label DTV_PLANEA_MODULO_HI = $d039
-  // Linear Graphics Plane B Counter Control
-  .label DTV_PLANEB_START_LO = $d049
-  .label DTV_PLANEB_START_MI = $d04a
-  .label DTV_PLANEB_START_HI = $d04b
-  .label DTV_PLANEB_STEP = $d04c
-  .label DTV_PLANEB_MODULO_LO = $d047
-  .label DTV_PLANEB_MODULO_HI = $d048
-  // Select memory bank where color data is fetched from (bits 11:0)
-  // Memory address of Color RAM is ColorBank*$400
-  .label DTV_COLOR_BANK_LO = $d036
-  .label DTV_COLOR_BANK_HI = $d037
   .const DTV_COLOR_BANK_DEFAULT = $1d800
-  // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
-  // Memory address of VIC Graphics is GraphicsBank*$10000
-  .label DTV_GRAPHICS_VIC_BANK = $d03d
   .const KEY_3 = 8
   .const KEY_A = $a
   .const KEY_4 = $b
@@ -94,6 +47,53 @@
   .const KEY_SPACE = $3c
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label BGCOL1 = $d021
+  .label BGCOL2 = $d022
+  .label BGCOL3 = $d023
+  .label BGCOL4 = $d024
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // Feature enables or disables the extra C64 DTV features
+  .label DTV_FEATURE = $d03f
+  // Controls the graphics modes of the C64 DTV
+  .label DTV_CONTROL = $d03c
+  // Defines colors for the 16 first colors ($00-$0f)
+  .label DTV_PALETTE = $d200
+  // Linear Graphics Plane A Counter Control
+  .label DTV_PLANEA_START_LO = $d03a
+  .label DTV_PLANEA_START_MI = $d03b
+  .label DTV_PLANEA_START_HI = $d045
+  .label DTV_PLANEA_STEP = $d046
+  .label DTV_PLANEA_MODULO_LO = $d038
+  .label DTV_PLANEA_MODULO_HI = $d039
+  // Linear Graphics Plane B Counter Control
+  .label DTV_PLANEB_START_LO = $d049
+  .label DTV_PLANEB_START_MI = $d04a
+  .label DTV_PLANEB_START_HI = $d04b
+  .label DTV_PLANEB_STEP = $d04c
+  .label DTV_PLANEB_MODULO_LO = $d047
+  .label DTV_PLANEB_MODULO_HI = $d048
+  // Select memory bank where color data is fetched from (bits 11:0)
+  // Memory address of Color RAM is ColorBank*$400
+  .label DTV_COLOR_BANK_LO = $d036
+  .label DTV_COLOR_BANK_HI = $d037
+  // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
+  // Memory address of VIC Graphics is GraphicsBank*$10000
+  .label DTV_GRAPHICS_VIC_BANK = $d03d
   .label print_char_cursor = 6
   .label print_line_cursor = 8
 main: {
@@ -1852,9 +1852,9 @@ mode_hicolstdchar: {
 //  - 0: 4bpp CharData[3:0]
 //  - 1: 4bpp CharData[7:4]
 mode_stdbitmap: {
+    .const lines_cnt = 9
     .label SCREEN = $4000
     .label BITMAP = $6000
-    .const lines_cnt = 9
     .label col2 = $11
     // Bitmap Colors
     .label ch = 4
diff --git a/src/test/ref/c64dtv-gfxmodes.log b/src/test/ref/c64dtv-gfxmodes.log
index c44e9510a..81193f19d 100644
--- a/src/test/ref/c64dtv-gfxmodes.log
+++ b/src/test/ref/c64dtv-gfxmodes.log
@@ -11991,78 +11991,31 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label BGCOL1 = $d021
-  .label BGCOL2 = $d022
-  .label BGCOL3 = $d023
-  .label BGCOL4 = $d024
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   // The colors of the C64
   .const BLACK = 0
   .const GREEN = 5
   .const BLUE = 6
   .const LIGHT_GREEN = $d
-  // Feature enables or disables the extra C64 DTV features
-  .label DTV_FEATURE = $d03f
   .const DTV_FEATURE_ENABLE = 1
-  // Controls the graphics modes of the C64 DTV
-  .label DTV_CONTROL = $d03c
   .const DTV_LINEAR = 1
   .const DTV_BORDER_OFF = 2
   .const DTV_HIGHCOLOR = 4
   .const DTV_OVERSCAN = 8
   .const DTV_COLORRAM_OFF = $10
   .const DTV_CHUNKY = $40
-  // Defines colors for the 16 first colors ($00-$0f)
-  .label DTV_PALETTE = $d200
-  // Linear Graphics Plane A Counter Control
-  .label DTV_PLANEA_START_LO = $d03a
-  .label DTV_PLANEA_START_MI = $d03b
-  .label DTV_PLANEA_START_HI = $d045
-  .label DTV_PLANEA_STEP = $d046
-  .label DTV_PLANEA_MODULO_LO = $d038
-  .label DTV_PLANEA_MODULO_HI = $d039
-  // Linear Graphics Plane B Counter Control
-  .label DTV_PLANEB_START_LO = $d049
-  .label DTV_PLANEB_START_MI = $d04a
-  .label DTV_PLANEB_START_HI = $d04b
-  .label DTV_PLANEB_STEP = $d04c
-  .label DTV_PLANEB_MODULO_LO = $d047
-  .label DTV_PLANEB_MODULO_HI = $d048
-  // Select memory bank where color data is fetched from (bits 11:0)
-  // Memory address of Color RAM is ColorBank*$400
-  .label DTV_COLOR_BANK_LO = $d036
-  .label DTV_COLOR_BANK_HI = $d037
   .const DTV_COLOR_BANK_DEFAULT = $1d800
-  // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
-  // Memory address of VIC Graphics is GraphicsBank*$10000
-  .label DTV_GRAPHICS_VIC_BANK = $d03d
   .const KEY_3 = 8
   .const KEY_A = $a
   .const KEY_4 = $b
@@ -12083,6 +12036,53 @@ Target platform is c64basic / MOS6502X
   .const KEY_SPACE = $3c
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label BGCOL1 = $d021
+  .label BGCOL2 = $d022
+  .label BGCOL3 = $d023
+  .label BGCOL4 = $d024
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // Feature enables or disables the extra C64 DTV features
+  .label DTV_FEATURE = $d03f
+  // Controls the graphics modes of the C64 DTV
+  .label DTV_CONTROL = $d03c
+  // Defines colors for the 16 first colors ($00-$0f)
+  .label DTV_PALETTE = $d200
+  // Linear Graphics Plane A Counter Control
+  .label DTV_PLANEA_START_LO = $d03a
+  .label DTV_PLANEA_START_MI = $d03b
+  .label DTV_PLANEA_START_HI = $d045
+  .label DTV_PLANEA_STEP = $d046
+  .label DTV_PLANEA_MODULO_LO = $d038
+  .label DTV_PLANEA_MODULO_HI = $d039
+  // Linear Graphics Plane B Counter Control
+  .label DTV_PLANEB_START_LO = $d049
+  .label DTV_PLANEB_START_MI = $d04a
+  .label DTV_PLANEB_START_HI = $d04b
+  .label DTV_PLANEB_STEP = $d04c
+  .label DTV_PLANEB_MODULO_LO = $d047
+  .label DTV_PLANEB_MODULO_HI = $d048
+  // Select memory bank where color data is fetched from (bits 11:0)
+  // Memory address of Color RAM is ColorBank*$400
+  .label DTV_COLOR_BANK_LO = $d036
+  .label DTV_COLOR_BANK_HI = $d037
+  // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
+  // Memory address of VIC Graphics is GraphicsBank*$10000
+  .label DTV_GRAPHICS_VIC_BANK = $d03d
   // The value of the DTV control register
   // DTV Graphics Mode
   // DTV Graphics Mode
@@ -15354,9 +15354,9 @@ mode_hicolstdchar: {
 //  - 0: 4bpp CharData[3:0]
 //  - 1: 4bpp CharData[7:4]
 mode_stdbitmap: {
+    .const lines_cnt = 9
     .label SCREEN = $4000
     .label BITMAP = $6000
-    .const lines_cnt = 9
     .label __4 = $f3
     .label __7 = $f6
     .label __8 = $f7
@@ -18971,78 +18971,31 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label BGCOL1 = $d021
-  .label BGCOL2 = $d022
-  .label BGCOL3 = $d023
-  .label BGCOL4 = $d024
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   // The colors of the C64
   .const BLACK = 0
   .const GREEN = 5
   .const BLUE = 6
   .const LIGHT_GREEN = $d
-  // Feature enables or disables the extra C64 DTV features
-  .label DTV_FEATURE = $d03f
   .const DTV_FEATURE_ENABLE = 1
-  // Controls the graphics modes of the C64 DTV
-  .label DTV_CONTROL = $d03c
   .const DTV_LINEAR = 1
   .const DTV_BORDER_OFF = 2
   .const DTV_HIGHCOLOR = 4
   .const DTV_OVERSCAN = 8
   .const DTV_COLORRAM_OFF = $10
   .const DTV_CHUNKY = $40
-  // Defines colors for the 16 first colors ($00-$0f)
-  .label DTV_PALETTE = $d200
-  // Linear Graphics Plane A Counter Control
-  .label DTV_PLANEA_START_LO = $d03a
-  .label DTV_PLANEA_START_MI = $d03b
-  .label DTV_PLANEA_START_HI = $d045
-  .label DTV_PLANEA_STEP = $d046
-  .label DTV_PLANEA_MODULO_LO = $d038
-  .label DTV_PLANEA_MODULO_HI = $d039
-  // Linear Graphics Plane B Counter Control
-  .label DTV_PLANEB_START_LO = $d049
-  .label DTV_PLANEB_START_MI = $d04a
-  .label DTV_PLANEB_START_HI = $d04b
-  .label DTV_PLANEB_STEP = $d04c
-  .label DTV_PLANEB_MODULO_LO = $d047
-  .label DTV_PLANEB_MODULO_HI = $d048
-  // Select memory bank where color data is fetched from (bits 11:0)
-  // Memory address of Color RAM is ColorBank*$400
-  .label DTV_COLOR_BANK_LO = $d036
-  .label DTV_COLOR_BANK_HI = $d037
   .const DTV_COLOR_BANK_DEFAULT = $1d800
-  // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
-  // Memory address of VIC Graphics is GraphicsBank*$10000
-  .label DTV_GRAPHICS_VIC_BANK = $d03d
   .const KEY_3 = 8
   .const KEY_A = $a
   .const KEY_4 = $b
@@ -19063,6 +19016,53 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const KEY_SPACE = $3c
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label BGCOL1 = $d021
+  .label BGCOL2 = $d022
+  .label BGCOL3 = $d023
+  .label BGCOL4 = $d024
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // Feature enables or disables the extra C64 DTV features
+  .label DTV_FEATURE = $d03f
+  // Controls the graphics modes of the C64 DTV
+  .label DTV_CONTROL = $d03c
+  // Defines colors for the 16 first colors ($00-$0f)
+  .label DTV_PALETTE = $d200
+  // Linear Graphics Plane A Counter Control
+  .label DTV_PLANEA_START_LO = $d03a
+  .label DTV_PLANEA_START_MI = $d03b
+  .label DTV_PLANEA_START_HI = $d045
+  .label DTV_PLANEA_STEP = $d046
+  .label DTV_PLANEA_MODULO_LO = $d038
+  .label DTV_PLANEA_MODULO_HI = $d039
+  // Linear Graphics Plane B Counter Control
+  .label DTV_PLANEB_START_LO = $d049
+  .label DTV_PLANEB_START_MI = $d04a
+  .label DTV_PLANEB_START_HI = $d04b
+  .label DTV_PLANEB_STEP = $d04c
+  .label DTV_PLANEB_MODULO_LO = $d047
+  .label DTV_PLANEB_MODULO_HI = $d048
+  // Select memory bank where color data is fetched from (bits 11:0)
+  // Memory address of Color RAM is ColorBank*$400
+  .label DTV_COLOR_BANK_LO = $d036
+  .label DTV_COLOR_BANK_HI = $d037
+  // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
+  // Memory address of VIC Graphics is GraphicsBank*$10000
+  .label DTV_GRAPHICS_VIC_BANK = $d03d
   .label print_char_cursor = 6
   .label print_line_cursor = 8
   // @begin
@@ -21960,9 +21960,9 @@ mode_hicolstdchar: {
 //  - 0: 4bpp CharData[3:0]
 //  - 1: 4bpp CharData[7:4]
 mode_stdbitmap: {
+    .const lines_cnt = 9
     .label SCREEN = $4000
     .label BITMAP = $6000
-    .const lines_cnt = 9
     .label col2 = $11
     // Bitmap Colors
     .label ch = 4
@@ -26031,78 +26031,31 @@ Score: 2307926
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL = $d021
-  .label BGCOL1 = $d021
-  .label BGCOL2 = $d022
-  .label BGCOL3 = $d023
-  .label BGCOL4 = $d024
-  .label VIC_CONTROL = $d011
   .const VIC_ECM = $40
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label VIC_CONTROL2 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label VIC_MEMORY = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   // The colors of the C64
   .const BLACK = 0
   .const GREEN = 5
   .const BLUE = 6
   .const LIGHT_GREEN = $d
-  // Feature enables or disables the extra C64 DTV features
-  .label DTV_FEATURE = $d03f
   .const DTV_FEATURE_ENABLE = 1
-  // Controls the graphics modes of the C64 DTV
-  .label DTV_CONTROL = $d03c
   .const DTV_LINEAR = 1
   .const DTV_BORDER_OFF = 2
   .const DTV_HIGHCOLOR = 4
   .const DTV_OVERSCAN = 8
   .const DTV_COLORRAM_OFF = $10
   .const DTV_CHUNKY = $40
-  // Defines colors for the 16 first colors ($00-$0f)
-  .label DTV_PALETTE = $d200
-  // Linear Graphics Plane A Counter Control
-  .label DTV_PLANEA_START_LO = $d03a
-  .label DTV_PLANEA_START_MI = $d03b
-  .label DTV_PLANEA_START_HI = $d045
-  .label DTV_PLANEA_STEP = $d046
-  .label DTV_PLANEA_MODULO_LO = $d038
-  .label DTV_PLANEA_MODULO_HI = $d039
-  // Linear Graphics Plane B Counter Control
-  .label DTV_PLANEB_START_LO = $d049
-  .label DTV_PLANEB_START_MI = $d04a
-  .label DTV_PLANEB_START_HI = $d04b
-  .label DTV_PLANEB_STEP = $d04c
-  .label DTV_PLANEB_MODULO_LO = $d047
-  .label DTV_PLANEB_MODULO_HI = $d048
-  // Select memory bank where color data is fetched from (bits 11:0)
-  // Memory address of Color RAM is ColorBank*$400
-  .label DTV_COLOR_BANK_LO = $d036
-  .label DTV_COLOR_BANK_HI = $d037
   .const DTV_COLOR_BANK_DEFAULT = $1d800
-  // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
-  // Memory address of VIC Graphics is GraphicsBank*$10000
-  .label DTV_GRAPHICS_VIC_BANK = $d03d
   .const KEY_3 = 8
   .const KEY_A = $a
   .const KEY_4 = $b
@@ -26123,6 +26076,53 @@ Score: 2307926
   .const KEY_SPACE = $3c
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL = $d021
+  .label BGCOL1 = $d021
+  .label BGCOL2 = $d022
+  .label BGCOL3 = $d023
+  .label BGCOL4 = $d024
+  .label VIC_CONTROL = $d011
+  .label VIC_CONTROL2 = $d016
+  .label VIC_MEMORY = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // Feature enables or disables the extra C64 DTV features
+  .label DTV_FEATURE = $d03f
+  // Controls the graphics modes of the C64 DTV
+  .label DTV_CONTROL = $d03c
+  // Defines colors for the 16 first colors ($00-$0f)
+  .label DTV_PALETTE = $d200
+  // Linear Graphics Plane A Counter Control
+  .label DTV_PLANEA_START_LO = $d03a
+  .label DTV_PLANEA_START_MI = $d03b
+  .label DTV_PLANEA_START_HI = $d045
+  .label DTV_PLANEA_STEP = $d046
+  .label DTV_PLANEA_MODULO_LO = $d038
+  .label DTV_PLANEA_MODULO_HI = $d039
+  // Linear Graphics Plane B Counter Control
+  .label DTV_PLANEB_START_LO = $d049
+  .label DTV_PLANEB_START_MI = $d04a
+  .label DTV_PLANEB_START_HI = $d04b
+  .label DTV_PLANEB_STEP = $d04c
+  .label DTV_PLANEB_MODULO_LO = $d047
+  .label DTV_PLANEB_MODULO_HI = $d048
+  // Select memory bank where color data is fetched from (bits 11:0)
+  // Memory address of Color RAM is ColorBank*$400
+  .label DTV_COLOR_BANK_LO = $d036
+  .label DTV_COLOR_BANK_HI = $d037
+  // Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
+  // Memory address of VIC Graphics is GraphicsBank*$10000
+  .label DTV_GRAPHICS_VIC_BANK = $d03d
   .label print_char_cursor = 6
   .label print_line_cursor = 8
   // @begin
@@ -28907,9 +28907,9 @@ mode_hicolstdchar: {
 //  - 0: 4bpp CharData[3:0]
 //  - 1: 4bpp CharData[7:4]
 mode_stdbitmap: {
+    .const lines_cnt = 9
     .label SCREEN = $4000
     .label BITMAP = $6000
-    .const lines_cnt = 9
     .label col2 = $11
     // Bitmap Colors
     .label ch = 4
diff --git a/src/test/ref/cast-precedence-problem.asm b/src/test/ref/cast-precedence-problem.asm
index f91aadb14..cb01cd96f 100644
--- a/src/test/ref/cast-precedence-problem.asm
+++ b/src/test/ref/cast-precedence-problem.asm
@@ -3,14 +3,14 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const min = $a
     .const max = $c8
-    .label BGCOL = $d021
     .const sumw = min+max
     .const sumb = min+max
     .const midw = (sumw>>1)+1
     .const midb = (sumb>>1)+1
+    .label SCREEN = $400
+    .label BGCOL = $d021
     // SCREEN[0] = midw
     lda #midw
     sta SCREEN
diff --git a/src/test/ref/cast-precedence-problem.log b/src/test/ref/cast-precedence-problem.log
index 0bc3dc012..4189a2d9e 100644
--- a/src/test/ref/cast-precedence-problem.log
+++ b/src/test/ref/cast-precedence-problem.log
@@ -223,14 +223,14 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const min = $a
     .const max = $c8
-    .label BGCOL = $d021
     .const sumw = min+max
     .const sumb = min+max
     .const midw = (sumw>>1)+1
     .const midb = (sumb>>1)+1
+    .label SCREEN = $400
+    .label BGCOL = $d021
     // [4] *((const byte*) main::SCREEN) ← (const byte) main::midw#0 -- _deref_pbuc1=vbuc2 
     lda #midw
     sta SCREEN
@@ -299,14 +299,14 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const min = $a
     .const max = $c8
-    .label BGCOL = $d021
     .const sumw = min+max
     .const sumb = min+max
     .const midw = (sumw>>1)+1
     .const midb = (sumb>>1)+1
+    .label SCREEN = $400
+    .label BGCOL = $d021
     // [4] *((const byte*) main::SCREEN) ← (const byte) main::midw#0 -- _deref_pbuc1=vbuc2 
     lda #midw
     sta SCREEN
@@ -400,14 +400,14 @@ Score: 46
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const min = $a
     .const max = $c8
-    .label BGCOL = $d021
     .const sumw = min+max
     .const sumb = min+max
     .const midw = (sumw>>1)+1
     .const midb = (sumb>>1)+1
+    .label SCREEN = $400
+    .label BGCOL = $d021
     // SCREEN[0] = midw
     // [4] *((const byte*) main::SCREEN) ← (const byte) main::midw#0 -- _deref_pbuc1=vbuc2 
     lda #midw
diff --git a/src/test/ref/cia-timer-cyclecount.asm b/src/test/ref/cia-timer-cyclecount.asm
index c2030e345..5bd2b5d79 100644
--- a/src/test/ref/cia-timer-cyclecount.asm
+++ b/src/test/ref/cia-timer-cyclecount.asm
@@ -6,16 +6,16 @@
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
+  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
+  .const CLOCKS_PER_INIT = $12
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
-  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
-  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
-  .const CLOCKS_PER_INIT = $12
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
 main: {
     .label __1 = 9
     .label cyclecount = 9
diff --git a/src/test/ref/cia-timer-cyclecount.log b/src/test/ref/cia-timer-cyclecount.log
index b5176e950..e28ffe970 100644
--- a/src/test/ref/cia-timer-cyclecount.log
+++ b/src/test/ref/cia-timer-cyclecount.log
@@ -752,16 +752,16 @@ Target platform is c64basic / MOS6502X
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
+  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
+  .const CLOCKS_PER_INIT = $12
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
-  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
-  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
-  .const CLOCKS_PER_INIT = $12
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1181,16 +1181,16 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
+  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
+  .const CLOCKS_PER_INIT = $12
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
-  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
-  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
-  .const CLOCKS_PER_INIT = $12
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1696,16 +1696,16 @@ Score: 869
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
+  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
+  .const CLOCKS_PER_INIT = $12
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
-  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
-  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
-  .const CLOCKS_PER_INIT = $12
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/cia-timer-simple.asm b/src/test/ref/cia-timer-simple.asm
index 89a74bcbb..cf5c68ca5 100644
--- a/src/test/ref/cia-timer-simple.asm
+++ b/src/test/ref/cia-timer-simple.asm
@@ -6,13 +6,13 @@
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
 main: {
     // clock_start()
     // Reset & start the CIA#2 timer A+B
diff --git a/src/test/ref/cia-timer-simple.log b/src/test/ref/cia-timer-simple.log
index 08442d9ea..36f1dc224 100644
--- a/src/test/ref/cia-timer-simple.log
+++ b/src/test/ref/cia-timer-simple.log
@@ -732,13 +732,13 @@ Target platform is c64basic / MOS6502X
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1119,13 +1119,13 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1601,13 +1601,13 @@ Score: 455
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/clobber-a-problem.asm b/src/test/ref/clobber-a-problem.asm
index f2d7a5864..95293739d 100644
--- a/src/test/ref/clobber-a-problem.asm
+++ b/src/test/ref/clobber-a-problem.asm
@@ -1,11 +1,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
+  .const DARK_GREY = $b
+  .const BLACK = 0
   .label KERNEL_IRQ = $314
   .label BORDERCOL = $d020
   .label RASTER = $d012
-  .const DARK_GREY = $b
-  .const BLACK = 0
   .label irq_raster_next = 2
 __bbegin:
   // irq_raster_next = 0
diff --git a/src/test/ref/clobber-a-problem.log b/src/test/ref/clobber-a-problem.log
index d5606f074..6edfbc08a 100644
--- a/src/test/ref/clobber-a-problem.log
+++ b/src/test/ref/clobber-a-problem.log
@@ -188,11 +188,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DARK_GREY = $b
+  .const BLACK = 0
   .label KERNEL_IRQ = $314
   .label BORDERCOL = $d020
   .label RASTER = $d012
-  .const DARK_GREY = $b
-  .const BLACK = 0
   .label irq_raster_next = 3
   // @begin
 __bbegin:
@@ -320,11 +320,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DARK_GREY = $b
+  .const BLACK = 0
   .label KERNEL_IRQ = $314
   .label BORDERCOL = $d020
   .label RASTER = $d012
-  .const DARK_GREY = $b
-  .const BLACK = 0
   .label irq_raster_next = 2
   // @begin
 __bbegin:
@@ -473,11 +473,11 @@ Score: 159
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const DARK_GREY = $b
+  .const BLACK = 0
   .label KERNEL_IRQ = $314
   .label BORDERCOL = $d020
   .label RASTER = $d012
-  .const DARK_GREY = $b
-  .const BLACK = 0
   .label irq_raster_next = 2
   // @begin
 __bbegin:
diff --git a/src/test/ref/code-after-return-1.asm b/src/test/ref/code-after-return-1.asm
index d5bd6173a..641461559 100644
--- a/src/test/ref/code-after-return-1.asm
+++ b/src/test/ref/code-after-return-1.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const b = 0
+  .label SCREEN = $400
 main: {
     // SCREEN[0] = b
     lda #b
diff --git a/src/test/ref/code-after-return-1.log b/src/test/ref/code-after-return-1.log
index d601cfd99..bfeee9991 100644
--- a/src/test/ref/code-after-return-1.log
+++ b/src/test/ref/code-after-return-1.log
@@ -157,8 +157,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const b = 0
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -204,8 +204,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const b = 0
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -273,8 +273,8 @@ Score: 12
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const b = 0
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/comma-decl-2.asm b/src/test/ref/comma-decl-2.asm
index 67b857475..d27518e7d 100644
--- a/src/test/ref/comma-decl-2.asm
+++ b/src/test/ref/comma-decl-2.asm
@@ -3,9 +3,9 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const b = 0
     .const d = 0
+    .label SCREEN = $400
     // SCREEN[0] = b
     lda #b
     sta SCREEN
diff --git a/src/test/ref/comma-decl-2.log b/src/test/ref/comma-decl-2.log
index ad511a527..8ee47d7ed 100644
--- a/src/test/ref/comma-decl-2.log
+++ b/src/test/ref/comma-decl-2.log
@@ -120,9 +120,9 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const b = 0
     .const d = 0
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::b -- _deref_pbuc1=vbuc2 
     lda #b
     sta SCREEN
@@ -177,9 +177,9 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const b = 0
     .const d = 0
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::b -- _deref_pbuc1=vbuc2 
     lda #b
     sta SCREEN
@@ -247,9 +247,9 @@ Score: 26
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const b = 0
     .const d = 0
+    .label SCREEN = $400
     // SCREEN[0] = b
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::b -- _deref_pbuc1=vbuc2 
     lda #b
diff --git a/src/test/ref/comma-decl.asm b/src/test/ref/comma-decl.asm
index 43d517b53..35eababd8 100644
--- a/src/test/ref/comma-decl.asm
+++ b/src/test/ref/comma-decl.asm
@@ -3,10 +3,10 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const b = 'c'
     .const c = b+1
     .const d = c+1
+    .label SCREEN = $400
     // SCREEN[0] = b
     lda #b
     sta SCREEN
diff --git a/src/test/ref/comma-decl.log b/src/test/ref/comma-decl.log
index 4d5110388..738023a36 100644
--- a/src/test/ref/comma-decl.log
+++ b/src/test/ref/comma-decl.log
@@ -147,10 +147,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const b = 'c'
     .const c = b+1
     .const d = c+1
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::b -- _deref_pbuc1=vbuc2 
     lda #b
     sta SCREEN
@@ -204,10 +204,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const b = 'c'
     .const c = b+1
     .const d = c+1
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::b -- _deref_pbuc1=vbuc2 
     lda #b
     sta SCREEN
@@ -276,10 +276,10 @@ Score: 24
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const b = 'c'
     .const c = b+1
     .const d = c+1
+    .label SCREEN = $400
     // SCREEN[0] = b
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::b -- _deref_pbuc1=vbuc2 
     lda #b
diff --git a/src/test/ref/comma-expr-1.asm b/src/test/ref/comma-expr-1.asm
index 9fdcae319..594314a5b 100644
--- a/src/test/ref/comma-expr-1.asm
+++ b/src/test/ref/comma-expr-1.asm
@@ -3,9 +3,9 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const b = 3
     .const c = b+1
+    .label SCREEN = $400
     // SCREEN[1,0] = c
     lda #c
     sta SCREEN
diff --git a/src/test/ref/comma-expr-1.log b/src/test/ref/comma-expr-1.log
index 7ea0e87a7..eccdfe46f 100644
--- a/src/test/ref/comma-expr-1.log
+++ b/src/test/ref/comma-expr-1.log
@@ -118,9 +118,9 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const b = 3
     .const c = b+1
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::c#0 -- _deref_pbuc1=vbuc2 
     lda #c
     sta SCREEN
@@ -166,9 +166,9 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const b = 3
     .const c = b+1
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::c#0 -- _deref_pbuc1=vbuc2 
     lda #c
     sta SCREEN
@@ -229,9 +229,9 @@ Score: 12
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const b = 3
     .const c = b+1
+    .label SCREEN = $400
     // SCREEN[1,0] = c
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::c#0 -- _deref_pbuc1=vbuc2 
     lda #c
diff --git a/src/test/ref/comma-expr-2.asm b/src/test/ref/comma-expr-2.asm
index 3c6c78f06..a5431c19c 100644
--- a/src/test/ref/comma-expr-2.asm
+++ b/src/test/ref/comma-expr-2.asm
@@ -3,8 +3,8 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const c = 1+3
+    .label SCREEN = $400
     // SCREEN[1,0] = c
     lda #c
     sta SCREEN
diff --git a/src/test/ref/comma-expr-2.log b/src/test/ref/comma-expr-2.log
index ea9204fec..f44f8004e 100644
--- a/src/test/ref/comma-expr-2.log
+++ b/src/test/ref/comma-expr-2.log
@@ -116,8 +116,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const c = 1+3
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::c#1 -- _deref_pbuc1=vbuc2 
     lda #c
     sta SCREEN
@@ -163,8 +163,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const c = 1+3
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::c#1 -- _deref_pbuc1=vbuc2 
     lda #c
     sta SCREEN
@@ -224,8 +224,8 @@ Score: 12
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const c = 1+3
+    .label SCREEN = $400
     // SCREEN[1,0] = c
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::c#1 -- _deref_pbuc1=vbuc2 
     lda #c
diff --git a/src/test/ref/complex/clearscreen/clearscreen.asm b/src/test/ref/complex/clearscreen/clearscreen.asm
index 52340e361..7e8912c76 100644
--- a/src/test/ref/complex/clearscreen/clearscreen.asm
+++ b/src/test/ref/complex/clearscreen/clearscreen.asm
@@ -13,45 +13,15 @@
   .const BORDER_YPOS_BOTTOM = $fa
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_XMSB = $d010
-  .label SPRITES_COLS = $d027
-  .label SPRITES_ENABLE = $d015
-  .label SPRITES_EXPAND_Y = $d017
-  .label SPRITES_MC = $d01c
-  .label SPRITES_EXPAND_X = $d01d
-  .label RASTER = $d012
-  .label VIC_CONTROL = $d011
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
-  // The address of the CHARGEN character set
-  .label CHARGEN = $d000
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   .const LIGHT_BLUE = $e
-  // Address of the screen
-  .label SCREEN = $400
-  // Sprite data for the animating sprites
-  .label SPRITE_DATA = $2000
   // Max number of chars processed at once
   .const NUM_PROCESSING = 8
   // Distance value meaning not found
@@ -75,6 +45,36 @@
   .const OFFSET_STRUCT_PROCESSINGSPRITE_STATUS = $b
   .const OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR = $c
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_XMSB = $d010
+  .label SPRITES_COLS = $d027
+  .label SPRITES_ENABLE = $d015
+  .label SPRITES_EXPAND_Y = $d017
+  .label SPRITES_MC = $d01c
+  .label SPRITES_EXPAND_X = $d01d
+  .label RASTER = $d012
+  .label VIC_CONTROL = $d011
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The address of the CHARGEN character set
+  .label CHARGEN = $d000
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
+  // Address of the screen
+  .label SCREEN = $400
+  // Sprite data for the animating sprites
+  .label SPRITE_DATA = $2000
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
diff --git a/src/test/ref/complex/clearscreen/clearscreen.log b/src/test/ref/complex/clearscreen/clearscreen.log
index 6925dce87..0d121521f 100644
--- a/src/test/ref/complex/clearscreen/clearscreen.log
+++ b/src/test/ref/complex/clearscreen/clearscreen.log
@@ -4588,45 +4588,15 @@ Target platform is c64basic / MOS6502X
   .const BORDER_YPOS_BOTTOM = $fa
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_XMSB = $d010
-  .label SPRITES_COLS = $d027
-  .label SPRITES_ENABLE = $d015
-  .label SPRITES_EXPAND_Y = $d017
-  .label SPRITES_MC = $d01c
-  .label SPRITES_EXPAND_X = $d01d
-  .label RASTER = $d012
-  .label VIC_CONTROL = $d011
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
-  // The address of the CHARGEN character set
-  .label CHARGEN = $d000
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   .const LIGHT_BLUE = $e
-  // Address of the screen
-  .label SCREEN = $400
-  // Sprite data for the animating sprites
-  .label SPRITE_DATA = $2000
   // Max number of chars processed at once
   .const NUM_PROCESSING = 8
   // Distance value meaning not found
@@ -4650,6 +4620,36 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_PROCESSINGSPRITE_STATUS = $b
   .const OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR = $c
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_XMSB = $d010
+  .label SPRITES_COLS = $d027
+  .label SPRITES_ENABLE = $d015
+  .label SPRITES_EXPAND_Y = $d017
+  .label SPRITES_MC = $d01c
+  .label SPRITES_EXPAND_X = $d01d
+  .label RASTER = $d012
+  .label VIC_CONTROL = $d011
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The address of the CHARGEN character set
+  .label CHARGEN = $d000
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
+  // Address of the screen
+  .label SCREEN = $400
+  // Sprite data for the animating sprites
+  .label SPRITE_DATA = $2000
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
@@ -7578,45 +7578,15 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const BORDER_YPOS_BOTTOM = $fa
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_XMSB = $d010
-  .label SPRITES_COLS = $d027
-  .label SPRITES_ENABLE = $d015
-  .label SPRITES_EXPAND_Y = $d017
-  .label SPRITES_MC = $d01c
-  .label SPRITES_EXPAND_X = $d01d
-  .label RASTER = $d012
-  .label VIC_CONTROL = $d011
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
-  // The address of the CHARGEN character set
-  .label CHARGEN = $d000
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   .const LIGHT_BLUE = $e
-  // Address of the screen
-  .label SCREEN = $400
-  // Sprite data for the animating sprites
-  .label SPRITE_DATA = $2000
   // Max number of chars processed at once
   .const NUM_PROCESSING = 8
   // Distance value meaning not found
@@ -7640,6 +7610,36 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_PROCESSINGSPRITE_STATUS = $b
   .const OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR = $c
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_XMSB = $d010
+  .label SPRITES_COLS = $d027
+  .label SPRITES_ENABLE = $d015
+  .label SPRITES_EXPAND_Y = $d017
+  .label SPRITES_MC = $d01c
+  .label SPRITES_EXPAND_X = $d01d
+  .label RASTER = $d012
+  .label VIC_CONTROL = $d011
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The address of the CHARGEN character set
+  .label CHARGEN = $d000
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
+  // Address of the screen
+  .label SCREEN = $400
+  // Sprite data for the animating sprites
+  .label SPRITE_DATA = $2000
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
@@ -10470,45 +10470,15 @@ Score: 1113354
   .const BORDER_YPOS_BOTTOM = $fa
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_XMSB = $d010
-  .label SPRITES_COLS = $d027
-  .label SPRITES_ENABLE = $d015
-  .label SPRITES_EXPAND_Y = $d017
-  .label SPRITES_MC = $d01c
-  .label SPRITES_EXPAND_X = $d01d
-  .label RASTER = $d012
-  .label VIC_CONTROL = $d011
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
-  // The address of the CHARGEN character set
-  .label CHARGEN = $d000
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   .const LIGHT_BLUE = $e
-  // Address of the screen
-  .label SCREEN = $400
-  // Sprite data for the animating sprites
-  .label SPRITE_DATA = $2000
   // Max number of chars processed at once
   .const NUM_PROCESSING = 8
   // Distance value meaning not found
@@ -10532,6 +10502,36 @@ Score: 1113354
   .const OFFSET_STRUCT_PROCESSINGSPRITE_STATUS = $b
   .const OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR = $c
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_XMSB = $d010
+  .label SPRITES_COLS = $d027
+  .label SPRITES_ENABLE = $d015
+  .label SPRITES_EXPAND_Y = $d017
+  .label SPRITES_MC = $d01c
+  .label SPRITES_EXPAND_X = $d01d
+  .label RASTER = $d012
+  .label VIC_CONTROL = $d011
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The address of the CHARGEN character set
+  .label CHARGEN = $d000
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
+  // Address of the screen
+  .label SCREEN = $400
+  // Sprite data for the animating sprites
+  .label SPRITE_DATA = $2000
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
diff --git a/src/test/ref/complex/medusa/medusa.asm b/src/test/ref/complex/medusa/medusa.asm
index f2b990ec1..932e20aa5 100644
--- a/src/test/ref/complex/medusa/medusa.asm
+++ b/src/test/ref/complex/medusa/medusa.asm
@@ -3,11 +3,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  // The colors of the C64
+  .const BLACK = 0
   .label BGCOL = $d021
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
   .label SCREEN = $400
 main: {
     // *BGCOL = BLACK
diff --git a/src/test/ref/complex/medusa/medusa.log b/src/test/ref/complex/medusa/medusa.log
index 4aa0b372a..061ef32b0 100644
--- a/src/test/ref/complex/medusa/medusa.log
+++ b/src/test/ref/complex/medusa/medusa.log
@@ -505,11 +505,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The colors of the C64
+  .const BLACK = 0
   .label BGCOL = $d021
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
   .label SCREEN = $400
   // @begin
 __bbegin:
@@ -690,11 +690,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The colors of the C64
+  .const BLACK = 0
   .label BGCOL = $d021
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
   .label SCREEN = $400
   // @begin
 __bbegin:
@@ -994,11 +994,11 @@ Score: 797
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The colors of the C64
+  .const BLACK = 0
   .label BGCOL = $d021
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
   .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/complex/prebob/grid-bobs.asm b/src/test/ref/complex/prebob/grid-bobs.asm
index f48f6c6d3..5326f528c 100644
--- a/src/test/ref/complex/prebob/grid-bobs.asm
+++ b/src/test/ref/complex/prebob/grid-bobs.asm
@@ -2,22 +2,7 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D018 = $d018
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const KEY_SPACE = $3c
-  // The BASIC screen
-  .label BASIC_SCREEN = $400
-  // The BASIC charset
-  .label BASIC_CHARSET = $1000
-  // The BOB screen
-  .label BOB_SCREEN = $2800
-  // The BOB charset
-  .label BOB_CHARSET = $2000
   // The number of different X-shifts
   .const BOB_SHIFTS_X = 4
   // The number of different Y-shifts
@@ -29,6 +14,21 @@
   .const SIZEOF_POINTER = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D018 = $d018
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // The BASIC screen
+  .label BASIC_SCREEN = $400
+  // The BASIC charset
+  .label BASIC_CHARSET = $1000
+  // The BOB screen
+  .label BOB_SCREEN = $2800
+  // The BOB charset
+  .label BOB_CHARSET = $2000
   // BOB charset ID of the next glyph to be added
   .label bob_charset_next_id = $11
   // Current index within the progress cursor (0-7)
@@ -422,9 +422,9 @@ renderBobCleanup: {
 }
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = BOB_SCREEN
     .const c = 0
     .const num = $3e8
+    .label str = BOB_SCREEN
     .label end = str+num
     .label dst = $19
     lda #<str
diff --git a/src/test/ref/complex/prebob/grid-bobs.log b/src/test/ref/complex/prebob/grid-bobs.log
index 3f334197d..5a37c65f9 100644
--- a/src/test/ref/complex/prebob/grid-bobs.log
+++ b/src/test/ref/complex/prebob/grid-bobs.log
@@ -4580,22 +4580,7 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D018 = $d018
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const KEY_SPACE = $3c
-  // The BASIC screen
-  .label BASIC_SCREEN = $400
-  // The BASIC charset
-  .label BASIC_CHARSET = $1000
-  // The BOB screen
-  .label BOB_SCREEN = $2800
-  // The BOB charset
-  .label BOB_CHARSET = $2000
   // The number of different X-shifts
   .const BOB_SHIFTS_X = 4
   // The number of different Y-shifts
@@ -4607,6 +4592,21 @@ Target platform is c64basic / MOS6502X
   .const SIZEOF_POINTER = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D018 = $d018
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // The BASIC screen
+  .label BASIC_SCREEN = $400
+  // The BASIC charset
+  .label BASIC_CHARSET = $1000
+  // The BOB screen
+  .label BOB_SCREEN = $2800
+  // The BOB charset
+  .label BOB_CHARSET = $2000
   // BOB charset ID of the next glyph to be added
   .label bob_charset_next_id = $22
   // Current index within the progress cursor (0-7)
@@ -5246,9 +5246,9 @@ renderBobCleanup: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = BOB_SCREEN
     .const c = 0
     .const num = $3e8
+    .label str = BOB_SCREEN
     .label end = str+num
     .label dst = $13
     // [104] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -6690,22 +6690,7 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D018 = $d018
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const KEY_SPACE = $3c
-  // The BASIC screen
-  .label BASIC_SCREEN = $400
-  // The BASIC charset
-  .label BASIC_CHARSET = $1000
-  // The BOB screen
-  .label BOB_SCREEN = $2800
-  // The BOB charset
-  .label BOB_CHARSET = $2000
   // The number of different X-shifts
   .const BOB_SHIFTS_X = 4
   // The number of different Y-shifts
@@ -6717,6 +6702,21 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const SIZEOF_POINTER = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D018 = $d018
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // The BASIC screen
+  .label BASIC_SCREEN = $400
+  // The BASIC charset
+  .label BASIC_CHARSET = $1000
+  // The BOB screen
+  .label BOB_SCREEN = $2800
+  // The BOB charset
+  .label BOB_CHARSET = $2000
   // BOB charset ID of the next glyph to be added
   .label bob_charset_next_id = $11
   // Current index within the progress cursor (0-7)
@@ -7312,9 +7312,9 @@ renderBobCleanup: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = BOB_SCREEN
     .const c = 0
     .const num = $3e8
+    .label str = BOB_SCREEN
     .label end = str+num
     .label dst = $19
     // [104] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -9011,22 +9011,7 @@ Score: 3582851
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D018 = $d018
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const KEY_SPACE = $3c
-  // The BASIC screen
-  .label BASIC_SCREEN = $400
-  // The BASIC charset
-  .label BASIC_CHARSET = $1000
-  // The BOB screen
-  .label BOB_SCREEN = $2800
-  // The BOB charset
-  .label BOB_CHARSET = $2000
   // The number of different X-shifts
   .const BOB_SHIFTS_X = 4
   // The number of different Y-shifts
@@ -9038,6 +9023,21 @@ Score: 3582851
   .const SIZEOF_POINTER = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D018 = $d018
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // The BASIC screen
+  .label BASIC_SCREEN = $400
+  // The BASIC charset
+  .label BASIC_CHARSET = $1000
+  // The BOB screen
+  .label BOB_SCREEN = $2800
+  // The BOB charset
+  .label BOB_CHARSET = $2000
   // BOB charset ID of the next glyph to be added
   .label bob_charset_next_id = $11
   // Current index within the progress cursor (0-7)
@@ -9604,9 +9604,9 @@ renderBobCleanup: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = BOB_SCREEN
     .const c = 0
     .const num = $3e8
+    .label str = BOB_SCREEN
     .label end = str+num
     .label dst = $19
     // [104] phi from memset to memset::@1 [phi:memset->memset::@1]
diff --git a/src/test/ref/complex/prebob/vogel-bobs.asm b/src/test/ref/complex/prebob/vogel-bobs.asm
index aed885591..300eab9e8 100644
--- a/src/test/ref/complex/prebob/vogel-bobs.asm
+++ b/src/test/ref/complex/prebob/vogel-bobs.asm
@@ -2,22 +2,7 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D018 = $d018
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const KEY_SPACE = $3c
-  // The BASIC screen
-  .label SCREEN_BASIC = $400
-  // The BASIC charset
-  .label CHARSET_BASIC = $1000
-  // The BOB screen
-  .label BOB_SCREEN = $2800
-  // The BOB charset
-  .label BOB_CHARSET = $2000
   // The number of different X-shifts
   .const BOB_SHIFTS_X = 4
   // The number of different Y-shifts
@@ -29,6 +14,21 @@
   .const SIZEOF_POINTER = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D018 = $d018
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // The BASIC screen
+  .label SCREEN_BASIC = $400
+  // The BASIC charset
+  .label CHARSET_BASIC = $1000
+  // The BOB screen
+  .label BOB_SCREEN = $2800
+  // The BOB charset
+  .label BOB_CHARSET = $2000
   .label COS = SIN+$40
   // BOB charset ID of the next glyph to be added
   .label bob_charset_next_id = 9
@@ -481,9 +481,9 @@ renderBobCleanup: {
 }
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = BOB_SCREEN
     .const c = 0
     .const num = $3e8
+    .label str = BOB_SCREEN
     .label end = str+num
     .label dst = $c
     lda #<str
diff --git a/src/test/ref/complex/prebob/vogel-bobs.log b/src/test/ref/complex/prebob/vogel-bobs.log
index a42067ad8..40f61410d 100644
--- a/src/test/ref/complex/prebob/vogel-bobs.log
+++ b/src/test/ref/complex/prebob/vogel-bobs.log
@@ -4932,22 +4932,7 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D018 = $d018
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const KEY_SPACE = $3c
-  // The BASIC screen
-  .label SCREEN_BASIC = $400
-  // The BASIC charset
-  .label CHARSET_BASIC = $1000
-  // The BOB screen
-  .label BOB_SCREEN = $2800
-  // The BOB charset
-  .label BOB_CHARSET = $2000
   // The number of different X-shifts
   .const BOB_SHIFTS_X = 4
   // The number of different Y-shifts
@@ -4959,6 +4944,21 @@ Target platform is c64basic / MOS6502X
   .const SIZEOF_POINTER = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D018 = $d018
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // The BASIC screen
+  .label SCREEN_BASIC = $400
+  // The BASIC charset
+  .label CHARSET_BASIC = $1000
+  // The BOB screen
+  .label BOB_SCREEN = $2800
+  // The BOB charset
+  .label BOB_CHARSET = $2000
   .label COS = SIN+$40
   // BOB charset ID of the next glyph to be added
   .label bob_charset_next_id = $1c
@@ -5778,9 +5778,9 @@ renderBobCleanup: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = BOB_SCREEN
     .const c = 0
     .const num = $3e8
+    .label str = BOB_SCREEN
     .label end = str+num
     .label dst = $d
     // [138] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -7416,22 +7416,7 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D018 = $d018
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const KEY_SPACE = $3c
-  // The BASIC screen
-  .label SCREEN_BASIC = $400
-  // The BASIC charset
-  .label CHARSET_BASIC = $1000
-  // The BOB screen
-  .label BOB_SCREEN = $2800
-  // The BOB charset
-  .label BOB_CHARSET = $2000
   // The number of different X-shifts
   .const BOB_SHIFTS_X = 4
   // The number of different Y-shifts
@@ -7443,6 +7428,21 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const SIZEOF_POINTER = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D018 = $d018
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // The BASIC screen
+  .label SCREEN_BASIC = $400
+  // The BASIC charset
+  .label CHARSET_BASIC = $1000
+  // The BOB screen
+  .label BOB_SCREEN = $2800
+  // The BOB charset
+  .label BOB_CHARSET = $2000
   .label COS = SIN+$40
   // BOB charset ID of the next glyph to be added
   .label bob_charset_next_id = 9
@@ -8148,9 +8148,9 @@ renderBobCleanup: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = BOB_SCREEN
     .const c = 0
     .const num = $3e8
+    .label str = BOB_SCREEN
     .label end = str+num
     .label dst = $c
     // [138] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -9935,22 +9935,7 @@ Score: 3510799
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D018 = $d018
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const KEY_SPACE = $3c
-  // The BASIC screen
-  .label SCREEN_BASIC = $400
-  // The BASIC charset
-  .label CHARSET_BASIC = $1000
-  // The BOB screen
-  .label BOB_SCREEN = $2800
-  // The BOB charset
-  .label BOB_CHARSET = $2000
   // The number of different X-shifts
   .const BOB_SHIFTS_X = 4
   // The number of different Y-shifts
@@ -9962,6 +9947,21 @@ Score: 3510799
   .const SIZEOF_POINTER = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D018 = $d018
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // The BASIC screen
+  .label SCREEN_BASIC = $400
+  // The BASIC charset
+  .label CHARSET_BASIC = $1000
+  // The BOB screen
+  .label BOB_SCREEN = $2800
+  // The BOB charset
+  .label BOB_CHARSET = $2000
   .label COS = SIN+$40
   // BOB charset ID of the next glyph to be added
   .label bob_charset_next_id = 9
@@ -10633,9 +10633,9 @@ renderBobCleanup: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = BOB_SCREEN
     .const c = 0
     .const num = $3e8
+    .label str = BOB_SCREEN
     .label end = str+num
     .label dst = $c
     // [138] phi from memset to memset::@1 [phi:memset->memset::@1]
diff --git a/src/test/ref/complex/prebob/vogel-sprites.asm b/src/test/ref/complex/prebob/vogel-sprites.asm
index 14faf0ee6..68681d2f3 100644
--- a/src/test/ref/complex/prebob/vogel-sprites.asm
+++ b/src/test/ref/complex/prebob/vogel-sprites.asm
@@ -2,6 +2,18 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
+  .const VIC_RST8 = $80
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // The colors of the C64
+  .const BLACK = 0
+  .const GREEN = 5
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const KEY_SPACE = $3c
+  // The number of BOBs to render
+  .const NUM_BOBS = $10
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -10,22 +22,10 @@
   .label RASTER = $d012
   .label BORDERCOL = $d020
   .label D011 = $d011
-  .const VIC_RST8 = $80
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
-  // The colors of the C64
-  .const BLACK = 0
-  .const GREEN = 5
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
-  .const KEY_SPACE = $3c
   // The BASIC screen
   .label SCREEN = $400
-  // The number of BOBs to render
-  .const NUM_BOBS = $10
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label COS = SIN+$40
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = SCREEN+$3f8
@@ -587,9 +587,9 @@ init: {
 }
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = ' '
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 5
     lda #<str
diff --git a/src/test/ref/complex/prebob/vogel-sprites.log b/src/test/ref/complex/prebob/vogel-sprites.log
index fdcef72ec..4f4057e6a 100644
--- a/src/test/ref/complex/prebob/vogel-sprites.log
+++ b/src/test/ref/complex/prebob/vogel-sprites.log
@@ -3219,6 +3219,18 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const VIC_RST8 = $80
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // The colors of the C64
+  .const BLACK = 0
+  .const GREEN = 5
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const KEY_SPACE = $3c
+  // The number of BOBs to render
+  .const NUM_BOBS = $10
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -3227,22 +3239,10 @@ Target platform is c64basic / MOS6502X
   .label RASTER = $d012
   .label BORDERCOL = $d020
   .label D011 = $d011
-  .const VIC_RST8 = $80
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
-  // The colors of the C64
-  .const BLACK = 0
-  .const GREEN = 5
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
-  .const KEY_SPACE = $3c
   // The BASIC screen
   .label SCREEN = $400
-  // The number of BOBs to render
-  .const NUM_BOBS = $10
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label COS = SIN+$40
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = SCREEN+$3f8
@@ -4308,9 +4308,9 @@ init: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = ' '
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = $10
     // [187] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -5186,6 +5186,18 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const VIC_RST8 = $80
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // The colors of the C64
+  .const BLACK = 0
+  .const GREEN = 5
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const KEY_SPACE = $3c
+  // The number of BOBs to render
+  .const NUM_BOBS = $10
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -5194,22 +5206,10 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label RASTER = $d012
   .label BORDERCOL = $d020
   .label D011 = $d011
-  .const VIC_RST8 = $80
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
-  // The colors of the C64
-  .const BLACK = 0
-  .const GREEN = 5
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
-  .const KEY_SPACE = $3c
   // The BASIC screen
   .label SCREEN = $400
-  // The number of BOBs to render
-  .const NUM_BOBS = $10
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label COS = SIN+$40
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = SCREEN+$3f8
@@ -6108,9 +6108,9 @@ init: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = ' '
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 5
     // [187] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -7157,6 +7157,18 @@ Score: 74020
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const VIC_RST8 = $80
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // The colors of the C64
+  .const BLACK = 0
+  .const GREEN = 5
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const KEY_SPACE = $3c
+  // The number of BOBs to render
+  .const NUM_BOBS = $10
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -7165,22 +7177,10 @@ Score: 74020
   .label RASTER = $d012
   .label BORDERCOL = $d020
   .label D011 = $d011
-  .const VIC_RST8 = $80
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
-  // The colors of the C64
-  .const BLACK = 0
-  .const GREEN = 5
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
-  .const KEY_SPACE = $3c
   // The BASIC screen
   .label SCREEN = $400
-  // The number of BOBs to render
-  .const NUM_BOBS = $10
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label COS = SIN+$40
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = SCREEN+$3f8
@@ -8045,9 +8045,9 @@ init: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = ' '
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 5
     // [187] phi from memset to memset::@1 [phi:memset->memset::@1]
diff --git a/src/test/ref/complex/splines/truetype-splines.asm b/src/test/ref/complex/splines/truetype-splines.asm
index 6eb5cae93..866fc8cc0 100644
--- a/src/test/ref/complex/splines/truetype-splines.asm
+++ b/src/test/ref/complex/splines/truetype-splines.asm
@@ -2,17 +2,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label RASTER = $d012
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const WHITE = 1
-  .label BITMAP_SCREEN = $5c00
-  .label BITMAP_GRAPHICS = $6000
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
   .const LINE_TO = 2
@@ -21,6 +14,13 @@
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SEGMENT_VIA = 5
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label D011 = $d011
+  .label D018 = $d018
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  .label BITMAP_SCREEN = $5c00
+  .label BITMAP_GRAPHICS = $6000
   .label COS = SIN+$40
 main: {
     .const vicSelectGfxBank1_toDd001_return = 3^(>BITMAP_SCREEN)/$40
diff --git a/src/test/ref/complex/splines/truetype-splines.log b/src/test/ref/complex/splines/truetype-splines.log
index a13e46e97..7b63eda6b 100644
--- a/src/test/ref/complex/splines/truetype-splines.log
+++ b/src/test/ref/complex/splines/truetype-splines.log
@@ -5228,17 +5228,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const WHITE = 1
-  .label BITMAP_SCREEN = $5c00
-  .label BITMAP_GRAPHICS = $6000
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
   .const LINE_TO = 2
@@ -5247,6 +5240,13 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SEGMENT_VIA = 5
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label D011 = $d011
+  .label D018 = $d018
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  .label BITMAP_SCREEN = $5c00
+  .label BITMAP_GRAPHICS = $6000
   .label COS = SIN+$40
   // @begin
 __bbegin:
@@ -8702,17 +8702,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const WHITE = 1
-  .label BITMAP_SCREEN = $5c00
-  .label BITMAP_GRAPHICS = $6000
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
   .const LINE_TO = 2
@@ -8721,6 +8714,13 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SEGMENT_VIA = 5
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label D011 = $d011
+  .label D018 = $d018
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  .label BITMAP_SCREEN = $5c00
+  .label BITMAP_GRAPHICS = $6000
   .label COS = SIN+$40
   // @begin
 __bbegin:
@@ -11910,17 +11910,10 @@ Score: 674154
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const WHITE = 1
-  .label BITMAP_SCREEN = $5c00
-  .label BITMAP_GRAPHICS = $6000
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
   .const LINE_TO = 2
@@ -11929,6 +11922,13 @@ Score: 674154
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SEGMENT_VIA = 5
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label D011 = $d011
+  .label D018 = $d018
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  .label BITMAP_SCREEN = $5c00
+  .label BITMAP_GRAPHICS = $6000
   .label COS = SIN+$40
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/complex/spritescroller/spritescroller.asm b/src/test/ref/complex/spritescroller/spritescroller.asm
index 9e5972184..a4d07b5c0 100644
--- a/src/test/ref/complex/spritescroller/spritescroller.asm
+++ b/src/test/ref/complex/spritescroller/spritescroller.asm
@@ -4,6 +4,17 @@
 .pc = $80d "Program"
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
+  .const PROCPORT_RAM_CHARROM = 1
+  // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
+  .const PROCPORT_BASIC_KERNEL_IO = 7
+  .const WHITE = 1
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const toSpritePtr1_return = SPRITES/$40
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -16,32 +27,21 @@
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
-  .const PROCPORT_RAM_CHARROM = 1
-  // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
-  .const PROCPORT_BASIC_KERNEL_IO = 7
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
-  .const WHITE = 1
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
   .label CHARSET_DEFAULT = $1000
   .label SPRITES = $3000
   .label SCREEN = $400
   // The high-value table
   .label XMOVEMENT_HI = XMOVEMENT+$100
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = $400+$3f8
-  .const toSpritePtr1_return = SPRITES/$40
   .label plex_show_idx = $d
   .label plex_sprite_idx = $e
   .label plex_sprite_msb = $f
diff --git a/src/test/ref/complex/spritescroller/spritescroller.log b/src/test/ref/complex/spritescroller/spritescroller.log
index 92ac361c2..25fd84e76 100644
--- a/src/test/ref/complex/spritescroller/spritescroller.log
+++ b/src/test/ref/complex/spritescroller/spritescroller.log
@@ -3572,6 +3572,17 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
+  .const PROCPORT_RAM_CHARROM = 1
+  // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
+  .const PROCPORT_BASIC_KERNEL_IO = 7
+  .const WHITE = 1
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const toSpritePtr1_return = SPRITES/$40
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -3584,32 +3595,21 @@ Target platform is c64basic / MOS6502X
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
-  .const PROCPORT_RAM_CHARROM = 1
-  // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
-  .const PROCPORT_BASIC_KERNEL_IO = 7
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
-  .const WHITE = 1
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
   .label CHARSET_DEFAULT = $1000
   .label SPRITES = $3000
   .label SCREEN = $400
   // The high-value table
   .label XMOVEMENT_HI = XMOVEMENT+$100
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = $400+$3f8
-  .const toSpritePtr1_return = SPRITES/$40
   .label plex_show_idx = $2b
   .label plex_sprite_idx = $2c
   .label plex_sprite_msb = $2d
@@ -5483,6 +5483,17 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
+  .const PROCPORT_RAM_CHARROM = 1
+  // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
+  .const PROCPORT_BASIC_KERNEL_IO = 7
+  .const WHITE = 1
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const toSpritePtr1_return = SPRITES/$40
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -5495,32 +5506,21 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
-  .const PROCPORT_RAM_CHARROM = 1
-  // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
-  .const PROCPORT_BASIC_KERNEL_IO = 7
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
-  .const WHITE = 1
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
   .label CHARSET_DEFAULT = $1000
   .label SPRITES = $3000
   .label SCREEN = $400
   // The high-value table
   .label XMOVEMENT_HI = XMOVEMENT+$100
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = $400+$3f8
-  .const toSpritePtr1_return = SPRITES/$40
   .label plex_show_idx = $d
   .label plex_sprite_idx = $e
   .label plex_sprite_msb = $f
@@ -7431,6 +7431,17 @@ Score: 159127
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
+  .const PROCPORT_RAM_CHARROM = 1
+  // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
+  .const PROCPORT_BASIC_KERNEL_IO = 7
+  .const WHITE = 1
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const toSpritePtr1_return = SPRITES/$40
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -7443,32 +7454,21 @@ Score: 159127
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
-  .const PROCPORT_RAM_CHARROM = 1
-  // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
-  .const PROCPORT_BASIC_KERNEL_IO = 7
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
-  .const WHITE = 1
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
   .label CHARSET_DEFAULT = $1000
   .label SPRITES = $3000
   .label SCREEN = $400
   // The high-value table
   .label XMOVEMENT_HI = XMOVEMENT+$100
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = $400+$3f8
-  .const toSpritePtr1_return = SPRITES/$40
   .label plex_show_idx = $d
   .label plex_sprite_idx = $e
   .label plex_sprite_msb = $f
diff --git a/src/test/ref/complex/tetris/test-sprites.asm b/src/test/ref/complex/tetris/test-sprites.asm
index 1940aafcc..48b5d3073 100644
--- a/src/test/ref/complex/tetris/test-sprites.asm
+++ b/src/test/ref/complex/tetris/test-sprites.asm
@@ -5,6 +5,21 @@
   .const CIA_INTERRUPT_CLEAR = $7f
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  // The Y-position of the first sprite row
+  .const SPRITES_FIRST_YPOS = $31
+  // The line of the first IRQ
+  .const IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS+$13
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
@@ -19,16 +34,10 @@
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The CIA#2: Serial bus, RS-232, VIC memory bank
@@ -37,8 +46,6 @@
   .label CIA1_INTERRUPT = $dc0d
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
   // Address of the first screen
   .label PLAYFIELD_SCREEN_1 = $400
   // Address of the second screen
@@ -51,14 +58,7 @@
   .label PLAYFIELD_SPRITES = $3000
   // Address of the charset
   .label PLAYFIELD_CHARSET = $2800
-  // The Y-position of the first sprite row
-  .const SPRITES_FIRST_YPOS = $31
-  // The line of the first IRQ
-  .const IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS+$13
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label SIN_SPRITE = $2800
-  .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
   .label render_screen_showing = 5
   .label irq_raster_next = 6
   .label irq_sprite_ypos = 7
diff --git a/src/test/ref/complex/tetris/test-sprites.log b/src/test/ref/complex/tetris/test-sprites.log
index 444aec8c1..aefec702f 100644
--- a/src/test/ref/complex/tetris/test-sprites.log
+++ b/src/test/ref/complex/tetris/test-sprites.log
@@ -1689,6 +1689,21 @@ Target platform is c64basic / MOS6502X
   .const CIA_INTERRUPT_CLEAR = $7f
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  // The Y-position of the first sprite row
+  .const SPRITES_FIRST_YPOS = $31
+  // The line of the first IRQ
+  .const IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS+$13
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
@@ -1703,16 +1718,10 @@ Target platform is c64basic / MOS6502X
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The CIA#2: Serial bus, RS-232, VIC memory bank
@@ -1721,8 +1730,6 @@ Target platform is c64basic / MOS6502X
   .label CIA1_INTERRUPT = $dc0d
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
   // Address of the first screen
   .label PLAYFIELD_SCREEN_1 = $400
   // Address of the second screen
@@ -1735,14 +1742,7 @@ Target platform is c64basic / MOS6502X
   .label PLAYFIELD_SPRITES = $3000
   // Address of the charset
   .label PLAYFIELD_CHARSET = $2800
-  // The Y-position of the first sprite row
-  .const SPRITES_FIRST_YPOS = $31
-  // The line of the first IRQ
-  .const IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS+$13
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label SIN_SPRITE = $2800
-  .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
   .label render_screen_showing = $a
   .label irq_raster_next = $b
   .label irq_sprite_ypos = $c
@@ -2567,6 +2567,21 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_INTERRUPT_CLEAR = $7f
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  // The Y-position of the first sprite row
+  .const SPRITES_FIRST_YPOS = $31
+  // The line of the first IRQ
+  .const IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS+$13
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
@@ -2581,16 +2596,10 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The CIA#2: Serial bus, RS-232, VIC memory bank
@@ -2599,8 +2608,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label CIA1_INTERRUPT = $dc0d
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
   // Address of the first screen
   .label PLAYFIELD_SCREEN_1 = $400
   // Address of the second screen
@@ -2613,14 +2620,7 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label PLAYFIELD_SPRITES = $3000
   // Address of the charset
   .label PLAYFIELD_CHARSET = $2800
-  // The Y-position of the first sprite row
-  .const SPRITES_FIRST_YPOS = $31
-  // The line of the first IRQ
-  .const IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS+$13
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label SIN_SPRITE = $2800
-  .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
   .label render_screen_showing = 5
   .label irq_raster_next = 6
   .label irq_sprite_ypos = 7
@@ -3547,6 +3547,21 @@ Score: 11662
   .const CIA_INTERRUPT_CLEAR = $7f
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  // The Y-position of the first sprite row
+  .const SPRITES_FIRST_YPOS = $31
+  // The line of the first IRQ
+  .const IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS+$13
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
@@ -3561,16 +3576,10 @@ Score: 11662
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The CIA#2: Serial bus, RS-232, VIC memory bank
@@ -3579,8 +3588,6 @@ Score: 11662
   .label CIA1_INTERRUPT = $dc0d
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
   // Address of the first screen
   .label PLAYFIELD_SCREEN_1 = $400
   // Address of the second screen
@@ -3593,14 +3600,7 @@ Score: 11662
   .label PLAYFIELD_SPRITES = $3000
   // Address of the charset
   .label PLAYFIELD_CHARSET = $2800
-  // The Y-position of the first sprite row
-  .const SPRITES_FIRST_YPOS = $31
-  // The line of the first IRQ
-  .const IRQ_RASTER_FIRST = SPRITES_FIRST_YPOS+$13
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label SIN_SPRITE = $2800
-  .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
   .label render_screen_showing = 5
   .label irq_raster_next = 6
   .label irq_sprite_ypos = 7
diff --git a/src/test/ref/complex/tetris/tetris.asm b/src/test/ref/complex/tetris/tetris.asm
index 37a87c210..ee8efa275 100644
--- a/src/test/ref/complex/tetris/tetris.asm
+++ b/src/test/ref/complex/tetris/tetris.asm
@@ -8,53 +8,17 @@
   .const CIA_INTERRUPT_CLEAR = $7f
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  .label SPRITES_ENABLE = $d015
-  .label SPRITES_EXPAND_Y = $d017
-  .label SPRITES_MC = $d01c
-  .label SPRITES_EXPAND_X = $d01d
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL1 = $d021
-  .label BGCOL2 = $d022
-  .label BGCOL3 = $d023
-  .label BGCOL4 = $d024
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#1 Interrupt for reading in ASM
-  .label CIA1_INTERRUPT = $dc0d
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const RED = 2
@@ -77,18 +41,6 @@
   .const KEY_CTRL = $3a
   .const KEY_SPACE = $3c
   .const KEY_COMMODORE = $3d
-  // Address of the first screen
-  .label PLAYFIELD_SCREEN_1 = $400
-  // Address of the second screen
-  .label PLAYFIELD_SCREEN_2 = $2c00
-  // Screen Sprite pointers on screen 1
-  .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
-  // Screen Sprite pointers on screen 2
-  .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
-  // Address of the sprites covering the playfield
-  .label PLAYFIELD_SPRITES = $3000
-  // Address of the charset
-  .label PLAYFIELD_CHARSET = $2800
   // The size of the playfield
   .const PLAYFIELD_LINES = $16
   .const PLAYFIELD_COLS = $a
@@ -115,6 +67,54 @@
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  .label SPRITES_ENABLE = $d015
+  .label SPRITES_EXPAND_Y = $d017
+  .label SPRITES_MC = $d01c
+  .label SPRITES_EXPAND_X = $d01d
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL1 = $d021
+  .label BGCOL2 = $d022
+  .label BGCOL3 = $d023
+  .label BGCOL4 = $d024
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#1 Interrupt for reading in ASM
+  .label CIA1_INTERRUPT = $dc0d
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
+  // Address of the first screen
+  .label PLAYFIELD_SCREEN_1 = $400
+  // Address of the second screen
+  .label PLAYFIELD_SCREEN_2 = $2c00
+  // Screen Sprite pointers on screen 1
+  .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
+  // Screen Sprite pointers on screen 2
+  .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
+  // Address of the sprites covering the playfield
+  .label PLAYFIELD_SPRITES = $3000
+  // Address of the charset
+  .label PLAYFIELD_CHARSET = $2800
   .label render_screen_showing = $26
   .label score_bcd = $27
   .label irq_raster_next = $2b
@@ -341,10 +341,10 @@ render_screen_swap: {
 }
 // Show the current score
 render_score: {
-    .label score_bytes = score_bcd
     .const score_offset = $28*5+$1c
     .const lines_offset = $28*1+$16
     .const level_offset = $28*$13+$1f
+    .label score_bytes = score_bcd
     .label screen = 7
     // if(render_screen_render==0)
     lda.z render_screen_render
diff --git a/src/test/ref/complex/tetris/tetris.log b/src/test/ref/complex/tetris/tetris.log
index 819e76c83..bc9582064 100644
--- a/src/test/ref/complex/tetris/tetris.log
+++ b/src/test/ref/complex/tetris/tetris.log
@@ -11628,53 +11628,17 @@ Target platform is c64basic / MOS6502X
   .const CIA_INTERRUPT_CLEAR = $7f
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  .label SPRITES_ENABLE = $d015
-  .label SPRITES_EXPAND_Y = $d017
-  .label SPRITES_MC = $d01c
-  .label SPRITES_EXPAND_X = $d01d
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL1 = $d021
-  .label BGCOL2 = $d022
-  .label BGCOL3 = $d023
-  .label BGCOL4 = $d024
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#1 Interrupt for reading in ASM
-  .label CIA1_INTERRUPT = $dc0d
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const RED = 2
@@ -11697,18 +11661,6 @@ Target platform is c64basic / MOS6502X
   .const KEY_CTRL = $3a
   .const KEY_SPACE = $3c
   .const KEY_COMMODORE = $3d
-  // Address of the first screen
-  .label PLAYFIELD_SCREEN_1 = $400
-  // Address of the second screen
-  .label PLAYFIELD_SCREEN_2 = $2c00
-  // Screen Sprite pointers on screen 1
-  .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
-  // Screen Sprite pointers on screen 2
-  .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
-  // Address of the sprites covering the playfield
-  .label PLAYFIELD_SPRITES = $3000
-  // Address of the charset
-  .label PLAYFIELD_CHARSET = $2800
   // The size of the playfield
   .const PLAYFIELD_LINES = $16
   .const PLAYFIELD_COLS = $a
@@ -11735,6 +11687,54 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  .label SPRITES_ENABLE = $d015
+  .label SPRITES_EXPAND_Y = $d017
+  .label SPRITES_MC = $d01c
+  .label SPRITES_EXPAND_X = $d01d
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL1 = $d021
+  .label BGCOL2 = $d022
+  .label BGCOL3 = $d023
+  .label BGCOL4 = $d024
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#1 Interrupt for reading in ASM
+  .label CIA1_INTERRUPT = $dc0d
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
+  // Address of the first screen
+  .label PLAYFIELD_SCREEN_1 = $400
+  // Address of the second screen
+  .label PLAYFIELD_SCREEN_2 = $2c00
+  // Screen Sprite pointers on screen 1
+  .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
+  // Screen Sprite pointers on screen 2
+  .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
+  // Address of the sprites covering the playfield
+  .label PLAYFIELD_SPRITES = $3000
+  // Address of the charset
+  .label PLAYFIELD_CHARSET = $2800
   .label render_screen_showing = $70
   .label score_bcd = $71
   .label irq_raster_next = $75
@@ -12226,10 +12226,10 @@ render_screen_swap: {
   // render_score
 // Show the current score
 render_score: {
-    .label score_bytes = score_bcd
     .const score_offset = $28*5+$1c
     .const lines_offset = $28*1+$16
     .const level_offset = $28*$13+$1f
+    .label score_bytes = score_bcd
     .label screen = 5
     // [74] if((byte) render_screen_render#18==(byte) 0) goto render_score::@1 -- vbuz1_eq_0_then_la1 
     lda.z render_screen_render
@@ -16778,53 +16778,17 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_INTERRUPT_CLEAR = $7f
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  .label SPRITES_ENABLE = $d015
-  .label SPRITES_EXPAND_Y = $d017
-  .label SPRITES_MC = $d01c
-  .label SPRITES_EXPAND_X = $d01d
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL1 = $d021
-  .label BGCOL2 = $d022
-  .label BGCOL3 = $d023
-  .label BGCOL4 = $d024
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#1 Interrupt for reading in ASM
-  .label CIA1_INTERRUPT = $dc0d
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const RED = 2
@@ -16847,18 +16811,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const KEY_CTRL = $3a
   .const KEY_SPACE = $3c
   .const KEY_COMMODORE = $3d
-  // Address of the first screen
-  .label PLAYFIELD_SCREEN_1 = $400
-  // Address of the second screen
-  .label PLAYFIELD_SCREEN_2 = $2c00
-  // Screen Sprite pointers on screen 1
-  .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
-  // Screen Sprite pointers on screen 2
-  .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
-  // Address of the sprites covering the playfield
-  .label PLAYFIELD_SPRITES = $3000
-  // Address of the charset
-  .label PLAYFIELD_CHARSET = $2800
   // The size of the playfield
   .const PLAYFIELD_LINES = $16
   .const PLAYFIELD_COLS = $a
@@ -16885,6 +16837,54 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  .label SPRITES_ENABLE = $d015
+  .label SPRITES_EXPAND_Y = $d017
+  .label SPRITES_MC = $d01c
+  .label SPRITES_EXPAND_X = $d01d
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL1 = $d021
+  .label BGCOL2 = $d022
+  .label BGCOL3 = $d023
+  .label BGCOL4 = $d024
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#1 Interrupt for reading in ASM
+  .label CIA1_INTERRUPT = $dc0d
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
+  // Address of the first screen
+  .label PLAYFIELD_SCREEN_1 = $400
+  // Address of the second screen
+  .label PLAYFIELD_SCREEN_2 = $2c00
+  // Screen Sprite pointers on screen 1
+  .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
+  // Screen Sprite pointers on screen 2
+  .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
+  // Address of the sprites covering the playfield
+  .label PLAYFIELD_SPRITES = $3000
+  // Address of the charset
+  .label PLAYFIELD_CHARSET = $2800
   .label render_screen_showing = $26
   .label score_bcd = $27
   .label irq_raster_next = $2b
@@ -17351,10 +17351,10 @@ render_screen_swap: {
   // render_score
 // Show the current score
 render_score: {
-    .label score_bytes = score_bcd
     .const score_offset = $28*5+$1c
     .const lines_offset = $28*1+$16
     .const level_offset = $28*$13+$1f
+    .label score_bytes = score_bcd
     .label screen = 7
     // [74] if((byte) render_screen_render#18==(byte) 0) goto render_score::@1 -- vbuz1_eq_0_then_la1 
     lda.z render_screen_render
@@ -22125,53 +22125,17 @@ Score: 3348915
   .const CIA_INTERRUPT_CLEAR = $7f
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  .label SPRITES_ENABLE = $d015
-  .label SPRITES_EXPAND_Y = $d017
-  .label SPRITES_MC = $d01c
-  .label SPRITES_EXPAND_X = $d01d
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label BGCOL1 = $d021
-  .label BGCOL2 = $d022
-  .label BGCOL3 = $d023
-  .label BGCOL4 = $d024
-  .label VIC_CONTROL = $d011
-  .label D011 = $d011
   .const VIC_ECM = $40
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // VIC II IRQ Status Register
-  .label IRQ_STATUS = $d019
-  // VIC II IRQ Enable Register
-  .label IRQ_ENABLE = $d01a
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // Color Ram
-  .label COLS = $d800
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#1 Interrupt for reading in ASM
-  .label CIA1_INTERRUPT = $dc0d
-  // The vector used when the HARDWARE serves IRQ interrupts
-  .label HARDWARE_IRQ = $fffe
   // The colors of the C64
   .const BLACK = 0
   .const RED = 2
@@ -22194,18 +22158,6 @@ Score: 3348915
   .const KEY_CTRL = $3a
   .const KEY_SPACE = $3c
   .const KEY_COMMODORE = $3d
-  // Address of the first screen
-  .label PLAYFIELD_SCREEN_1 = $400
-  // Address of the second screen
-  .label PLAYFIELD_SCREEN_2 = $2c00
-  // Screen Sprite pointers on screen 1
-  .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
-  // Screen Sprite pointers on screen 2
-  .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
-  // Address of the sprites covering the playfield
-  .label PLAYFIELD_SPRITES = $3000
-  // Address of the charset
-  .label PLAYFIELD_CHARSET = $2800
   // The size of the playfield
   .const PLAYFIELD_LINES = $16
   .const PLAYFIELD_COLS = $a
@@ -22232,6 +22184,54 @@ Score: 3348915
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  .label SPRITES_ENABLE = $d015
+  .label SPRITES_EXPAND_Y = $d017
+  .label SPRITES_MC = $d01c
+  .label SPRITES_EXPAND_X = $d01d
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label BGCOL1 = $d021
+  .label BGCOL2 = $d022
+  .label BGCOL3 = $d023
+  .label BGCOL4 = $d024
+  .label VIC_CONTROL = $d011
+  .label D011 = $d011
+  .label D018 = $d018
+  // VIC II IRQ Status Register
+  .label IRQ_STATUS = $d019
+  // VIC II IRQ Enable Register
+  .label IRQ_ENABLE = $d01a
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // Color Ram
+  .label COLS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#1 Interrupt for reading in ASM
+  .label CIA1_INTERRUPT = $dc0d
+  // The vector used when the HARDWARE serves IRQ interrupts
+  .label HARDWARE_IRQ = $fffe
+  // Address of the first screen
+  .label PLAYFIELD_SCREEN_1 = $400
+  // Address of the second screen
+  .label PLAYFIELD_SCREEN_2 = $2c00
+  // Screen Sprite pointers on screen 1
+  .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
+  // Screen Sprite pointers on screen 2
+  .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
+  // Address of the sprites covering the playfield
+  .label PLAYFIELD_SPRITES = $3000
+  // Address of the charset
+  .label PLAYFIELD_CHARSET = $2800
   .label render_screen_showing = $26
   .label score_bcd = $27
   .label irq_raster_next = $2b
@@ -22633,10 +22633,10 @@ render_screen_swap: {
   // render_score
 // Show the current score
 render_score: {
-    .label score_bytes = score_bcd
     .const score_offset = $28*5+$1c
     .const lines_offset = $28*1+$16
     .const level_offset = $28*$13+$1f
+    .label score_bytes = score_bcd
     .label screen = 7
     // if(render_screen_render==0)
     // [74] if((byte) render_screen_render#18==(byte) 0) goto render_score::@1 -- vbuz1_eq_0_then_la1 
diff --git a/src/test/ref/complex/xmega65/xmega65.asm b/src/test/ref/complex/xmega65/xmega65.asm
index 89373412c..0304c30bb 100644
--- a/src/test/ref/complex/xmega65/xmega65.asm
+++ b/src/test/ref/complex/xmega65/xmega65.asm
@@ -8,15 +8,15 @@
 .segmentdef Data [startAfter="Code", min=$8200, max=$bdff]
 .segmentdef Stack [min=$be00, max=$beff, fill]
 .segmentdef Zeropage [min=$bf00, max=$bfff, fill]
+  .const BLACK = 0
+  .const WHITE = 1
+  .const JMP = $4c
+  .const NOP = $ea
   .label RASTER = $d012
   .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BGCOL = $d021
   .label COLS = $d800
-  .const BLACK = 0
-  .const WHITE = 1
-  .const JMP = $4c
-  .const NOP = $ea
 __bbegin:
 .segment Code
 main: {
diff --git a/src/test/ref/complex/xmega65/xmega65.log b/src/test/ref/complex/xmega65/xmega65.log
index d54f46f3f..367810e5b 100644
--- a/src/test/ref/complex/xmega65/xmega65.log
+++ b/src/test/ref/complex/xmega65/xmega65.log
@@ -506,15 +506,15 @@ Target platform is custom / MOS6502X
 .segmentdef Stack [min=$be00, max=$beff, fill]
 .segmentdef Zeropage [min=$bf00, max=$bfff, fill]
   // Global Constants & labels
+  .const BLACK = 0
+  .const WHITE = 1
+  .const JMP = $4c
+  .const NOP = $ea
   .label RASTER = $d012
   .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BGCOL = $d021
   .label COLS = $d800
-  .const BLACK = 0
-  .const WHITE = 1
-  .const JMP = $4c
-  .const NOP = $ea
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -799,15 +799,15 @@ ASSEMBLER BEFORE OPTIMIZATION
 .segmentdef Stack [min=$be00, max=$beff, fill]
 .segmentdef Zeropage [min=$bf00, max=$bfff, fill]
   // Global Constants & labels
+  .const BLACK = 0
+  .const WHITE = 1
+  .const JMP = $4c
+  .const NOP = $ea
   .label RASTER = $d012
   .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BGCOL = $d021
   .label COLS = $d800
-  .const BLACK = 0
-  .const WHITE = 1
-  .const JMP = $4c
-  .const NOP = $ea
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1136,15 +1136,15 @@ Score: 1600
 .segmentdef Stack [min=$be00, max=$beff, fill]
 .segmentdef Zeropage [min=$bf00, max=$bfff, fill]
   // Global Constants & labels
+  .const BLACK = 0
+  .const WHITE = 1
+  .const JMP = $4c
+  .const NOP = $ea
   .label RASTER = $d012
   .label VIC_MEMORY = $d018
   .label SCREEN = $400
   .label BGCOL = $d021
   .label COLS = $d800
-  .const BLACK = 0
-  .const WHITE = 1
-  .const JMP = $4c
-  .const NOP = $ea
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/const-declaration.asm b/src/test/ref/const-declaration.asm
index bd969ad11..f2397408f 100644
--- a/src/test/ref/const-declaration.asm
+++ b/src/test/ref/const-declaration.asm
@@ -2,11 +2,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const LINE_LEN = $28
   .const MARGIN_TOP = 4
   .const MARGIN_LEFT = 4
   .const OFFSET = $28*5+5
+  .label SCREEN = $400
   .label BODY1 = SCREEN+MARGIN_TOP*LINE_LEN+MARGIN_LEFT
   .label BODY2 = SCREEN+OFFSET
 main: {
diff --git a/src/test/ref/const-declaration.log b/src/test/ref/const-declaration.log
index 8cacc765e..dbe9161ed 100644
--- a/src/test/ref/const-declaration.log
+++ b/src/test/ref/const-declaration.log
@@ -85,11 +85,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const LINE_LEN = $28
   .const MARGIN_TOP = 4
   .const MARGIN_LEFT = 4
   .const OFFSET = $28*5+5
+  .label SCREEN = $400
   .label BODY1 = SCREEN+MARGIN_TOP*LINE_LEN+MARGIN_LEFT
   .label BODY2 = SCREEN+OFFSET
   // @begin
@@ -141,11 +141,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const LINE_LEN = $28
   .const MARGIN_TOP = 4
   .const MARGIN_LEFT = 4
   .const OFFSET = $28*5+5
+  .label SCREEN = $400
   .label BODY1 = SCREEN+MARGIN_TOP*LINE_LEN+MARGIN_LEFT
   .label BODY2 = SCREEN+OFFSET
   // @begin
@@ -224,11 +224,11 @@ Score: 16
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const LINE_LEN = $28
   .const MARGIN_TOP = 4
   .const MARGIN_LEFT = 4
   .const OFFSET = $28*5+5
+  .label SCREEN = $400
   .label BODY1 = SCREEN+MARGIN_TOP*LINE_LEN+MARGIN_LEFT
   .label BODY2 = SCREEN+OFFSET
   // @begin
diff --git a/src/test/ref/constantmin.asm b/src/test/ref/constantmin.asm
index 08a528971..d661accc0 100644
--- a/src/test/ref/constantmin.asm
+++ b/src/test/ref/constantmin.asm
@@ -1,10 +1,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STAR = $51
-  .label VIC = $d000
   .const RED = 2
+  .label SCREEN = $400
+  .label VIC = $d000
 main: {
     // *SCREEN = STAR
     lda #STAR
diff --git a/src/test/ref/constantmin.log b/src/test/ref/constantmin.log
index 9edd0b65e..ecac14315 100644
--- a/src/test/ref/constantmin.log
+++ b/src/test/ref/constantmin.log
@@ -165,10 +165,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STAR = $51
-  .label VIC = $d000
   .const RED = 2
+  .label SCREEN = $400
+  .label VIC = $d000
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -246,10 +246,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STAR = $51
-  .label VIC = $d000
   .const RED = 2
+  .label SCREEN = $400
+  .label VIC = $d000
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -351,10 +351,10 @@ Score: 173
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STAR = $51
-  .label VIC = $d000
   .const RED = 2
+  .label SCREEN = $400
+  .label VIC = $d000
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/constants.asm b/src/test/ref/constants.asm
index 220ab38c9..a41c11c0e 100644
--- a/src/test/ref/constants.asm
+++ b/src/test/ref/constants.asm
@@ -1,9 +1,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BGCOL = $d021
   .const GREEN = 5
   .const RED = 2
+  .label BGCOL = $d021
   .label print_char_cursor = 2
   .label print_line_cursor = 4
 main: {
diff --git a/src/test/ref/constants.log b/src/test/ref/constants.log
index 801061d39..a14f24693 100644
--- a/src/test/ref/constants.log
+++ b/src/test/ref/constants.log
@@ -1594,9 +1594,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const GREEN = 5
   .const RED = 2
+  .label BGCOL = $d021
   .label print_char_cursor = 6
   .label print_line_cursor = $a
   // @begin
@@ -2291,9 +2291,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const GREEN = 5
   .const RED = 2
+  .label BGCOL = $d021
   .label print_char_cursor = 2
   .label print_line_cursor = 4
   // @begin
@@ -3128,9 +3128,9 @@ Score: 1783
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const GREEN = 5
   .const RED = 2
+  .label BGCOL = $d021
   .label print_char_cursor = 2
   .label print_line_cursor = 4
   // @begin
diff --git a/src/test/ref/cordic-atan2-16-ref.asm b/src/test/ref/cordic-atan2-16-ref.asm
index 75052143e..2c3381a32 100644
--- a/src/test/ref/cordic-atan2-16-ref.asm
+++ b/src/test/ref/cordic-atan2-16-ref.asm
@@ -12,8 +12,8 @@
   .label SCREEN = $2800
   .label print_char_cursor = 8
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label __4 = $a
     .label xw = $17
     .label yw = $19
diff --git a/src/test/ref/cordic-atan2-16-ref.log b/src/test/ref/cordic-atan2-16-ref.log
index 018a00aaf..7e0c4f328 100644
--- a/src/test/ref/cordic-atan2-16-ref.log
+++ b/src/test/ref/cordic-atan2-16-ref.log
@@ -2317,8 +2317,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label __4 = $33
     .label __6 = $39
     .label __7 = $3a
@@ -3458,8 +3458,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label __4 = $a
     .label xw = $17
     .label yw = $19
@@ -4760,8 +4760,8 @@ Score: 1044103
   // @end
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label __4 = $a
     .label xw = $17
     .label yw = $19
diff --git a/src/test/ref/cordic-atan2-16.asm b/src/test/ref/cordic-atan2-16.asm
index 63bf63e7e..2a70b36ce 100644
--- a/src/test/ref/cordic-atan2-16.asm
+++ b/src/test/ref/cordic-atan2-16.asm
@@ -11,8 +11,8 @@
   .label CHARSET = $2000
   .label SCREEN = $2800
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label __3 = 6
     .label xw = $13
     .label yw = $15
diff --git a/src/test/ref/cordic-atan2-16.log b/src/test/ref/cordic-atan2-16.log
index b88e56926..172bfffbc 100644
--- a/src/test/ref/cordic-atan2-16.log
+++ b/src/test/ref/cordic-atan2-16.log
@@ -1785,8 +1785,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label __3 = $2a
     .label xw = $1e
     .label yw = $20
@@ -2649,8 +2649,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label __3 = 6
     .label xw = $13
     .label yw = $15
@@ -3659,8 +3659,8 @@ Score: 1038677
   // @end
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label __3 = 6
     .label xw = $13
     .label yw = $15
diff --git a/src/test/ref/cordic-atan2.asm b/src/test/ref/cordic-atan2.asm
index 7df360b9b..b8a95a459 100644
--- a/src/test/ref/cordic-atan2.asm
+++ b/src/test/ref/cordic-atan2.asm
@@ -3,16 +3,16 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  // The number of iterations performed during 8-bit CORDIC atan2 calculation
+  .const CORDIC_ITERATIONS_8 = 8
   .label D018 = $d018
   // Color Ram
   .label COLS = $d800
-  // The number of iterations performed during 8-bit CORDIC atan2 calculation
-  .const CORDIC_ITERATIONS_8 = 8
   .label CHARSET = $2000
   .label SCREEN = $2800
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label screen = 4
     .label x = 3
     .label y = 2
diff --git a/src/test/ref/cordic-atan2.log b/src/test/ref/cordic-atan2.log
index b93c5f05d..588324a88 100644
--- a/src/test/ref/cordic-atan2.log
+++ b/src/test/ref/cordic-atan2.log
@@ -1475,11 +1475,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The number of iterations performed during 8-bit CORDIC atan2 calculation
+  .const CORDIC_ITERATIONS_8 = 8
   .label D018 = $d018
   // Color Ram
   .label COLS = $d800
-  // The number of iterations performed during 8-bit CORDIC atan2 calculation
-  .const CORDIC_ITERATIONS_8 = 8
   .label CHARSET = $2000
   .label SCREEN = $2800
   // @begin
@@ -1500,8 +1500,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label angle = $18
     .label screen = 4
     .label x = 3
@@ -2189,11 +2189,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The number of iterations performed during 8-bit CORDIC atan2 calculation
+  .const CORDIC_ITERATIONS_8 = 8
   .label D018 = $d018
   // Color Ram
   .label COLS = $d800
-  // The number of iterations performed during 8-bit CORDIC atan2 calculation
-  .const CORDIC_ITERATIONS_8 = 8
   .label CHARSET = $2000
   .label SCREEN = $2800
   // @begin
@@ -2214,8 +2214,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label screen = 4
     .label x = 3
     .label y = 2
@@ -3056,11 +3056,11 @@ Score: 232290
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The number of iterations performed during 8-bit CORDIC atan2 calculation
+  .const CORDIC_ITERATIONS_8 = 8
   .label D018 = $d018
   // Color Ram
   .label COLS = $d800
-  // The number of iterations performed during 8-bit CORDIC atan2 calculation
-  .const CORDIC_ITERATIONS_8 = 8
   .label CHARSET = $2000
   .label SCREEN = $2800
   // @begin
@@ -3072,8 +3072,8 @@ Score: 232290
   // @end
   // main
 main: {
-    .label col00 = COLS+$c*$28+$13
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
+    .label col00 = COLS+$c*$28+$13
     .label screen = 4
     .label x = 3
     .label y = 2
diff --git a/src/test/ref/danny-joystick-problem.asm b/src/test/ref/danny-joystick-problem.asm
index 730bac77b..a123a87af 100644
--- a/src/test/ref/danny-joystick-problem.asm
+++ b/src/test/ref/danny-joystick-problem.asm
@@ -3,10 +3,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
 main: {
     // (CIA2->PORT_B) &= 0x7f
     lda #$7f
diff --git a/src/test/ref/danny-joystick-problem.log b/src/test/ref/danny-joystick-problem.log
index 8dbcf37e9..dff6aaf50 100644
--- a/src/test/ref/danny-joystick-problem.log
+++ b/src/test/ref/danny-joystick-problem.log
@@ -268,10 +268,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -336,10 +336,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -502,10 +502,10 @@ Score: 26
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/default-font.asm b/src/test/ref/default-font.asm
index 9267dcbe2..439270dcb 100644
--- a/src/test/ref/default-font.asm
+++ b/src/test/ref/default-font.asm
@@ -52,9 +52,9 @@ main: {
 }
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = ' '
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 6
     lda #<str
diff --git a/src/test/ref/default-font.log b/src/test/ref/default-font.log
index 107d224e7..a58b73edf 100644
--- a/src/test/ref/default-font.log
+++ b/src/test/ref/default-font.log
@@ -542,9 +542,9 @@ main: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = ' '
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 7
     // [18] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -739,9 +739,9 @@ main: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = ' '
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 6
     // [18] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -971,9 +971,9 @@ main: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = ' '
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 6
     // [18] phi from memset to memset::@1 [phi:memset->memset::@1]
diff --git a/src/test/ref/double-assignment.asm b/src/test/ref/double-assignment.asm
index 18f64b488..6a66510ff 100644
--- a/src/test/ref/double-assignment.asm
+++ b/src/test/ref/double-assignment.asm
@@ -3,8 +3,8 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label screen = $400
     .const a = $c
+    .label screen = $400
     // screen[0] = a
     lda #a
     sta screen
diff --git a/src/test/ref/double-assignment.log b/src/test/ref/double-assignment.log
index fa888eb1b..fd7013cb4 100644
--- a/src/test/ref/double-assignment.log
+++ b/src/test/ref/double-assignment.log
@@ -133,8 +133,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label screen = $400
     .const a = $c
+    .label screen = $400
     // [4] *((const byte*) main::screen) ← (const byte) main::a#1 -- _deref_pbuc1=vbuc2 
     lda #a
     sta screen
@@ -184,8 +184,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label screen = $400
     .const a = $c
+    .label screen = $400
     // [4] *((const byte*) main::screen) ← (const byte) main::a#1 -- _deref_pbuc1=vbuc2 
     lda #a
     sta screen
@@ -251,8 +251,8 @@ Score: 16
   // @end
   // main
 main: {
-    .label screen = $400
     .const a = $c
+    .label screen = $400
     // screen[0] = a
     // [4] *((const byte*) main::screen) ← (const byte) main::a#1 -- _deref_pbuc1=vbuc2 
     lda #a
diff --git a/src/test/ref/double-import.asm b/src/test/ref/double-import.asm
index 214f15520..8a9a1d759 100644
--- a/src/test/ref/double-import.asm
+++ b/src/test/ref/double-import.asm
@@ -1,8 +1,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BGCOL = $d021
   .const RED = 2
+  .label BGCOL = $d021
 main: {
     // *BGCOL = RED
     lda #RED
diff --git a/src/test/ref/double-import.log b/src/test/ref/double-import.log
index fcbf937c4..5abd63fa3 100644
--- a/src/test/ref/double-import.log
+++ b/src/test/ref/double-import.log
@@ -77,8 +77,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const RED = 2
+  .label BGCOL = $d021
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -123,8 +123,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const RED = 2
+  .label BGCOL = $d021
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -190,8 +190,8 @@ Score: 12
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const RED = 2
+  .label BGCOL = $d021
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/dword.asm b/src/test/ref/dword.asm
index 4bfc943d3..62c722308 100644
--- a/src/test/ref/dword.asm
+++ b/src/test/ref/dword.asm
@@ -2,8 +2,8 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const a = $ee6b2800
+    .label SCREEN = $400
     .label b = 2
     ldx #0
   __b1:
diff --git a/src/test/ref/dword.log b/src/test/ref/dword.log
index 62db97b94..2e7a36b0b 100644
--- a/src/test/ref/dword.log
+++ b/src/test/ref/dword.log
@@ -162,8 +162,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const a = $ee6b2800
+    .label SCREEN = $400
     .label b = 3
     .label c = 7
     .label i = 2
@@ -257,8 +257,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const a = $ee6b2800
+    .label SCREEN = $400
     .label b = 2
     // [5] phi from main to main::@1 [phi:main->main::@1]
   __b1_from_main:
@@ -367,8 +367,8 @@ Score: 471
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const a = $ee6b2800
+    .label SCREEN = $400
     .label b = 2
     // [5] phi from main to main::@1 [phi:main->main::@1]
     // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
diff --git a/src/test/ref/enum-7.asm b/src/test/ref/enum-7.asm
index 2431777ee..7dfaa9958 100644
--- a/src/test/ref/enum-7.asm
+++ b/src/test/ref/enum-7.asm
@@ -4,8 +4,8 @@
 .pc = $80d "Program"
   .const RED = 0
 main: {
-    .label SCREEN = $400
     .const button_size = $18
+    .label SCREEN = $400
     // SCREEN[0] = button.color
     lda #RED
     sta SCREEN
diff --git a/src/test/ref/enum-7.log b/src/test/ref/enum-7.log
index e6327bdc2..96d9183ba 100644
--- a/src/test/ref/enum-7.log
+++ b/src/test/ref/enum-7.log
@@ -119,8 +119,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const button_size = $18
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) RED -- _deref_pbuc1=vbuc2 
     lda #RED
     sta SCREEN
@@ -175,8 +175,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const button_size = $18
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) RED -- _deref_pbuc1=vbuc2 
     lda #RED
     sta SCREEN
@@ -244,8 +244,8 @@ Score: 18
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const button_size = $18
+    .label SCREEN = $400
     // SCREEN[0] = button.color
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) RED -- _deref_pbuc1=vbuc2 
     lda #RED
diff --git a/src/test/ref/enum-8.asm b/src/test/ref/enum-8.asm
index 28ec4aabf..c88ee4087 100644
--- a/src/test/ref/enum-8.asm
+++ b/src/test/ref/enum-8.asm
@@ -4,8 +4,8 @@
 .pc = $80d "Program"
   .const RED = 2
 main: {
-    .label SCREEN = $400
     .const button_size = $18
+    .label SCREEN = $400
     // SCREEN[0] = button.color
     lda #RED
     sta SCREEN
diff --git a/src/test/ref/enum-8.log b/src/test/ref/enum-8.log
index 6da7d5c33..3cc115253 100644
--- a/src/test/ref/enum-8.log
+++ b/src/test/ref/enum-8.log
@@ -121,8 +121,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const button_size = $18
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) RED -- _deref_pbuc1=vbuc2 
     lda #RED
     sta SCREEN
@@ -177,8 +177,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const button_size = $18
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) RED -- _deref_pbuc1=vbuc2 
     lda #RED
     sta SCREEN
@@ -244,8 +244,8 @@ Score: 18
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const button_size = $18
+    .label SCREEN = $400
     // SCREEN[0] = button.color
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) RED -- _deref_pbuc1=vbuc2 
     lda #RED
diff --git a/src/test/ref/examples/3d/3d.asm b/src/test/ref/examples/3d/3d.asm
index 05a6ecf1c..a825792d9 100644
--- a/src/test/ref/examples/3d/3d.asm
+++ b/src/test/ref/examples/3d/3d.asm
@@ -5,17 +5,18 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   .const GREEN = 5
   .const LIGHT_BLUE = $e
   .const LIGHT_GREY = $f
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const sz = 0
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // The rotated point - updated by calling rotate_matrix()
   .label xr = $f0
   .label yr = $f1
@@ -28,7 +29,6 @@
   .label psp1 = $f6
   .label psp2 = $f8
   .label SCREEN = $400
-  .const sz = 0
   // A single sprite
   .label SPRITE = $3000
   .label COSH = SINH+$40
diff --git a/src/test/ref/examples/3d/3d.log b/src/test/ref/examples/3d/3d.log
index ea43efc25..17240e327 100644
--- a/src/test/ref/examples/3d/3d.log
+++ b/src/test/ref/examples/3d/3d.log
@@ -4342,17 +4342,18 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   .const GREEN = 5
   .const LIGHT_BLUE = $e
   .const LIGHT_GREY = $f
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const sz = 0
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // The rotated point - updated by calling rotate_matrix()
   .label xr = $f0
   .label yr = $f1
@@ -4365,7 +4366,6 @@ Target platform is c64basic / MOS6502X
   .label psp1 = $f6
   .label psp2 = $f8
   .label SCREEN = $400
-  .const sz = 0
   // A single sprite
   .label SPRITE = $3000
   .label COSH = SINH+$40
@@ -7008,17 +7008,18 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   .const GREEN = 5
   .const LIGHT_BLUE = $e
   .const LIGHT_GREY = $f
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const sz = 0
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // The rotated point - updated by calling rotate_matrix()
   .label xr = $f0
   .label yr = $f1
@@ -7031,7 +7032,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label psp1 = $f6
   .label psp2 = $f8
   .label SCREEN = $400
-  .const sz = 0
   // A single sprite
   .label SPRITE = $3000
   .label COSH = SINH+$40
@@ -9737,17 +9737,18 @@ Score: 67977
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   .const GREEN = 5
   .const LIGHT_BLUE = $e
   .const LIGHT_GREY = $f
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const sz = 0
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // The rotated point - updated by calling rotate_matrix()
   .label xr = $f0
   .label yr = $f1
@@ -9760,7 +9761,6 @@ Score: 67977
   .label psp1 = $f6
   .label psp2 = $f8
   .label SCREEN = $400
-  .const sz = 0
   // A single sprite
   .label SPRITE = $3000
   .label COSH = SINH+$40
diff --git a/src/test/ref/examples/bresenham/bitmap-bresenham.asm b/src/test/ref/examples/bresenham/bitmap-bresenham.asm
index 1f9e463ef..859cbfb2f 100644
--- a/src/test/ref/examples/bresenham/bitmap-bresenham.asm
+++ b/src/test/ref/examples/bresenham/bitmap-bresenham.asm
@@ -1,18 +1,18 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const lines_cnt = 8
+  .label D011 = $d011
   .label VIC_MEMORY = $d018
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   .label SCREEN = $400
   .label BITMAP = $2000
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const lines_cnt = 8
 main: {
     // VICII->BORDER_COLOR = 0
     lda #0
diff --git a/src/test/ref/examples/bresenham/bitmap-bresenham.log b/src/test/ref/examples/bresenham/bitmap-bresenham.log
index ad7353785..d1c1ac225 100644
--- a/src/test/ref/examples/bresenham/bitmap-bresenham.log
+++ b/src/test/ref/examples/bresenham/bitmap-bresenham.log
@@ -2691,18 +2691,18 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const lines_cnt = 8
+  .label D011 = $d011
   .label VIC_MEMORY = $d018
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   .label SCREEN = $400
   .label BITMAP = $2000
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const lines_cnt = 8
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -4127,18 +4127,18 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const lines_cnt = 8
+  .label D011 = $d011
   .label VIC_MEMORY = $d018
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   .label SCREEN = $400
   .label BITMAP = $2000
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const lines_cnt = 8
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -5686,18 +5686,18 @@ Score: 221364
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const lines_cnt = 8
+  .label D011 = $d011
   .label VIC_MEMORY = $d018
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   .label SCREEN = $400
   .label BITMAP = $2000
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const lines_cnt = 8
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/examples/chargen/chargen-analysis.asm b/src/test/ref/examples/chargen/chargen-analysis.asm
index 73ba76977..68277b671 100644
--- a/src/test/ref/examples/chargen/chargen-analysis.asm
+++ b/src/test/ref/examples/chargen/chargen-analysis.asm
@@ -2,12 +2,6 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
-  // The address of the CHARGEN character set
-  .label CHARGEN = $d000
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const KEY_F7 = 3
   .const KEY_F1 = 4
   .const KEY_F3 = 5
@@ -64,6 +58,12 @@
   .const KEY_SPACE = $3c
   .const KEY_Q = $3e
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The address of the CHARGEN character set
+  .label CHARGEN = $d000
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label SCREEN = $400
 main: {
     .label sc = 2
diff --git a/src/test/ref/examples/chargen/chargen-analysis.log b/src/test/ref/examples/chargen/chargen-analysis.log
index 411a7654b..9f5fa64f3 100644
--- a/src/test/ref/examples/chargen/chargen-analysis.log
+++ b/src/test/ref/examples/chargen/chargen-analysis.log
@@ -1974,12 +1974,6 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
-  // The address of the CHARGEN character set
-  .label CHARGEN = $d000
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const KEY_F7 = 3
   .const KEY_F1 = 4
   .const KEY_F3 = 5
@@ -2036,6 +2030,12 @@ Target platform is c64basic / MOS6502X
   .const KEY_SPACE = $3c
   .const KEY_Q = $3e
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The address of the CHARGEN character set
+  .label CHARGEN = $d000
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label SCREEN = $400
   // @begin
 __bbegin:
@@ -3065,12 +3065,6 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
-  // The address of the CHARGEN character set
-  .label CHARGEN = $d000
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const KEY_F7 = 3
   .const KEY_F1 = 4
   .const KEY_F3 = 5
@@ -3127,6 +3121,12 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const KEY_SPACE = $3c
   .const KEY_Q = $3e
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The address of the CHARGEN character set
+  .label CHARGEN = $d000
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label SCREEN = $400
   // @begin
 __bbegin:
@@ -4378,12 +4378,6 @@ Score: 558979
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
-  // The address of the CHARGEN character set
-  .label CHARGEN = $d000
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const KEY_F7 = 3
   .const KEY_F1 = 4
   .const KEY_F3 = 5
@@ -4440,6 +4434,12 @@ Score: 558979
   .const KEY_SPACE = $3c
   .const KEY_Q = $3e
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The address of the CHARGEN character set
+  .label CHARGEN = $d000
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/examples/conio/nacht-screen.asm b/src/test/ref/examples/conio/nacht-screen.asm
index 82c1d6a47..e44e4a5b0 100644
--- a/src/test/ref/examples/conio/nacht-screen.asm
+++ b/src/test/ref/examples/conio/nacht-screen.asm
@@ -20,6 +20,12 @@
   .const CH_LTEE = $6b
   // The right T character
   .const CH_RTEE = $73
+  // The screen width
+  .const CONIO_WIDTH = $28
+  // The screen height
+  .const CONIO_HEIGHT = $19
+  .const COLOR_GRAY3 = $f
+  .const COLOR_BLACK = 0
   // The text screen address
   .label CONIO_SCREEN_TEXT = $400
   // The color screen address
@@ -32,12 +38,6 @@
   .label CONIO_CIA1_PORT_A = $dc00
   // CIA#1 Port B: keyboard matrix rows and joystick #1.
   .label CONIO_CIA1_PORT_B = $dc01
-  // The screen width
-  .const CONIO_WIDTH = $28
-  // The screen height
-  .const CONIO_HEIGHT = $19
-  .const COLOR_GRAY3 = $f
-  .const COLOR_BLACK = 0
   .label VIC_MEMORY = $d018
   .label XSize = $f
   .label YSize = $10
diff --git a/src/test/ref/examples/conio/nacht-screen.log b/src/test/ref/examples/conio/nacht-screen.log
index 7bab4a9b9..3a7a7a1c4 100644
--- a/src/test/ref/examples/conio/nacht-screen.log
+++ b/src/test/ref/examples/conio/nacht-screen.log
@@ -3997,6 +3997,12 @@ Target platform is c64basic / MOS6502X
   .const CH_LTEE = $6b
   // The right T character
   .const CH_RTEE = $73
+  // The screen width
+  .const CONIO_WIDTH = $28
+  // The screen height
+  .const CONIO_HEIGHT = $19
+  .const COLOR_GRAY3 = $f
+  .const COLOR_BLACK = 0
   // The text screen address
   .label CONIO_SCREEN_TEXT = $400
   // The color screen address
@@ -4009,12 +4015,6 @@ Target platform is c64basic / MOS6502X
   .label CONIO_CIA1_PORT_A = $dc00
   // CIA#1 Port B: keyboard matrix rows and joystick #1.
   .label CONIO_CIA1_PORT_B = $dc01
-  // The screen width
-  .const CONIO_WIDTH = $28
-  // The screen height
-  .const CONIO_HEIGHT = $19
-  .const COLOR_GRAY3 = $f
-  .const COLOR_BLACK = 0
   .label VIC_MEMORY = $d018
   .label XSize = $22
   .label YSize = $23
@@ -5459,6 +5459,12 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CH_LTEE = $6b
   // The right T character
   .const CH_RTEE = $73
+  // The screen width
+  .const CONIO_WIDTH = $28
+  // The screen height
+  .const CONIO_HEIGHT = $19
+  .const COLOR_GRAY3 = $f
+  .const COLOR_BLACK = 0
   // The text screen address
   .label CONIO_SCREEN_TEXT = $400
   // The color screen address
@@ -5471,12 +5477,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label CONIO_CIA1_PORT_A = $dc00
   // CIA#1 Port B: keyboard matrix rows and joystick #1.
   .label CONIO_CIA1_PORT_B = $dc01
-  // The screen width
-  .const CONIO_WIDTH = $28
-  // The screen height
-  .const CONIO_HEIGHT = $19
-  .const COLOR_GRAY3 = $f
-  .const COLOR_BLACK = 0
   .label VIC_MEMORY = $d018
   .label XSize = $f
   .label YSize = $10
@@ -7123,6 +7123,12 @@ Score: 13128
   .const CH_LTEE = $6b
   // The right T character
   .const CH_RTEE = $73
+  // The screen width
+  .const CONIO_WIDTH = $28
+  // The screen height
+  .const CONIO_HEIGHT = $19
+  .const COLOR_GRAY3 = $f
+  .const COLOR_BLACK = 0
   // The text screen address
   .label CONIO_SCREEN_TEXT = $400
   // The color screen address
@@ -7135,12 +7141,6 @@ Score: 13128
   .label CONIO_CIA1_PORT_A = $dc00
   // CIA#1 Port B: keyboard matrix rows and joystick #1.
   .label CONIO_CIA1_PORT_B = $dc01
-  // The screen width
-  .const CONIO_WIDTH = $28
-  // The screen height
-  .const CONIO_HEIGHT = $19
-  .const COLOR_GRAY3 = $f
-  .const COLOR_BLACK = 0
   .label VIC_MEMORY = $d018
   .label XSize = $f
   .label YSize = $10
diff --git a/src/test/ref/examples/eightqueens/eightqueens-recursive.asm b/src/test/ref/examples/eightqueens/eightqueens-recursive.asm
index 1b776ba97..2832c7b0b 100644
--- a/src/test/ref/examples/eightqueens/eightqueens-recursive.asm
+++ b/src/test/ref/examples/eightqueens/eightqueens-recursive.asm
@@ -6,8 +6,6 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
@@ -20,6 +18,8 @@
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
   .const STACK_BASE = $103
   .const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label printf_cursor_x = $11
   .label printf_cursor_y = $12
   .label printf_cursor_ptr = $13
@@ -269,9 +269,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $a
     .label src = $1f
@@ -955,11 +955,11 @@ tod_init: {
 }
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = 8
     .const format_min_length = 0
     .const format_justify_left = 0
     .const format_zero_padding = 0
     .const format_upper_case = 0
+    .label uvalue = 8
     // printf_buffer.sign = format.sign_always?'+':0
     // Handle any sign
     lda #0
diff --git a/src/test/ref/examples/eightqueens/eightqueens-recursive.log b/src/test/ref/examples/eightqueens/eightqueens-recursive.log
index 81859129f..4f0fca228 100644
--- a/src/test/ref/examples/eightqueens/eightqueens-recursive.log
+++ b/src/test/ref/examples/eightqueens/eightqueens-recursive.log
@@ -7129,8 +7129,6 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
@@ -7142,6 +7140,8 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
   .const STACK_BASE = $103
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label printf_cursor_x = $4b
   .label printf_cursor_y = $4c
   .label printf_cursor_ptr = $4d
@@ -7609,9 +7609,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $d
     .label src = $b
@@ -8674,11 +8674,11 @@ tod_init: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = 8
     .const format_min_length = 0
     .const format_justify_left = 0
     .const format_zero_padding = 0
     .const format_upper_case = 0
+    .label uvalue = 8
     jmp __b1
     // printf_uint::@1
   __b1:
@@ -10387,8 +10387,6 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
@@ -10401,6 +10399,8 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
   .const STACK_BASE = $103
   .const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label printf_cursor_x = $11
   .label printf_cursor_y = $12
   .label printf_cursor_ptr = $13
@@ -10830,9 +10830,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $a
     .label src = $1f
@@ -11836,11 +11836,11 @@ tod_init: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = 8
     .const format_min_length = 0
     .const format_justify_left = 0
     .const format_zero_padding = 0
     .const format_upper_case = 0
+    .label uvalue = 8
     jmp __b1
     // printf_uint::@1
   __b1:
@@ -13947,8 +13947,6 @@ Score: 2147483647
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
@@ -13961,6 +13959,8 @@ Score: 2147483647
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
   .const STACK_BASE = $103
   .const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label printf_cursor_x = $11
   .label printf_cursor_y = $12
   .label printf_cursor_ptr = $13
@@ -14350,9 +14350,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $a
     .label src = $1f
@@ -15327,11 +15327,11 @@ tod_init: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = 8
     .const format_min_length = 0
     .const format_justify_left = 0
     .const format_zero_padding = 0
     .const format_upper_case = 0
+    .label uvalue = 8
     // printf_uint::@1
     // printf_buffer.sign = format.sign_always?'+':0
     // [239] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0 -- _deref_pbuc1=vbuc2 
diff --git a/src/test/ref/examples/eightqueens/eightqueens.asm b/src/test/ref/examples/eightqueens/eightqueens.asm
index 7b0097765..4bddf9331 100644
--- a/src/test/ref/examples/eightqueens/eightqueens.asm
+++ b/src/test/ref/examples/eightqueens/eightqueens.asm
@@ -6,8 +6,6 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
@@ -19,6 +17,8 @@
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
   .const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label printf_cursor_x = $12
   .label printf_cursor_y = $13
   .label printf_cursor_ptr = $14
@@ -255,9 +255,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $21
     .label src = $10
@@ -1230,11 +1230,11 @@ tod_init: {
 }
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = 8
     .const format_min_length = 0
     .const format_justify_left = 0
     .const format_zero_padding = 0
     .const format_upper_case = 0
+    .label uvalue = 8
     // printf_buffer.sign = format.sign_always?'+':0
     // Handle any sign
     lda #0
diff --git a/src/test/ref/examples/eightqueens/eightqueens.log b/src/test/ref/examples/eightqueens/eightqueens.log
index e8a85c8b7..5d385808d 100644
--- a/src/test/ref/examples/eightqueens/eightqueens.log
+++ b/src/test/ref/examples/eightqueens/eightqueens.log
@@ -7355,8 +7355,6 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
@@ -7367,6 +7365,8 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_MIN = $a
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label printf_cursor_x = $4f
   .label printf_cursor_y = $50
   .label printf_cursor_ptr = $51
@@ -7826,9 +7826,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $d
     .label src = $b
@@ -9599,11 +9599,11 @@ tod_init: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = 8
     .const format_min_length = 0
     .const format_justify_left = 0
     .const format_zero_padding = 0
     .const format_upper_case = 0
+    .label uvalue = 8
     jmp __b1
     // printf_uint::@1
   __b1:
@@ -10565,8 +10565,6 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
@@ -10578,6 +10576,8 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
   .const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label printf_cursor_x = $12
   .label printf_cursor_y = $13
   .label printf_cursor_ptr = $14
@@ -10997,9 +10997,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $21
     .label src = $10
@@ -12566,11 +12566,11 @@ tod_init: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = 8
     .const format_min_length = 0
     .const format_justify_left = 0
     .const format_zero_padding = 0
     .const format_upper_case = 0
+    .label uvalue = 8
     jmp __b1
     // printf_uint::@1
   __b1:
@@ -14059,8 +14059,6 @@ Score: 1359697
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
@@ -14072,6 +14070,8 @@ Score: 1359697
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
   .const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label printf_cursor_x = $12
   .label printf_cursor_y = $13
   .label printf_cursor_ptr = $14
@@ -14448,9 +14448,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $21
     .label src = $10
@@ -15933,11 +15933,11 @@ tod_init: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = 8
     .const format_min_length = 0
     .const format_justify_left = 0
     .const format_zero_padding = 0
     .const format_upper_case = 0
+    .label uvalue = 8
     // printf_uint::@1
     // printf_buffer.sign = format.sign_always?'+':0
     // [334] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0 -- _deref_pbuc1=vbuc2 
diff --git a/src/test/ref/examples/fire/fire.asm b/src/test/ref/examples/fire/fire.asm
index 376b8d4c8..6558733ac 100644
--- a/src/test/ref/examples/fire/fire.asm
+++ b/src/test/ref/examples/fire/fire.asm
@@ -6,15 +6,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const YELLOW = 7
@@ -23,6 +16,13 @@
   .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN1 = $3800
   .label SCREEN2 = $3c00
   .label BUFFER = $4000
diff --git a/src/test/ref/examples/fire/fire.log b/src/test/ref/examples/fire/fire.log
index ccc8414eb..97c881bd1 100644
--- a/src/test/ref/examples/fire/fire.log
+++ b/src/test/ref/examples/fire/fire.log
@@ -1682,15 +1682,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const YELLOW = 7
@@ -1699,6 +1692,13 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN1 = $3800
   .label SCREEN2 = $3c00
   .label BUFFER = $4000
@@ -2517,15 +2517,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const YELLOW = 7
@@ -2534,6 +2527,13 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN1 = $3800
   .label SCREEN2 = $3c00
   .label BUFFER = $4000
@@ -3500,15 +3500,8 @@ Score: 102503
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const YELLOW = 7
@@ -3517,6 +3510,13 @@ Score: 102503
   .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN1 = $3800
   .label SCREEN2 = $3c00
   .label BUFFER = $4000
diff --git a/src/test/ref/examples/font-2x2/font-2x2.asm b/src/test/ref/examples/font-2x2/font-2x2.asm
index 43904e09d..0c6360ec0 100644
--- a/src/test/ref/examples/font-2x2/font-2x2.asm
+++ b/src/test/ref/examples/font-2x2/font-2x2.asm
@@ -2,13 +2,13 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D018 = $d018
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  .label D018 = $d018
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   .label SCREEN = $400
@@ -155,8 +155,8 @@ show: {
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 // memset(byte register(X) c)
 memset: {
-    .label str = SCREEN
     .const num = $400
+    .label str = SCREEN
     .label end = str+num
     .label dst = $d
     lda #<str
diff --git a/src/test/ref/examples/font-2x2/font-2x2.log b/src/test/ref/examples/font-2x2/font-2x2.log
index e89b3f9be..7491d45eb 100644
--- a/src/test/ref/examples/font-2x2/font-2x2.log
+++ b/src/test/ref/examples/font-2x2/font-2x2.log
@@ -2302,13 +2302,13 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  .label D018 = $d018
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   .label SCREEN = $400
@@ -2555,8 +2555,8 @@ show: {
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 // memset(byte zp($25) c)
 memset: {
-    .label str = SCREEN
     .const num = $400
+    .label str = SCREEN
     .label end = str+num
     .label dst = 5
     .label c = $25
@@ -3385,13 +3385,13 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  .label D018 = $d018
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   .label SCREEN = $400
@@ -3616,8 +3616,8 @@ show: {
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 // memset(byte register(X) c)
 memset: {
-    .label str = SCREEN
     .const num = $400
+    .label str = SCREEN
     .label end = str+num
     .label dst = $d
     // [42] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -4585,13 +4585,13 @@ Score: 122846
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  .label D018 = $d018
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   .label SCREEN = $400
@@ -4806,8 +4806,8 @@ show: {
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 // memset(byte register(X) c)
 memset: {
-    .label str = SCREEN
     .const num = $400
+    .label str = SCREEN
     .label end = str+num
     .label dst = $d
     // [42] phi from memset to memset::@1 [phi:memset->memset::@1]
diff --git a/src/test/ref/examples/irq/irq-hyperscreen.asm b/src/test/ref/examples/irq/irq-hyperscreen.asm
index ee6377685..51ee8e4d9 100644
--- a/src/test/ref/examples/irq/irq-hyperscreen.asm
+++ b/src/test/ref/examples/irq/irq-hyperscreen.asm
@@ -7,21 +7,21 @@
   .const VIC_RSEL = 8
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the KERNAL serves IRQ interrupts
-  .label KERNEL_IRQ = $314
   .const WHITE = 1
   .const RED = 2
-  .label GHOST_BYTE = $3fff
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the KERNAL serves IRQ interrupts
+  .label KERNEL_IRQ = $314
+  .label GHOST_BYTE = $3fff
 main: {
     // *GHOST_BYTE = 0
     lda #0
diff --git a/src/test/ref/examples/irq/irq-hyperscreen.log b/src/test/ref/examples/irq/irq-hyperscreen.log
index 66325ab6a..380be6e80 100644
--- a/src/test/ref/examples/irq/irq-hyperscreen.log
+++ b/src/test/ref/examples/irq/irq-hyperscreen.log
@@ -369,21 +369,21 @@ Target platform is c64basic / MOS6502X
   .const VIC_RSEL = 8
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the KERNAL serves IRQ interrupts
-  .label KERNEL_IRQ = $314
   .const WHITE = 1
   .const RED = 2
-  .label GHOST_BYTE = $3fff
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the KERNAL serves IRQ interrupts
+  .label KERNEL_IRQ = $314
+  .label GHOST_BYTE = $3fff
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -555,21 +555,21 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const VIC_RSEL = 8
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the KERNAL serves IRQ interrupts
-  .label KERNEL_IRQ = $314
   .const WHITE = 1
   .const RED = 2
-  .label GHOST_BYTE = $3fff
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the KERNAL serves IRQ interrupts
+  .label KERNEL_IRQ = $314
+  .label GHOST_BYTE = $3fff
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -840,21 +840,21 @@ Score: 154
   .const VIC_RSEL = 8
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
-  // The vector used when the KERNAL serves IRQ interrupts
-  .label KERNEL_IRQ = $314
   .const WHITE = 1
   .const RED = 2
-  .label GHOST_BYTE = $3fff
   .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
+  // The vector used when the KERNAL serves IRQ interrupts
+  .label KERNEL_IRQ = $314
+  .label GHOST_BYTE = $3fff
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/examples/kernalload/kernalload.asm b/src/test/ref/examples/kernalload/kernalload.asm
index 50faadec8..bbcdfb51d 100644
--- a/src/test/ref/examples/kernalload/kernalload.asm
+++ b/src/test/ref/examples/kernalload/kernalload.asm
@@ -17,18 +17,18 @@
 .segment Code
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
+  .const GREEN = 5
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
-  .const GREEN = 5
   // Address to load to
   .label LOAD_SPRITE = $3000
   .label SCREEN = $400
   .label SPRITES_PTR = SCREEN+SPRITE_PTRS
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
 __bbegin:
 .segment Code
 main: {
diff --git a/src/test/ref/examples/kernalload/kernalload.log b/src/test/ref/examples/kernalload/kernalload.log
index 3aa627559..8b9174bc2 100644
--- a/src/test/ref/examples/kernalload/kernalload.log
+++ b/src/test/ref/examples/kernalload/kernalload.log
@@ -871,18 +871,18 @@ Target platform is custom / MOS6502X
   // Global Constants & labels
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
+  .const GREEN = 5
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
-  .const GREEN = 5
   // Address to load to
   .label LOAD_SPRITE = $3000
   .label SCREEN = $400
   .label SPRITES_PTR = SCREEN+SPRITE_PTRS
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1284,18 +1284,18 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
+  .const GREEN = 5
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
-  .const GREEN = 5
   // Address to load to
   .label LOAD_SPRITE = $3000
   .label SCREEN = $400
   .label SPRITES_PTR = SCREEN+SPRITE_PTRS
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1836,18 +1836,18 @@ Score: 811
   // Global Constants & labels
   // The offset of the sprite pointers from the screen start address
   .const SPRITE_PTRS = $3f8
+  .const GREEN = 5
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
-  .const GREEN = 5
   // Address to load to
   .label LOAD_SPRITE = $3000
   .label SCREEN = $400
   .label SPRITES_PTR = SCREEN+SPRITE_PTRS
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.asm b/src/test/ref/examples/multiplexer/simple-multiplexer.asm
index 5f62129f9..b0d852681 100644
--- a/src/test/ref/examples/multiplexer/simple-multiplexer.asm
+++ b/src/test/ref/examples/multiplexer/simple-multiplexer.asm
@@ -2,16 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_XMSB = $d010
-  .label SPRITES_COLS = $d027
-  .label D011 = $d011
   .const VIC_RST8 = $80
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   // The colors of the C64
   .const BLACK = 0
   .const GREEN = 5
@@ -20,6 +13,13 @@
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_XMSB = $d010
+  .label SPRITES_COLS = $d027
+  .label D011 = $d011
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // Location of screen & sprites
   .label SCREEN = $400
   .label SPRITE = $2000
diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.log b/src/test/ref/examples/multiplexer/simple-multiplexer.log
index 739193a66..3930c2c3d 100644
--- a/src/test/ref/examples/multiplexer/simple-multiplexer.log
+++ b/src/test/ref/examples/multiplexer/simple-multiplexer.log
@@ -1671,16 +1671,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_XMSB = $d010
-  .label SPRITES_COLS = $d027
-  .label D011 = $d011
   .const VIC_RST8 = $80
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   // The colors of the C64
   .const BLACK = 0
   .const GREEN = 5
@@ -1689,6 +1682,13 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_XMSB = $d010
+  .label SPRITES_COLS = $d027
+  .label D011 = $d011
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // Location of screen & sprites
   .label SCREEN = $400
   .label SPRITE = $2000
@@ -2628,16 +2628,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_XMSB = $d010
-  .label SPRITES_COLS = $d027
-  .label D011 = $d011
   .const VIC_RST8 = $80
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   // The colors of the C64
   .const BLACK = 0
   .const GREEN = 5
@@ -2646,6 +2639,13 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_XMSB = $d010
+  .label SPRITES_COLS = $d027
+  .label D011 = $d011
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // Location of screen & sprites
   .label SCREEN = $400
   .label SPRITE = $2000
@@ -3646,16 +3646,9 @@ Score: 60648
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_XMSB = $d010
-  .label SPRITES_COLS = $d027
-  .label D011 = $d011
   .const VIC_RST8 = $80
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   // The colors of the C64
   .const BLACK = 0
   .const GREEN = 5
@@ -3664,6 +3657,13 @@ Score: 60648
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_XMSB = $d010
+  .label SPRITES_COLS = $d027
+  .label D011 = $d011
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // Location of screen & sprites
   .label SCREEN = $400
   .label SPRITE = $2000
diff --git a/src/test/ref/examples/music/music.asm b/src/test/ref/examples/music/music.asm
index 4bdd1f80e..a44064906 100644
--- a/src/test/ref/examples/music/music.asm
+++ b/src/test/ref/examples/music/music.asm
@@ -2,11 +2,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   .label MUSIC = $1000
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // kickasm
   // Load the SID
   .const music = LoadSid("toiletrensdyr.sid")
diff --git a/src/test/ref/examples/music/music.log b/src/test/ref/examples/music/music.log
index 952dd7935..c7b57f926 100644
--- a/src/test/ref/examples/music/music.log
+++ b/src/test/ref/examples/music/music.log
@@ -292,11 +292,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   .label MUSIC = $1000
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // @begin
 __bbegin:
   jmp __b1
@@ -377,11 +377,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   .label MUSIC = $1000
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // @begin
 __bbegin:
   jmp __b1
@@ -566,11 +566,11 @@ Score: 3882
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   .label MUSIC = $1000
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   // @begin
   // @1
   // kickasm
diff --git a/src/test/ref/examples/music/music_irq.asm b/src/test/ref/examples/music/music_irq.asm
index da31ae786..d4d6b16c8 100644
--- a/src/test/ref/examples/music/music_irq.asm
+++ b/src/test/ref/examples/music/music_irq.asm
@@ -6,6 +6,12 @@
   .const CIA_INTERRUPT_CLEAR = $7f
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // The CIA#1: keyboard matrix, joystick #1/#2
@@ -13,12 +19,6 @@
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label MUSIC = $1000
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
   // kickasm
   // Load the SID
   .const music = LoadSid("toiletrensdyr.sid")
diff --git a/src/test/ref/examples/music/music_irq.log b/src/test/ref/examples/music/music_irq.log
index f2806a4c3..88530746b 100644
--- a/src/test/ref/examples/music/music_irq.log
+++ b/src/test/ref/examples/music/music_irq.log
@@ -325,6 +325,12 @@ Target platform is c64basic / MOS6502X
   .const CIA_INTERRUPT_CLEAR = $7f
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // The CIA#1: keyboard matrix, joystick #1/#2
@@ -332,12 +338,6 @@ Target platform is c64basic / MOS6502X
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label MUSIC = $1000
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
   // @begin
 __bbegin:
   jmp __b1
@@ -460,6 +460,12 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_INTERRUPT_CLEAR = $7f
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // The CIA#1: keyboard matrix, joystick #1/#2
@@ -467,12 +473,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label MUSIC = $1000
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
   // @begin
 __bbegin:
   jmp __b1
@@ -702,6 +702,12 @@ Score: 2899
   .const CIA_INTERRUPT_CLEAR = $7f
   // Bits for the VICII IRQ Status/Enable Registers
   .const IRQ_RASTER = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // The CIA#1: keyboard matrix, joystick #1/#2
@@ -709,12 +715,6 @@ Score: 2899
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label MUSIC = $1000
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
   // @begin
   // @1
   // kickasm
diff --git a/src/test/ref/examples/nmisamples/nmisamples.asm b/src/test/ref/examples/nmisamples/nmisamples.asm
index 99950fdfd..feee55de5 100644
--- a/src/test/ref/examples/nmisamples/nmisamples.asm
+++ b/src/test/ref/examples/nmisamples/nmisamples.asm
@@ -6,6 +6,12 @@
 .pc = $80d "Program"
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const SAMPLE_SIZE = $6100
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A = 4
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
@@ -16,12 +22,6 @@
   .label CIA2_INTERRUPT = $dd0d
   // The vector used when the KERNAL serves NMI interrupts
   .label KERNEL_NMI = $318
-  .const SAMPLE_SIZE = $6100
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A = 4
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18
   .label sample = 2
 __bbegin:
   // sample = SAMPLE
diff --git a/src/test/ref/examples/nmisamples/nmisamples.log b/src/test/ref/examples/nmisamples/nmisamples.log
index 051178e98..e6a3e03db 100644
--- a/src/test/ref/examples/nmisamples/nmisamples.log
+++ b/src/test/ref/examples/nmisamples/nmisamples.log
@@ -419,6 +419,12 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const SAMPLE_SIZE = $6100
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A = 4
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
@@ -429,12 +435,6 @@ Target platform is c64basic / MOS6502X
   .label CIA2_INTERRUPT = $dd0d
   // The vector used when the KERNAL serves NMI interrupts
   .label KERNEL_NMI = $318
-  .const SAMPLE_SIZE = $6100
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A = 4
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18
   .label sample = 2
   // @begin
 __bbegin:
@@ -659,6 +659,12 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const SAMPLE_SIZE = $6100
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A = 4
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
@@ -669,12 +675,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label CIA2_INTERRUPT = $dd0d
   // The vector used when the KERNAL serves NMI interrupts
   .label KERNEL_NMI = $318
-  .const SAMPLE_SIZE = $6100
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A = 4
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18
   .label sample = 2
   // @begin
 __bbegin:
@@ -998,6 +998,12 @@ Score: 483
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const SAMPLE_SIZE = $6100
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A = 4
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
@@ -1008,12 +1014,6 @@ Score: 483
   .label CIA2_INTERRUPT = $dd0d
   // The vector used when the KERNAL serves NMI interrupts
   .label KERNEL_NMI = $318
-  .const SAMPLE_SIZE = $6100
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A = 4
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18
   .label sample = 2
   // @begin
 __bbegin:
diff --git a/src/test/ref/examples/plasma/plasma-unroll.asm b/src/test/ref/examples/plasma/plasma-unroll.asm
index e0660d830..12521d978 100644
--- a/src/test/ref/examples/plasma/plasma-unroll.asm
+++ b/src/test/ref/examples/plasma/plasma-unroll.asm
@@ -8,25 +8,25 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
+  // The colors of the C64
+  .const BLACK = 0
+  .const BLUE = 6
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
-  .const BLUE = 6
   .label SCREEN1 = $2800
   .label CHARSET = $2000
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .label print_line_cursor = $400
   .label print_char_cursor = $b
   // Plasma state variables
diff --git a/src/test/ref/examples/plasma/plasma-unroll.log b/src/test/ref/examples/plasma/plasma-unroll.log
index 2d230ff38..f18fe24e0 100644
--- a/src/test/ref/examples/plasma/plasma-unroll.log
+++ b/src/test/ref/examples/plasma/plasma-unroll.log
@@ -3260,25 +3260,25 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
+  // The colors of the C64
+  .const BLACK = 0
+  .const BLUE = 6
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
-  .const BLUE = 6
   .label SCREEN1 = $2800
   .label CHARSET = $2000
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .label print_line_cursor = $400
   .label print_char_cursor = $12
   // Plasma state variables
@@ -4538,25 +4538,25 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
+  // The colors of the C64
+  .const BLACK = 0
+  .const BLUE = 6
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
-  .const BLUE = 6
   .label SCREEN1 = $2800
   .label CHARSET = $2000
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .label print_line_cursor = $400
   .label print_char_cursor = $b
   // Plasma state variables
@@ -5863,25 +5863,25 @@ Score: 95644
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
+  // The colors of the C64
+  .const BLACK = 0
+  .const BLUE = 6
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
-  .const BLUE = 6
   .label SCREEN1 = $2800
   .label CHARSET = $2000
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .label print_line_cursor = $400
   .label print_char_cursor = $b
   // Plasma state variables
diff --git a/src/test/ref/examples/plasma/plasma.asm b/src/test/ref/examples/plasma/plasma.asm
index 88e13aafe..eb1edddd2 100644
--- a/src/test/ref/examples/plasma/plasma.asm
+++ b/src/test/ref/examples/plasma/plasma.asm
@@ -6,26 +6,26 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
+  // The colors of the C64
+  .const BLACK = 0
+  .const BLUE = 6
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
-  .const BLUE = 6
   .label SCREEN1 = $2800
   .label SCREEN2 = $2c00
   .label CHARSET = $2000
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .label print_line_cursor = $400
   .label print_char_cursor = $b
   // Plasma state variables
diff --git a/src/test/ref/examples/plasma/plasma.log b/src/test/ref/examples/plasma/plasma.log
index a23b79f84..3a4367adc 100644
--- a/src/test/ref/examples/plasma/plasma.log
+++ b/src/test/ref/examples/plasma/plasma.log
@@ -2506,26 +2506,26 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
+  // The colors of the C64
+  .const BLACK = 0
+  .const BLUE = 6
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
-  .const BLUE = 6
   .label SCREEN1 = $2800
   .label SCREEN2 = $2c00
   .label CHARSET = $2000
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .label print_line_cursor = $400
   .label print_char_cursor = $14
   // Plasma state variables
@@ -3388,26 +3388,26 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
+  // The colors of the C64
+  .const BLACK = 0
+  .const BLUE = 6
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
-  .const BLUE = 6
   .label SCREEN1 = $2800
   .label SCREEN2 = $2c00
   .label CHARSET = $2000
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .label print_line_cursor = $400
   .label print_char_cursor = $b
   // Plasma state variables
@@ -4458,26 +4458,26 @@ Score: 95730
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
+  // The colors of the C64
+  .const BLACK = 0
+  .const BLUE = 6
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D018 = $d018
   // The SID MOS 6581/8580
   .label SID = $d400
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
   // Color Ram
   .label COLS = $d800
-  // The colors of the C64
-  .const BLACK = 0
-  .const BLUE = 6
   .label SCREEN1 = $2800
   .label SCREEN2 = $2c00
   .label CHARSET = $2000
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .label print_line_cursor = $400
   .label print_char_cursor = $b
   // Plasma state variables
diff --git a/src/test/ref/examples/rasterbars/raster-bars.asm b/src/test/ref/examples/rasterbars/raster-bars.asm
index aca03ddb8..929a03d75 100644
--- a/src/test/ref/examples/rasterbars/raster-bars.asm
+++ b/src/test/ref/examples/rasterbars/raster-bars.asm
@@ -1,11 +1,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
 main: {
     // asm
     sei
diff --git a/src/test/ref/examples/rasterbars/raster-bars.log b/src/test/ref/examples/rasterbars/raster-bars.log
index cf5fdc7af..bff5ff5ef 100644
--- a/src/test/ref/examples/rasterbars/raster-bars.log
+++ b/src/test/ref/examples/rasterbars/raster-bars.log
@@ -378,11 +378,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -541,11 +541,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -817,11 +817,11 @@ Score: 8340
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/examples/rotate/rotate.asm b/src/test/ref/examples/rotate/rotate.asm
index 0cf9899d4..cc38ea2eb 100644
--- a/src/test/ref/examples/rotate/rotate.asm
+++ b/src/test/ref/examples/rotate/rotate.asm
@@ -6,15 +6,6 @@
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#2 timer A&B as one single 32-bit value
-  .label CIA2_TIMER_AB = $dd04
   .const GREEN = 5
   .const LIGHT_BLUE = $e
   // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
@@ -26,6 +17,15 @@
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#2 timer A&B as one single 32-bit value
+  .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
   .label COS = SIN+$40
   // A single sprite
diff --git a/src/test/ref/examples/rotate/rotate.log b/src/test/ref/examples/rotate/rotate.log
index 4209d5f31..c91c17a74 100644
--- a/src/test/ref/examples/rotate/rotate.log
+++ b/src/test/ref/examples/rotate/rotate.log
@@ -2392,15 +2392,6 @@ Target platform is c64basic / MOS6502X
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#2 timer A&B as one single 32-bit value
-  .label CIA2_TIMER_AB = $dd04
   .const GREEN = 5
   .const LIGHT_BLUE = $e
   // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
@@ -2412,6 +2403,15 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#2 timer A&B as one single 32-bit value
+  .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
   .label COS = SIN+$40
   // A single sprite
@@ -3865,15 +3865,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#2 timer A&B as one single 32-bit value
-  .label CIA2_TIMER_AB = $dd04
   .const GREEN = 5
   .const LIGHT_BLUE = $e
   // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
@@ -3885,6 +3876,15 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#2 timer A&B as one single 32-bit value
+  .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
   .label COS = SIN+$40
   // A single sprite
@@ -5352,15 +5352,6 @@ Score: 30994
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
-  .label SPRITES_XPOS = $d000
-  .label SPRITES_YPOS = $d001
-  .label SPRITES_COLS = $d027
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#2 timer A&B as one single 32-bit value
-  .label CIA2_TIMER_AB = $dd04
   .const GREEN = 5
   .const LIGHT_BLUE = $e
   // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
@@ -5372,6 +5363,15 @@ Score: 30994
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
   .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
+  .label SPRITES_XPOS = $d000
+  .label SPRITES_YPOS = $d001
+  .label SPRITES_COLS = $d027
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#2 timer A&B as one single 32-bit value
+  .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
   .label COS = SIN+$40
   // A single sprite
diff --git a/src/test/ref/examples/scroll/scroll.asm b/src/test/ref/examples/scroll/scroll.asm
index e14b2932c..6dc65fb7b 100644
--- a/src/test/ref/examples/scroll/scroll.asm
+++ b/src/test/ref/examples/scroll/scroll.asm
@@ -1,12 +1,12 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  .label SCREEN = $400
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  .label SCREEN = $400
 main: {
     .label line = SCREEN+$28
     .label nxt = 2
diff --git a/src/test/ref/examples/scroll/scroll.log b/src/test/ref/examples/scroll/scroll.log
index c0227c662..ab83880f6 100644
--- a/src/test/ref/examples/scroll/scroll.log
+++ b/src/test/ref/examples/scroll/scroll.log
@@ -655,12 +655,12 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  .label SCREEN = $400
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -911,12 +911,12 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  .label SCREEN = $400
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1308,12 +1308,12 @@ Score: 6262
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  .label SCREEN = $400
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/examples/scrollbig/scrollbig.asm b/src/test/ref/examples/scrollbig/scrollbig.asm
index 63e4ef3b8..2c2a426ab 100644
--- a/src/test/ref/examples/scrollbig/scrollbig.asm
+++ b/src/test/ref/examples/scrollbig/scrollbig.asm
@@ -2,15 +2,15 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
   .label SCREEN = $400
   .label current_bit = 2
   // Scroll the next bit from the current char onto the screen - trigger next char if needed
diff --git a/src/test/ref/examples/scrollbig/scrollbig.log b/src/test/ref/examples/scrollbig/scrollbig.log
index 101a76b58..aff15d7b7 100644
--- a/src/test/ref/examples/scrollbig/scrollbig.log
+++ b/src/test/ref/examples/scrollbig/scrollbig.log
@@ -1514,15 +1514,15 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
   .label SCREEN = $400
   // Soft-scroll using $d016 - trigger bit-scroll/char-scroll when needed
   .label scroll = 2
@@ -2074,15 +2074,15 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
   .label SCREEN = $400
   .label current_bit = 2
   // Scroll the next bit from the current char onto the screen - trigger next char if needed
@@ -2778,15 +2778,15 @@ Score: 20886
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   // The VIC-II MOS 6567/6569
   .label VICII = $d000
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
-  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16
   .label SCREEN = $400
   .label current_bit = 2
   // Scroll the next bit from the current char onto the screen - trigger next char if needed
diff --git a/src/test/ref/examples/scrolllogo/scrolllogo.asm b/src/test/ref/examples/scrolllogo/scrolllogo.asm
index cd4ff4da9..37855bc82 100644
--- a/src/test/ref/examples/scrolllogo/scrolllogo.asm
+++ b/src/test/ref/examples/scrolllogo/scrolllogo.asm
@@ -1,13 +1,7 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D016 = $d016
   .const VIC_MCM = $10
-  .label D018 = $d018
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -25,6 +19,12 @@
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .label D016 = $d016
+  .label D018 = $d018
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN = $400
   .label LOGO = $2000
   // Remainder after unsigned 16-bit division
diff --git a/src/test/ref/examples/scrolllogo/scrolllogo.log b/src/test/ref/examples/scrolllogo/scrolllogo.log
index 273c1e1b7..072fd64e6 100644
--- a/src/test/ref/examples/scrolllogo/scrolllogo.log
+++ b/src/test/ref/examples/scrolllogo/scrolllogo.log
@@ -4199,13 +4199,7 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D016 = $d016
   .const VIC_MCM = $10
-  .label D018 = $d018
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -4223,6 +4217,12 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .label D016 = $d016
+  .label D018 = $d018
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN = $400
   .label LOGO = $2000
   // Remainder after unsigned 16-bit division
@@ -6348,13 +6348,7 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D016 = $d016
   .const VIC_MCM = $10
-  .label D018 = $d018
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -6372,6 +6366,12 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .label D016 = $d016
+  .label D018 = $d018
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN = $400
   .label LOGO = $2000
   // Remainder after unsigned 16-bit division
@@ -8526,13 +8526,7 @@ Score: 46731
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D016 = $d016
   .const VIC_MCM = $10
-  .label D018 = $d018
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -8550,6 +8544,12 @@ Score: 46731
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
   .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .label D016 = $d016
+  .label D018 = $d018
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN = $400
   .label LOGO = $2000
   // Remainder after unsigned 16-bit division
diff --git a/src/test/ref/examples/showlogo/showlogo.asm b/src/test/ref/examples/showlogo/showlogo.asm
index b423afcae..04d31a663 100644
--- a/src/test/ref/examples/showlogo/showlogo.asm
+++ b/src/test/ref/examples/showlogo/showlogo.asm
@@ -1,14 +1,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D016 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label D018 = $d018
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -17,6 +11,12 @@
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
+  .label D016 = $d016
+  .label D018 = $d018
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN = $400
   .label LOGO = $2000
   // kickasm
diff --git a/src/test/ref/examples/showlogo/showlogo.log b/src/test/ref/examples/showlogo/showlogo.log
index 5413aa895..bf14f8332 100644
--- a/src/test/ref/examples/showlogo/showlogo.log
+++ b/src/test/ref/examples/showlogo/showlogo.log
@@ -722,14 +722,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D016 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label D018 = $d018
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -738,6 +732,12 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
+  .label D016 = $d016
+  .label D018 = $d018
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN = $400
   .label LOGO = $2000
   // @begin
@@ -967,14 +967,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D016 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label D018 = $d018
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -983,6 +977,12 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
+  .label D016 = $d016
+  .label D018 = $d018
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN = $400
   .label LOGO = $2000
   // @begin
@@ -1342,14 +1342,8 @@ Score: 5884
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D016 = $d016
   .const VIC_MCM = $10
   .const VIC_CSEL = 8
-  .label D018 = $d018
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
@@ -1358,6 +1352,12 @@ Score: 5884
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR1 = $22
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR2 = $23
+  .label D016 = $d016
+  .label D018 = $d018
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // Color Ram
+  .label COLS = $d800
   .label SCREEN = $400
   .label LOGO = $2000
   // @begin
diff --git a/src/test/ref/examples/sinplotter/sine-plotter.asm b/src/test/ref/examples/sinplotter/sine-plotter.asm
index 111857252..5c42dcc04 100644
--- a/src/test/ref/examples/sinplotter/sine-plotter.asm
+++ b/src/test/ref/examples/sinplotter/sine-plotter.asm
@@ -2,25 +2,14 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D016 = $d016
   .const VIC_CSEL = 8
-  .label D018 = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const WHITE = 1
   // PI*2 in u[4.28] format
   .const PI2_u4f28 = $6487ed51
@@ -32,6 +21,17 @@
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D011 = $d011
+  .label D016 = $d016
+  .label D018 = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
   .label SCREEN = $400
   .label BITMAP = $2000
   // Remainder after unsigned 16-bit division
diff --git a/src/test/ref/examples/sinplotter/sine-plotter.log b/src/test/ref/examples/sinplotter/sine-plotter.log
index 37f1c2362..da8205166 100644
--- a/src/test/ref/examples/sinplotter/sine-plotter.log
+++ b/src/test/ref/examples/sinplotter/sine-plotter.log
@@ -3829,25 +3829,14 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D016 = $d016
   .const VIC_CSEL = 8
-  .label D018 = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const WHITE = 1
   // PI*2 in u[4.28] format
   .const PI2_u4f28 = $6487ed51
@@ -3859,6 +3848,17 @@ Target platform is c64basic / MOS6502X
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D011 = $d011
+  .label D016 = $d016
+  .label D018 = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
   .label SCREEN = $400
   .label BITMAP = $2000
   // Remainder after unsigned 16-bit division
@@ -5994,25 +5994,14 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D016 = $d016
   .const VIC_CSEL = 8
-  .label D018 = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const WHITE = 1
   // PI*2 in u[4.28] format
   .const PI2_u4f28 = $6487ed51
@@ -6024,6 +6013,17 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D011 = $d011
+  .label D016 = $d016
+  .label D018 = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
   .label SCREEN = $400
   .label BITMAP = $2000
   // Remainder after unsigned 16-bit division
@@ -8220,25 +8220,14 @@ Score: 25034
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D016 = $d016
   .const VIC_CSEL = 8
-  .label D018 = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The VIC-II MOS 6567/6569
-  .label VICII = $d000
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   .const WHITE = 1
   // PI*2 in u[4.28] format
   .const PI2_u4f28 = $6487ed51
@@ -8250,6 +8239,17 @@ Score: 25034
   .const SIZEOF_SIGNED_WORD = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21
+  .label D011 = $d011
+  .label D016 = $d016
+  .label D018 = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The VIC-II MOS 6567/6569
+  .label VICII = $d000
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
   .label SCREEN = $400
   .label BITMAP = $2000
   // Remainder after unsigned 16-bit division
diff --git a/src/test/ref/examples/sinsprites/sinus-sprites.asm b/src/test/ref/examples/sinsprites/sinus-sprites.asm
index 85edbb4b1..5696d40ac 100644
--- a/src/test/ref/examples/sinsprites/sinus-sprites.asm
+++ b/src/test/ref/examples/sinsprites/sinus-sprites.asm
@@ -1,6 +1,14 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const sinlen_x = $dd
+  .const sinlen_y = $c5
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_Y = $17
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
@@ -15,16 +23,8 @@
   // Zeropage addresses used to hold lo/hi-bytes of addresses of float numbers in MEM
   .label memLo = $fe
   .label memHi = $ff
-  .const sinlen_x = $dd
-  .const sinlen_y = $c5
   .label sprites = $2000
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_Y = $17
   // Current index within the progress cursor (0-7)
   .label progress_idx = 4
   // Current position of the progress cursor
diff --git a/src/test/ref/examples/sinsprites/sinus-sprites.log b/src/test/ref/examples/sinsprites/sinus-sprites.log
index a93b22ac7..f4b3d40b3 100644
--- a/src/test/ref/examples/sinsprites/sinus-sprites.log
+++ b/src/test/ref/examples/sinsprites/sinus-sprites.log
@@ -3496,6 +3496,14 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const sinlen_x = $dd
+  .const sinlen_y = $c5
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_Y = $17
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
@@ -3510,16 +3518,8 @@ Target platform is c64basic / MOS6502X
   // Zeropage addresses used to hold lo/hi-bytes of addresses of float numbers in MEM
   .label memLo = $fe
   .label memHi = $ff
-  .const sinlen_x = $dd
-  .const sinlen_y = $c5
   .label sprites = $2000
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_Y = $17
   // Current index within the progress cursor (0-7)
   .label progress_idx = $16
   // Current position of the progress cursor
@@ -5381,6 +5381,14 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const sinlen_x = $dd
+  .const sinlen_y = $c5
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_Y = $17
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
@@ -5395,16 +5403,8 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Zeropage addresses used to hold lo/hi-bytes of addresses of float numbers in MEM
   .label memLo = $fe
   .label memHi = $ff
-  .const sinlen_x = $dd
-  .const sinlen_y = $c5
   .label sprites = $2000
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_Y = $17
   // Current index within the progress cursor (0-7)
   .label progress_idx = 4
   // Current position of the progress cursor
@@ -7506,6 +7506,14 @@ Score: 769690
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const sinlen_x = $dd
+  .const sinlen_y = $c5
+  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
+  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d
+  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_Y = $17
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_COLS = $d027
@@ -7520,16 +7528,8 @@ Score: 769690
   // Zeropage addresses used to hold lo/hi-bytes of addresses of float numbers in MEM
   .label memLo = $fe
   .label memHi = $ff
-  .const sinlen_x = $dd
-  .const sinlen_y = $c5
   .label sprites = $2000
   .label SCREEN = $400
-  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
-  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d
-  .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_Y = $17
   // Current index within the progress cursor (0-7)
   .label progress_idx = 4
   // Current position of the progress cursor
diff --git a/src/test/ref/gfxbank.asm b/src/test/ref/gfxbank.asm
index cd3cca4fa..e5de8a130 100644
--- a/src/test/ref/gfxbank.asm
+++ b/src/test/ref/gfxbank.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
 main: {
     .const vicSelectGfxBank1_toDd001_return = 3
     // CIA2->PORT_A_DDR = %00000011
diff --git a/src/test/ref/gfxbank.log b/src/test/ref/gfxbank.log
index 52cce4e61..9f450b537 100644
--- a/src/test/ref/gfxbank.log
+++ b/src/test/ref/gfxbank.log
@@ -358,9 +358,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -430,9 +430,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -615,9 +615,9 @@ Score: 18
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/importing.asm b/src/test/ref/importing.asm
index ed3234368..c8c1dd95f 100644
--- a/src/test/ref/importing.asm
+++ b/src/test/ref/importing.asm
@@ -1,8 +1,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BGCOL = $d021
   .const RED = 2
+  .label BGCOL = $d021
 main: {
     .label screen = $400
     // *screen = 1
diff --git a/src/test/ref/importing.log b/src/test/ref/importing.log
index fb6e1525f..f677ad370 100644
--- a/src/test/ref/importing.log
+++ b/src/test/ref/importing.log
@@ -88,8 +88,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const RED = 2
+  .label BGCOL = $d021
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -139,8 +139,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const RED = 2
+  .label BGCOL = $d021
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -211,8 +211,8 @@ Score: 18
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
   .const RED = 2
+  .label BGCOL = $d021
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/int-conversion.asm b/src/test/ref/int-conversion.asm
index 822a2636b..a330de874 100644
--- a/src/test/ref/int-conversion.asm
+++ b/src/test/ref/int-conversion.asm
@@ -4,14 +4,14 @@
 .pc = $80d "Program"
   .const RED = 2
   .const GREEN = 5
-  .label SCREEN = $400
-  .label COLS = $d800
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
   .const TYPEID_WORD = 3
   .const TYPEID_SIGNED_WORD = 4
   .const TYPEID_DWORD = 5
   .const TYPEID_SIGNED_DWORD = 6
+  .label SCREEN = $400
+  .label COLS = $d800
 main: {
     .label s = 2
     lda #<SCREEN
diff --git a/src/test/ref/int-conversion.log b/src/test/ref/int-conversion.log
index a63029f49..525dca83b 100644
--- a/src/test/ref/int-conversion.log
+++ b/src/test/ref/int-conversion.log
@@ -1638,14 +1638,14 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   .const RED = 2
   .const GREEN = 5
-  .label SCREEN = $400
-  .label COLS = $d800
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
   .const TYPEID_WORD = 3
   .const TYPEID_SIGNED_WORD = 4
   .const TYPEID_DWORD = 5
   .const TYPEID_SIGNED_DWORD = 6
+  .label SCREEN = $400
+  .label COLS = $d800
   .label idx = 6
   // @begin
 __bbegin:
@@ -2502,14 +2502,14 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   .const RED = 2
   .const GREEN = 5
-  .label SCREEN = $400
-  .label COLS = $d800
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
   .const TYPEID_WORD = 3
   .const TYPEID_SIGNED_WORD = 4
   .const TYPEID_DWORD = 5
   .const TYPEID_SIGNED_DWORD = 6
+  .label SCREEN = $400
+  .label COLS = $d800
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -3613,14 +3613,14 @@ Score: 1159
   // Global Constants & labels
   .const RED = 2
   .const GREEN = 5
-  .label SCREEN = $400
-  .label COLS = $d800
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
   .const TYPEID_WORD = 3
   .const TYPEID_SIGNED_WORD = 4
   .const TYPEID_DWORD = 5
   .const TYPEID_SIGNED_DWORD = 6
+  .label SCREEN = $400
+  .label COLS = $d800
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/int-literals.asm b/src/test/ref/int-literals.asm
index fdddb97b4..e8e4ddb8f 100644
--- a/src/test/ref/int-literals.asm
+++ b/src/test/ref/int-literals.asm
@@ -4,14 +4,14 @@
 .pc = $80d "Program"
   .const RED = 2
   .const GREEN = 5
-  .label SCREEN = $400
-  .label COLS = $d800
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
   .const TYPEID_WORD = 3
   .const TYPEID_SIGNED_WORD = 4
   .const TYPEID_DWORD = 5
   .const TYPEID_SIGNED_DWORD = 6
+  .label SCREEN = $400
+  .label COLS = $d800
   .label idx = 4
 main: {
     .label s = 2
diff --git a/src/test/ref/int-literals.log b/src/test/ref/int-literals.log
index 30993fe3c..f2a802153 100644
--- a/src/test/ref/int-literals.log
+++ b/src/test/ref/int-literals.log
@@ -755,14 +755,14 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   .const RED = 2
   .const GREEN = 5
-  .label SCREEN = $400
-  .label COLS = $d800
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
   .const TYPEID_WORD = 3
   .const TYPEID_SIGNED_WORD = 4
   .const TYPEID_DWORD = 5
   .const TYPEID_SIGNED_DWORD = 6
+  .label SCREEN = $400
+  .label COLS = $d800
   .label idx = 6
   // @begin
 __bbegin:
@@ -1163,14 +1163,14 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   .const RED = 2
   .const GREEN = 5
-  .label SCREEN = $400
-  .label COLS = $d800
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
   .const TYPEID_WORD = 3
   .const TYPEID_SIGNED_WORD = 4
   .const TYPEID_DWORD = 5
   .const TYPEID_SIGNED_DWORD = 6
+  .label SCREEN = $400
+  .label COLS = $d800
   .label idx = 4
   // @begin
 __bbegin:
@@ -1656,14 +1656,14 @@ Score: 755
   // Global Constants & labels
   .const RED = 2
   .const GREEN = 5
-  .label SCREEN = $400
-  .label COLS = $d800
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
   .const TYPEID_WORD = 3
   .const TYPEID_SIGNED_WORD = 4
   .const TYPEID_DWORD = 5
   .const TYPEID_SIGNED_DWORD = 6
+  .label SCREEN = $400
+  .label COLS = $d800
   .label idx = 4
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/irq-hardware-clobber-jsr.asm b/src/test/ref/irq-hardware-clobber-jsr.asm
index fcb06561c..42be0e7a4 100644
--- a/src/test/ref/irq-hardware-clobber-jsr.asm
+++ b/src/test/ref/irq-hardware-clobber-jsr.asm
@@ -4,6 +4,16 @@
 .pc = $80d "Program"
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label BORDERCOL = $d020
   .label BGCOL = $d021
@@ -12,24 +22,14 @@
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
 main: {
     // asm
     sei
diff --git a/src/test/ref/irq-hardware-clobber-jsr.log b/src/test/ref/irq-hardware-clobber-jsr.log
index 96d5d0b7a..f5f43944b 100644
--- a/src/test/ref/irq-hardware-clobber-jsr.log
+++ b/src/test/ref/irq-hardware-clobber-jsr.log
@@ -366,6 +366,16 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label BORDERCOL = $d020
   .label BGCOL = $d021
@@ -374,24 +384,14 @@ Target platform is c64basic / MOS6502X
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -536,6 +536,16 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label BORDERCOL = $d020
   .label BGCOL = $d021
@@ -544,24 +554,14 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -800,6 +800,16 @@ Score: 224
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in 0xA000, 0xE000 I/O in 0xD000
+  .const PROCPORT_RAM_IO = 5
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label BORDERCOL = $d020
   .label BGCOL = $d021
@@ -808,24 +818,14 @@ Score: 224
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in 0xA000, 0xE000 I/O in 0xD000
-  .const PROCPORT_RAM_IO = 5
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the HARDWARE serves IRQ interrupts
   .label HARDWARE_IRQ = $fffe
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/irq-hardware-clobber.asm b/src/test/ref/irq-hardware-clobber.asm
index 0679251ca..d58092c79 100644
--- a/src/test/ref/irq-hardware-clobber.asm
+++ b/src/test/ref/irq-hardware-clobber.asm
@@ -2,26 +2,26 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
 // RAM in $A000, $E000 CHAR ROM in $D000
 main: {
     // asm
diff --git a/src/test/ref/irq-hardware-clobber.log b/src/test/ref/irq-hardware-clobber.log
index 1bb70aa76..56584d516 100644
--- a/src/test/ref/irq-hardware-clobber.log
+++ b/src/test/ref/irq-hardware-clobber.log
@@ -166,26 +166,26 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -311,26 +311,26 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -469,26 +469,26 @@ Score: 212
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/irq-hardware-stack.asm b/src/test/ref/irq-hardware-stack.asm
index 87cd0f346..3ec646795 100644
--- a/src/test/ref/irq-hardware-stack.asm
+++ b/src/test/ref/irq-hardware-stack.asm
@@ -2,26 +2,26 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
 // RAM in $A000, $E000 CHAR ROM in $D000
 main: {
     // asm
diff --git a/src/test/ref/irq-hardware-stack.log b/src/test/ref/irq-hardware-stack.log
index e975d11c0..5455260e1 100644
--- a/src/test/ref/irq-hardware-stack.log
+++ b/src/test/ref/irq-hardware-stack.log
@@ -166,26 +166,26 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -305,26 +305,26 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -470,26 +470,26 @@ Score: 316
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/irq-hardware.asm b/src/test/ref/irq-hardware.asm
index 5adea2634..9528eeaa5 100644
--- a/src/test/ref/irq-hardware.asm
+++ b/src/test/ref/irq-hardware.asm
@@ -2,26 +2,26 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
 // RAM in $A000, $E000 CHAR ROM in $D000
 main: {
     // asm
diff --git a/src/test/ref/irq-hardware.log b/src/test/ref/irq-hardware.log
index 402ea9518..e1da2d51f 100644
--- a/src/test/ref/irq-hardware.log
+++ b/src/test/ref/irq-hardware.log
@@ -166,26 +166,26 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -304,26 +304,26 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -468,26 +468,26 @@ Score: 296
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
+  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
+  .const PROCPORT_DDR_MEMORY_MASK = 7
+  // RAM in $A000, $E000 I/O in $D000
+  .const PROCPORT_RAM_IO = $35
   .label HARDWARE_IRQ = $fffe
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // Processor port data direction register
   .label PROCPORT_DDR = 0
-  // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
-  .const PROCPORT_DDR_MEMORY_MASK = 7
   // Processor Port Register controlling RAM/ROM configuration and the datasette
   .label PROCPORT = 1
-  // RAM in $A000, $E000 I/O in $D000
-  .const PROCPORT_RAM_IO = $35
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/irq-idx-problem.asm b/src/test/ref/irq-idx-problem.asm
index 0ba5a0346..092db77a3 100644
--- a/src/test/ref/irq-idx-problem.asm
+++ b/src/test/ref/irq-idx-problem.asm
@@ -4,23 +4,23 @@
 .pc = $80d "Program"
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  .const VIC_SIZE = $30
+  .const IRQ_CHANGE_NEXT = $7f
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label SCREEN = $400
   .label VIC_BASE = $d000
-  .const VIC_SIZE = $30
-  .const IRQ_CHANGE_NEXT = $7f
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label irq_idx = 2
 __bbegin:
   // irq_idx = 0
diff --git a/src/test/ref/irq-idx-problem.log b/src/test/ref/irq-idx-problem.log
index e883c463d..17cb9adf6 100644
--- a/src/test/ref/irq-idx-problem.log
+++ b/src/test/ref/irq-idx-problem.log
@@ -468,23 +468,23 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  .const VIC_SIZE = $30
+  .const IRQ_CHANGE_NEXT = $7f
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label SCREEN = $400
   .label VIC_BASE = $d000
-  .const VIC_SIZE = $30
-  .const IRQ_CHANGE_NEXT = $7f
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label irq_idx = 2
   // @begin
 __bbegin:
@@ -678,23 +678,23 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  .const VIC_SIZE = $30
+  .const IRQ_CHANGE_NEXT = $7f
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label SCREEN = $400
   .label VIC_BASE = $d000
-  .const VIC_SIZE = $30
-  .const IRQ_CHANGE_NEXT = $7f
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label irq_idx = 2
   // @begin
 __bbegin:
@@ -990,23 +990,23 @@ Score: 604
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  .const VIC_SIZE = $30
+  .const IRQ_CHANGE_NEXT = $7f
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label SCREEN = $400
   .label VIC_BASE = $d000
-  .const VIC_SIZE = $30
-  .const IRQ_CHANGE_NEXT = $7f
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label irq_idx = 2
   // @begin
 __bbegin:
diff --git a/src/test/ref/irq-kernel-minimal.asm b/src/test/ref/irq-kernel-minimal.asm
index 4544e6993..70b525dbd 100644
--- a/src/test/ref/irq-kernel-minimal.asm
+++ b/src/test/ref/irq-kernel-minimal.asm
@@ -2,12 +2,12 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label BGCOL = $d021
-  // The vector used when the KERNAL serves IRQ interrupts
-  .label KERNEL_IRQ = $314
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
+  .label BGCOL = $d021
+  // The vector used when the KERNAL serves IRQ interrupts
+  .label KERNEL_IRQ = $314
 // Setup the IRQ routine
 main: {
     // asm
diff --git a/src/test/ref/irq-kernel-minimal.log b/src/test/ref/irq-kernel-minimal.log
index f0d595e75..30370df03 100644
--- a/src/test/ref/irq-kernel-minimal.log
+++ b/src/test/ref/irq-kernel-minimal.log
@@ -276,12 +276,12 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
-  // The vector used when the KERNAL serves IRQ interrupts
-  .label KERNEL_IRQ = $314
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
+  .label BGCOL = $d021
+  // The vector used when the KERNAL serves IRQ interrupts
+  .label KERNEL_IRQ = $314
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -360,12 +360,12 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
-  // The vector used when the KERNAL serves IRQ interrupts
-  .label KERNEL_IRQ = $314
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
+  .label BGCOL = $d021
+  // The vector used when the KERNAL serves IRQ interrupts
+  .label KERNEL_IRQ = $314
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -545,12 +545,12 @@ Score: 37
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label BGCOL = $d021
-  // The vector used when the KERNAL serves IRQ interrupts
-  .label KERNEL_IRQ = $314
   // The colors of the C64
   .const BLACK = 0
   .const WHITE = 1
+  .label BGCOL = $d021
+  // The vector used when the KERNAL serves IRQ interrupts
+  .label KERNEL_IRQ = $314
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/irq-kernel.asm b/src/test/ref/irq-kernel.asm
index e97af5d28..3f25d2745 100644
--- a/src/test/ref/irq-kernel.asm
+++ b/src/test/ref/irq-kernel.asm
@@ -2,17 +2,17 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
 main: {
     // asm
     sei
diff --git a/src/test/ref/irq-kernel.log b/src/test/ref/irq-kernel.log
index ad70f0f03..19b5b3a39 100644
--- a/src/test/ref/irq-kernel.log
+++ b/src/test/ref/irq-kernel.log
@@ -139,17 +139,17 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -247,17 +247,17 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -380,17 +380,17 @@ Score: 71
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/irq-local-var-overlap-problem.asm b/src/test/ref/irq-local-var-overlap-problem.asm
index 1d1674d03..b24d5416f 100644
--- a/src/test/ref/irq-local-var-overlap-problem.asm
+++ b/src/test/ref/irq-local-var-overlap-problem.asm
@@ -2,16 +2,16 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const IRQ_RASTER = 1
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
 main: {
     .label k = 4
     .label j = 3
diff --git a/src/test/ref/irq-local-var-overlap-problem.log b/src/test/ref/irq-local-var-overlap-problem.log
index ee17e410e..8aee9db59 100644
--- a/src/test/ref/irq-local-var-overlap-problem.log
+++ b/src/test/ref/irq-local-var-overlap-problem.log
@@ -849,16 +849,16 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1379,16 +1379,16 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -2010,16 +2010,16 @@ Score: 314173644
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label FGCOL = $d021
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/irq-raster.asm b/src/test/ref/irq-raster.asm
index 45a2b03e4..9941913a6 100644
--- a/src/test/ref/irq-raster.asm
+++ b/src/test/ref/irq-raster.asm
@@ -2,17 +2,17 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
 main: {
     // asm
     sei
diff --git a/src/test/ref/irq-raster.log b/src/test/ref/irq-raster.log
index f803accf7..f9661fc91 100644
--- a/src/test/ref/irq-raster.log
+++ b/src/test/ref/irq-raster.log
@@ -139,17 +139,17 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -247,17 +247,17 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -380,17 +380,17 @@ Score: 71
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const BLACK = 0
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
-  .const WHITE = 1
-  .const BLACK = 0
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/irq-volatile-bool-problem.asm b/src/test/ref/irq-volatile-bool-problem.asm
index 6589e534a..427f3855d 100644
--- a/src/test/ref/irq-volatile-bool-problem.asm
+++ b/src/test/ref/irq-volatile-bool-problem.asm
@@ -3,15 +3,15 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const IRQ_RASTER = 1
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
 main: {
     // asm
     sei
diff --git a/src/test/ref/irq-volatile-bool-problem.log b/src/test/ref/irq-volatile-bool-problem.log
index 64b0ae3b4..c161f7ce3 100644
--- a/src/test/ref/irq-volatile-bool-problem.log
+++ b/src/test/ref/irq-volatile-bool-problem.log
@@ -207,15 +207,15 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -330,15 +330,15 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -488,15 +488,15 @@ Score: 951
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const IRQ_RASTER = 1
+  .const CIA_INTERRUPT_CLEAR = $7f
   .label KERNEL_IRQ = $314
   .label RASTER = $d012
   .label VIC_CONTROL = $d011
   .label IRQ_STATUS = $d019
   .label IRQ_ENABLE = $d01a
-  .const IRQ_RASTER = 1
   .label BGCOL = $d020
   .label CIA1_INTERRUPT = $dc0d
-  .const CIA_INTERRUPT_CLEAR = $7f
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/keyboard-glitch.asm b/src/test/ref/keyboard-glitch.asm
index 572b72717..15d5f34c0 100644
--- a/src/test/ref/keyboard-glitch.asm
+++ b/src/test/ref/keyboard-glitch.asm
@@ -12,13 +12,13 @@
   .const KEY_C = $14
   .const KEY_I = $21
   .const KEY_SPACE = $3c
+  .const RED = 2
+  .const GREEN = 5
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label BORDERCOL = $d020
   .label BGCOL = $d021
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
-  .const RED = 2
-  .const GREEN = 5
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label SCREEN = $400
 main: {
     // *BORDERCOL = GREEN
diff --git a/src/test/ref/keyboard-glitch.log b/src/test/ref/keyboard-glitch.log
index 297da4bdb..a39bbb229 100644
--- a/src/test/ref/keyboard-glitch.log
+++ b/src/test/ref/keyboard-glitch.log
@@ -762,13 +762,13 @@ Target platform is c64basic / MOS6502X
   .const KEY_C = $14
   .const KEY_I = $21
   .const KEY_SPACE = $3c
+  .const RED = 2
+  .const GREEN = 5
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label BORDERCOL = $d020
   .label BGCOL = $d021
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
-  .const RED = 2
-  .const GREEN = 5
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label SCREEN = $400
   // @begin
 __bbegin:
@@ -1120,13 +1120,13 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const KEY_C = $14
   .const KEY_I = $21
   .const KEY_SPACE = $3c
+  .const RED = 2
+  .const GREEN = 5
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label BORDERCOL = $d020
   .label BGCOL = $d021
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
-  .const RED = 2
-  .const GREEN = 5
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label SCREEN = $400
   // @begin
 __bbegin:
@@ -1595,13 +1595,13 @@ Score: 3151
   .const KEY_C = $14
   .const KEY_I = $21
   .const KEY_SPACE = $3c
+  .const RED = 2
+  .const GREEN = 5
+  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label BORDERCOL = $d020
   .label BGCOL = $d021
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
-  .const RED = 2
-  .const GREEN = 5
-  .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
   .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/kickasm-uses-prevent-deletion.asm b/src/test/ref/kickasm-uses-prevent-deletion.asm
index 96976222b..d89946cea 100644
--- a/src/test/ref/kickasm-uses-prevent-deletion.asm
+++ b/src/test/ref/kickasm-uses-prevent-deletion.asm
@@ -2,11 +2,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const BLACK = 0
+  .const WHITE = 1
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label BGCOL = $d021
-  .const BLACK = 0
-  .const WHITE = 1
 main: {
     // kickasm
     sei
diff --git a/src/test/ref/kickasm-uses-prevent-deletion.log b/src/test/ref/kickasm-uses-prevent-deletion.log
index c28e63c6b..f8f4b952c 100644
--- a/src/test/ref/kickasm-uses-prevent-deletion.log
+++ b/src/test/ref/kickasm-uses-prevent-deletion.log
@@ -115,11 +115,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const BLACK = 0
+  .const WHITE = 1
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label BGCOL = $d021
-  .const BLACK = 0
-  .const WHITE = 1
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -189,11 +189,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const BLACK = 0
+  .const WHITE = 1
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label BGCOL = $d021
-  .const BLACK = 0
-  .const WHITE = 1
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -287,11 +287,11 @@ Score: 277
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const BLACK = 0
+  .const WHITE = 1
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
   .label BGCOL = $d021
-  .const BLACK = 0
-  .const WHITE = 1
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/line-anim.asm b/src/test/ref/line-anim.asm
index 2534b66d9..cd25176f8 100644
--- a/src/test/ref/line-anim.asm
+++ b/src/test/ref/line-anim.asm
@@ -2,28 +2,28 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   // The number of points
   .const SIZE = 4
   // The delay between pixels
   .const DELAY = 8
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label D018 = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
   .label BITMAP = $a000
   .label SCREEN = $8800
 main: {
diff --git a/src/test/ref/line-anim.log b/src/test/ref/line-anim.log
index 66d959e75..5e57558a5 100644
--- a/src/test/ref/line-anim.log
+++ b/src/test/ref/line-anim.log
@@ -2552,28 +2552,28 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   // The number of points
   .const SIZE = 4
   // The delay between pixels
   .const DELAY = 8
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label D018 = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
   .label BITMAP = $a000
   .label SCREEN = $8800
   // @begin
@@ -3910,28 +3910,28 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   // The number of points
   .const SIZE = 4
   // The delay between pixels
   .const DELAY = 8
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label D018 = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
   .label BITMAP = $a000
   .label SCREEN = $8800
   // @begin
@@ -5395,28 +5395,28 @@ Score: 21967
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  .label D011 = $d011
   .const VIC_BMM = $20
   .const VIC_DEN = $10
   .const VIC_RSEL = 8
-  .label D018 = $d018
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 I/O in 0xD000
   .const PROCPORT_RAM_IO = 5
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
   // The number of points
   .const SIZE = 4
   // The delay between pixels
   .const DELAY = 8
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  .label D011 = $d011
+  .label D018 = $d018
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
   .label BITMAP = $a000
   .label SCREEN = $8800
   // @begin
diff --git a/src/test/ref/literals.asm b/src/test/ref/literals.asm
index c352295f4..f5aa137e4 100644
--- a/src/test/ref/literals.asm
+++ b/src/test/ref/literals.asm
@@ -1,9 +1,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const ch = 'a'
   .const num = 1
+  .label SCREEN = $400
 main: {
     // SCREEN[0] = ch
     lda #ch
diff --git a/src/test/ref/literals.log b/src/test/ref/literals.log
index 403a16429..ed494165e 100644
--- a/src/test/ref/literals.log
+++ b/src/test/ref/literals.log
@@ -158,9 +158,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const ch = 'a'
   .const num = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -247,9 +247,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const ch = 'a'
   .const num = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -357,9 +357,9 @@ Score: 293
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const ch = 'a'
   .const num = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/loop-memset-min.asm b/src/test/ref/loop-memset-min.asm
index e4d1ad18f..4a59d04f8 100644
--- a/src/test/ref/loop-memset-min.asm
+++ b/src/test/ref/loop-memset-min.asm
@@ -11,9 +11,9 @@ main: {
 }
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = 'c'
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 2
     lda #<str
diff --git a/src/test/ref/loop-memset-min.log b/src/test/ref/loop-memset-min.log
index 75758bd2a..39877a824 100644
--- a/src/test/ref/loop-memset-min.log
+++ b/src/test/ref/loop-memset-min.log
@@ -302,9 +302,9 @@ main: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = 'c'
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 2
     // [8] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -401,9 +401,9 @@ main: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = 'c'
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 2
     // [8] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -530,9 +530,9 @@ main: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = SCREEN
     .const c = 'c'
     .const num = $3e8
+    .label str = SCREEN
     .label end = str+num
     .label dst = 2
     // [8] phi from memset to memset::@1 [phi:memset->memset::@1]
diff --git a/src/test/ref/memcpy-0.asm b/src/test/ref/memcpy-0.asm
index ff37b00e0..0ba85c063 100644
--- a/src/test/ref/memcpy-0.asm
+++ b/src/test/ref/memcpy-0.asm
@@ -2,13 +2,13 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label D018 = $d018
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  .label D018 = $d018
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   .label CHARSET = $2000
diff --git a/src/test/ref/memcpy-0.log b/src/test/ref/memcpy-0.log
index cc87bb4ea..bdf9fc834 100644
--- a/src/test/ref/memcpy-0.log
+++ b/src/test/ref/memcpy-0.log
@@ -610,13 +610,13 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  .label D018 = $d018
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   .label CHARSET = $2000
@@ -824,13 +824,13 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  .label D018 = $d018
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   .label CHARSET = $2000
@@ -1169,13 +1169,13 @@ Score: 711
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in 0xA000, 0xE000 CHAR ROM in 0xD000
   .const PROCPORT_RAM_CHARROM = 1
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  .label D018 = $d018
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   // The address of the CHARGEN character set
   .label CHARGEN = $d000
   .label CHARSET = $2000
diff --git a/src/test/ref/millfork-benchmarks/plasma-kc.asm b/src/test/ref/millfork-benchmarks/plasma-kc.asm
index b60d3feda..866cb09b6 100644
--- a/src/test/ref/millfork-benchmarks/plasma-kc.asm
+++ b/src/test/ref/millfork-benchmarks/plasma-kc.asm
@@ -1,14 +1,14 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
+  .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e
+  .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e
   .label VIC_MEMORY = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   .label SCREEN1 = $e000
   .label SCREEN2 = $e400
   .label CHARSET = $e800
-  .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e
-  .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e
   .label last_time = $a
   .label rand_seed = $c
   .label print_line_cursor = 4
diff --git a/src/test/ref/millfork-benchmarks/plasma-kc.log b/src/test/ref/millfork-benchmarks/plasma-kc.log
index 2e0599945..ad99c267e 100644
--- a/src/test/ref/millfork-benchmarks/plasma-kc.log
+++ b/src/test/ref/millfork-benchmarks/plasma-kc.log
@@ -2105,14 +2105,14 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e
+  .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e
   .label VIC_MEMORY = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   .label SCREEN1 = $e000
   .label SCREEN2 = $e400
   .label CHARSET = $e800
-  .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e
-  .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e
   .label last_time = $19
   .label rand_seed = $1b
   .label print_line_cursor = $e
@@ -3096,14 +3096,14 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e
+  .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e
   .label VIC_MEMORY = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   .label SCREEN1 = $e000
   .label SCREEN2 = $e400
   .label CHARSET = $e800
-  .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e
-  .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e
   .label last_time = $a
   .label rand_seed = $c
   .label print_line_cursor = 4
@@ -4226,14 +4226,14 @@ Score: 104143
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e
+  .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e
   .label VIC_MEMORY = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   .label SCREEN1 = $e000
   .label SCREEN2 = $e400
   .label CHARSET = $e800
-  .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e
-  .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e
   .label last_time = $a
   .label rand_seed = $c
   .label print_line_cursor = 4
diff --git a/src/test/ref/multiplexer-irq/simple-multiplexer-irq.asm b/src/test/ref/multiplexer-irq/simple-multiplexer-irq.asm
index 75c94b6d9..42eb8d378 100644
--- a/src/test/ref/multiplexer-irq/simple-multiplexer-irq.asm
+++ b/src/test/ref/multiplexer-irq/simple-multiplexer-irq.asm
@@ -4,6 +4,16 @@
 .pc = $80d "Program"
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const RED = 2
+  .const GREEN = 5
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -13,24 +23,14 @@
   .label BORDERCOL = $d020
   .label VIC_CONTROL = $d011
   .label D011 = $d011
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
-  .const WHITE = 1
-  .const RED = 2
-  .const GREEN = 5
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = $400+$3f8
   .label plex_show_idx = 6
diff --git a/src/test/ref/multiplexer-irq/simple-multiplexer-irq.log b/src/test/ref/multiplexer-irq/simple-multiplexer-irq.log
index 682b4b225..f6f69c134 100644
--- a/src/test/ref/multiplexer-irq/simple-multiplexer-irq.log
+++ b/src/test/ref/multiplexer-irq/simple-multiplexer-irq.log
@@ -1641,6 +1641,16 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const RED = 2
+  .const GREEN = 5
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -1650,24 +1660,14 @@ Target platform is c64basic / MOS6502X
   .label BORDERCOL = $d020
   .label VIC_CONTROL = $d011
   .label D011 = $d011
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
-  .const WHITE = 1
-  .const RED = 2
-  .const GREEN = 5
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = $400+$3f8
   .label plex_show_idx = $d
@@ -2688,6 +2688,16 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const RED = 2
+  .const GREEN = 5
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -2697,24 +2707,14 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label BORDERCOL = $d020
   .label VIC_CONTROL = $d011
   .label D011 = $d011
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
-  .const WHITE = 1
-  .const RED = 2
-  .const GREEN = 5
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = $400+$3f8
   .label plex_show_idx = 6
@@ -3775,6 +3775,16 @@ Score: 43606
   // Global Constants & labels
   // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
   .const CIA_INTERRUPT_CLEAR = $7f
+  .const VIC_DEN = $10
+  .const VIC_RSEL = 8
+  // Bits for the VICII IRQ Status/Enable Registers
+  .const IRQ_RASTER = 1
+  .const WHITE = 1
+  .const RED = 2
+  .const GREEN = 5
+  // The number of sprites in the multiplexer
+  .const PLEX_COUNT = $20
+  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -3784,24 +3794,14 @@ Score: 43606
   .label BORDERCOL = $d020
   .label VIC_CONTROL = $d011
   .label D011 = $d011
-  .const VIC_DEN = $10
-  .const VIC_RSEL = 8
   // VIC II IRQ Status Register
   .label IRQ_STATUS = $d019
   // VIC II IRQ Enable Register
   .label IRQ_ENABLE = $d01a
-  // Bits for the VICII IRQ Status/Enable Registers
-  .const IRQ_RASTER = 1
   // The CIA#1: keyboard matrix, joystick #1/#2
   .label CIA1 = $dc00
   // The vector used when the KERNAL serves IRQ interrupts
   .label KERNEL_IRQ = $314
-  .const WHITE = 1
-  .const RED = 2
-  .const GREEN = 5
-  // The number of sprites in the multiplexer
-  .const PLEX_COUNT = $20
-  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
   // The address of the sprite pointers on the current screen (screen+0x3f8).
   .label PLEX_SCREEN_PTR = $400+$3f8
   .label plex_show_idx = 6
diff --git a/src/test/ref/number-inference-sum.asm b/src/test/ref/number-inference-sum.asm
index 05d22eef0..0a2a72dbd 100644
--- a/src/test/ref/number-inference-sum.asm
+++ b/src/test/ref/number-inference-sum.asm
@@ -4,12 +4,12 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label screen = $400
-    .label bgcol = $d020
     .const RED = 2
     .const b1 = $fa
     .const b2 = b1+$fa
     .const w = b2+1
+    .label screen = $400
+    .label bgcol = $d020
     // screen[0] = w
     lda #<w
     sta screen
diff --git a/src/test/ref/number-inference-sum.log b/src/test/ref/number-inference-sum.log
index 5cc603783..0059405bc 100644
--- a/src/test/ref/number-inference-sum.log
+++ b/src/test/ref/number-inference-sum.log
@@ -171,12 +171,12 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label screen = $400
-    .label bgcol = $d020
     .const RED = 2
     .const b1 = $fa
     .const b2 = b1+$fa
     .const w = b2+1
+    .label screen = $400
+    .label bgcol = $d020
     // [4] *((const nomodify word*) main::screen) ← (const word) main::w#0 -- _deref_pwuc1=vwuc2 
     lda #<w
     sta screen
@@ -232,12 +232,12 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label screen = $400
-    .label bgcol = $d020
     .const RED = 2
     .const b1 = $fa
     .const b2 = b1+$fa
     .const w = b2+1
+    .label screen = $400
+    .label bgcol = $d020
     // [4] *((const nomodify word*) main::screen) ← (const word) main::w#0 -- _deref_pwuc1=vwuc2 
     lda #<w
     sta screen
@@ -314,12 +314,12 @@ Score: 24
   // @end
   // main
 main: {
-    .label screen = $400
-    .label bgcol = $d020
     .const RED = 2
     .const b1 = $fa
     .const b2 = b1+$fa
     .const w = b2+1
+    .label screen = $400
+    .label bgcol = $d020
     // screen[0] = w
     // [4] *((const nomodify word*) main::screen) ← (const word) main::w#0 -- _deref_pwuc1=vwuc2 
     lda #<w
diff --git a/src/test/ref/plasma-center.asm b/src/test/ref/plasma-center.asm
index 44a82920c..60e87c623 100644
--- a/src/test/ref/plasma-center.asm
+++ b/src/test/ref/plasma-center.asm
@@ -2,32 +2,32 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
+  .const NUM_SQUARES = $30
+  .label D018 = $d018
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // Color Ram
+  .label COLS = $d800
   // Plasma charset
   .label CHARSET = $2000
   // Plasma screen 1
   .label SCREEN1 = $2800
   // Plasma screen 2
   .label SCREEN2 = $2c00
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
   .label print_line_cursor = $400
-  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
-  .const NUM_SQUARES = $30
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $c
   // Squares for each char value SQUARES[i] = i*i
diff --git a/src/test/ref/plasma-center.log b/src/test/ref/plasma-center.log
index 69eb081e8..c5ffa2199 100644
--- a/src/test/ref/plasma-center.log
+++ b/src/test/ref/plasma-center.log
@@ -5217,32 +5217,32 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
+  .const NUM_SQUARES = $30
+  .label D018 = $d018
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // Color Ram
+  .label COLS = $d800
   // Plasma charset
   .label CHARSET = $2000
   // Plasma screen 1
   .label SCREEN1 = $2800
   // Plasma screen 2
   .label SCREEN2 = $2c00
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
   .label print_line_cursor = $400
-  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
-  .const NUM_SQUARES = $30
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $3f
   // Squares for each char value SQUARES[i] = i*i
@@ -7704,32 +7704,32 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
+  .const NUM_SQUARES = $30
+  .label D018 = $d018
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // Color Ram
+  .label COLS = $d800
   // Plasma charset
   .label CHARSET = $2000
   // Plasma screen 1
   .label SCREEN1 = $2800
   // Plasma screen 2
   .label SCREEN2 = $2c00
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
   .label print_line_cursor = $400
-  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
-  .const NUM_SQUARES = $30
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $c
   // Squares for each char value SQUARES[i] = i*i
@@ -10218,32 +10218,32 @@ Score: 1208167
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label D018 = $d018
   // SID Channel Control Register Noise Waveform
   .const SID_CONTROL_NOISE = $80
-  // The SID MOS 6581/8580
-  .label SID = $d400
-  // Color Ram
-  .label COLS = $d800
   // The colors of the C64
   .const BLACK = 0
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
+  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
+  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
+  .const NUM_SQUARES = $30
+  .label D018 = $d018
+  // The SID MOS 6581/8580
+  .label SID = $d400
+  // Color Ram
+  .label COLS = $d800
   // Plasma charset
   .label CHARSET = $2000
   // Plasma screen 1
   .label SCREEN1 = $2800
   // Plasma screen 2
   .label SCREEN2 = $2c00
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_FREQ = $e
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL = $12
-  .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
   .label print_line_cursor = $400
-  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
-  .const NUM_SQUARES = $30
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $c
   // Squares for each char value SQUARES[i] = i*i
diff --git a/src/test/ref/pointer-cast-3.asm b/src/test/ref/pointer-cast-3.asm
index 6e8775bf8..c9072e293 100644
--- a/src/test/ref/pointer-cast-3.asm
+++ b/src/test/ref/pointer-cast-3.asm
@@ -3,8 +3,8 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label sb_screen = $400
     .const sb = $ff
+    .label sb_screen = $400
     // *sb_screen = sb
     lda #sb
     sta sb_screen
diff --git a/src/test/ref/pointer-cast-3.log b/src/test/ref/pointer-cast-3.log
index 25c389b74..ebeb961ac 100644
--- a/src/test/ref/pointer-cast-3.log
+++ b/src/test/ref/pointer-cast-3.log
@@ -95,8 +95,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label sb_screen = $400
     .const sb = $ff
+    .label sb_screen = $400
     // [4] *((const nomodify signed byte*) main::sb_screen) ← (const signed byte) main::sb -- _deref_pbsc1=vbsc2 
     lda #sb
     sta sb_screen
@@ -142,8 +142,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label sb_screen = $400
     .const sb = $ff
+    .label sb_screen = $400
     // [4] *((const nomodify signed byte*) main::sb_screen) ← (const signed byte) main::sb -- _deref_pbsc1=vbsc2 
     lda #sb
     sta sb_screen
@@ -202,8 +202,8 @@ Score: 12
   // @end
   // main
 main: {
-    .label sb_screen = $400
     .const sb = $ff
+    .label sb_screen = $400
     // *sb_screen = sb
     // [4] *((const nomodify signed byte*) main::sb_screen) ← (const signed byte) main::sb -- _deref_pbsc1=vbsc2 
     lda #sb
diff --git a/src/test/ref/pointer-cast.asm b/src/test/ref/pointer-cast.asm
index 997312907..d46302207 100644
--- a/src/test/ref/pointer-cast.asm
+++ b/src/test/ref/pointer-cast.asm
@@ -4,14 +4,14 @@
 .pc = $80d "Program"
   .const SIZEOF_WORD = 2
   .const SIZEOF_SIGNED_WORD = 2
-  .label ub_screen = $400
-  .label sb_screen = $428
-  .label uw_screen = $450
-  .label sw_screen = $478
   .const ub = $29
   .const sb = -$29
   .const uw = $3000
   .const sw = -$3000
+  .label ub_screen = $400
+  .label sb_screen = $428
+  .label uw_screen = $450
+  .label sw_screen = $478
 main: {
     // *((byte*)ub_screen) = ub
     lda #ub
diff --git a/src/test/ref/pointer-cast.log b/src/test/ref/pointer-cast.log
index 2d91b4284..c6a1f1412 100644
--- a/src/test/ref/pointer-cast.log
+++ b/src/test/ref/pointer-cast.log
@@ -346,14 +346,14 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   .const SIZEOF_WORD = 2
   .const SIZEOF_SIGNED_WORD = 2
-  .label ub_screen = $400
-  .label sb_screen = $428
-  .label uw_screen = $450
-  .label sw_screen = $478
   .const ub = $29
   .const sb = -$29
   .const uw = $3000
   .const sw = -$3000
+  .label ub_screen = $400
+  .label sb_screen = $428
+  .label uw_screen = $450
+  .label sw_screen = $478
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -477,14 +477,14 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   .const SIZEOF_WORD = 2
   .const SIZEOF_SIGNED_WORD = 2
-  .label ub_screen = $400
-  .label sb_screen = $428
-  .label uw_screen = $450
-  .label sw_screen = $478
   .const ub = $29
   .const sb = -$29
   .const uw = $3000
   .const sw = -$3000
+  .label ub_screen = $400
+  .label sb_screen = $428
+  .label uw_screen = $450
+  .label sw_screen = $478
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -622,14 +622,14 @@ Score: 150
   // Global Constants & labels
   .const SIZEOF_WORD = 2
   .const SIZEOF_SIGNED_WORD = 2
-  .label ub_screen = $400
-  .label sb_screen = $428
-  .label uw_screen = $450
-  .label sw_screen = $478
   .const ub = $29
   .const sb = -$29
   .const uw = $3000
   .const sw = -$3000
+  .label ub_screen = $400
+  .label sb_screen = $428
+  .label uw_screen = $450
+  .label sw_screen = $478
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/printf-1.asm b/src/test/ref/printf-1.asm
index ee2eed5d3..61b507c2c 100644
--- a/src/test/ref/printf-1.asm
+++ b/src/test/ref/printf-1.asm
@@ -266,9 +266,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 9
diff --git a/src/test/ref/printf-1.log b/src/test/ref/printf-1.log
index 49f2c35e1..27dd4574c 100644
--- a/src/test/ref/printf-1.log
+++ b/src/test/ref/printf-1.log
@@ -2091,9 +2091,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $13
     .label src = $11
@@ -2975,9 +2975,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 9
@@ -3951,9 +3951,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 9
diff --git a/src/test/ref/printf-12.asm b/src/test/ref/printf-12.asm
index 817028738..99c7c39da 100644
--- a/src/test/ref/printf-12.asm
+++ b/src/test/ref/printf-12.asm
@@ -29,10 +29,10 @@ __bbegin:
   jsr main
   rts
 main: {
+    .const ui = $162e
     .label sc = -$c
     .label uc = $22
     .label si = -$4d2
-    .const ui = $162e
     .label sl = -$1e240
     .label ul = $8aa52
     .label c = $17
@@ -345,9 +345,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 9
     .label src = $11
diff --git a/src/test/ref/printf-12.log b/src/test/ref/printf-12.log
index ec93461bb..0574348aa 100644
--- a/src/test/ref/printf-12.log
+++ b/src/test/ref/printf-12.log
@@ -6360,10 +6360,10 @@ __bend_from___b2:
 __bend:
   // main
 main: {
+    .const ui = $162e
     .label sc = -$c
     .label uc = $22
     .label si = -$4d2
-    .const ui = $162e
     .label sl = -$1e240
     .label ul = $8aa52
     .label c = $49
@@ -6978,9 +6978,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $d
     .label src = $b
@@ -9197,10 +9197,10 @@ __bend_from___b2:
 __bend:
   // main
 main: {
+    .const ui = $162e
     .label sc = -$c
     .label uc = $22
     .label si = -$4d2
-    .const ui = $162e
     .label sl = -$1e240
     .label ul = $8aa52
     .label c = $17
@@ -9791,9 +9791,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 9
     .label src = $11
@@ -12385,10 +12385,10 @@ __bbegin:
   // @end
   // main
 main: {
+    .const ui = $162e
     .label sc = -$c
     .label uc = $22
     .label si = -$4d2
-    .const ui = $162e
     .label sl = -$1e240
     .label ul = $8aa52
     .label c = $17
@@ -12897,9 +12897,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 9
     .label src = $11
diff --git a/src/test/ref/printf-13.asm b/src/test/ref/printf-13.asm
index e2caf41e8..acd940800 100644
--- a/src/test/ref/printf-13.asm
+++ b/src/test/ref/printf-13.asm
@@ -842,9 +842,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 9
     .label src = $c
diff --git a/src/test/ref/printf-13.log b/src/test/ref/printf-13.log
index 0813e761d..a6addd680 100644
--- a/src/test/ref/printf-13.log
+++ b/src/test/ref/printf-13.log
@@ -7996,9 +7996,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $d
     .label src = $b
@@ -11308,9 +11308,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 9
     .label src = $c
@@ -14973,9 +14973,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 9
     .label src = $c
diff --git a/src/test/ref/printf-14.asm b/src/test/ref/printf-14.asm
index 7241a0951..0e23ed475 100644
--- a/src/test/ref/printf-14.asm
+++ b/src/test/ref/printf-14.asm
@@ -212,9 +212,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 4
     .label src = 2
diff --git a/src/test/ref/printf-14.log b/src/test/ref/printf-14.log
index 3330883a3..4b427412f 100644
--- a/src/test/ref/printf-14.log
+++ b/src/test/ref/printf-14.log
@@ -3174,9 +3174,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $d
     .label src = $b
@@ -4036,9 +4036,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 4
     .label src = 2
@@ -4997,9 +4997,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 4
     .label src = 2
diff --git a/src/test/ref/printf-15.asm b/src/test/ref/printf-15.asm
index 06ad7654c..2b0e14f46 100644
--- a/src/test/ref/printf-15.asm
+++ b/src/test/ref/printf-15.asm
@@ -187,9 +187,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 6
     .label src = 4
diff --git a/src/test/ref/printf-15.log b/src/test/ref/printf-15.log
index d8a28b704..fde56e549 100644
--- a/src/test/ref/printf-15.log
+++ b/src/test/ref/printf-15.log
@@ -1227,9 +1227,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $d
     .label src = $b
@@ -1773,9 +1773,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 6
     .label src = 4
@@ -2376,9 +2376,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 6
     .label src = 4
diff --git a/src/test/ref/printf-16.asm b/src/test/ref/printf-16.asm
index 75c677120..b350ccf37 100644
--- a/src/test/ref/printf-16.asm
+++ b/src/test/ref/printf-16.asm
@@ -399,9 +399,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 5
diff --git a/src/test/ref/printf-16.log b/src/test/ref/printf-16.log
index df70d4ba7..a457d8142 100644
--- a/src/test/ref/printf-16.log
+++ b/src/test/ref/printf-16.log
@@ -4697,9 +4697,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $d
     .label src = $b
@@ -6177,9 +6177,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 5
@@ -7823,9 +7823,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 5
diff --git a/src/test/ref/printf-2.asm b/src/test/ref/printf-2.asm
index cd8064802..a723f38f4 100644
--- a/src/test/ref/printf-2.asm
+++ b/src/test/ref/printf-2.asm
@@ -171,9 +171,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 7
     .label src = 5
@@ -213,11 +213,11 @@ memcpy: {
 }
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = $d80
     .const format_min_length = $a
     .const format_justify_left = 1
     .const format_zero_padding = 0
     .const format_upper_case = 1
+    .label uvalue = $d80
     // printf_buffer.sign = format.sign_always?'+':0
     // Handle any sign
     lda #0
diff --git a/src/test/ref/printf-2.log b/src/test/ref/printf-2.log
index 142ea20c8..b704f1d5d 100644
--- a/src/test/ref/printf-2.log
+++ b/src/test/ref/printf-2.log
@@ -4480,9 +4480,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = $b
     .label src = 9
@@ -4539,11 +4539,11 @@ memcpy: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = $d80
     .const format_min_length = $a
     .const format_justify_left = 1
     .const format_zero_padding = 0
     .const format_upper_case = 1
+    .label uvalue = $d80
     jmp __b1
     // printf_uint::@1
   __b1:
@@ -6492,9 +6492,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 7
     .label src = 5
@@ -6551,11 +6551,11 @@ memcpy: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = $d80
     .const format_min_length = $a
     .const format_justify_left = 1
     .const format_zero_padding = 0
     .const format_upper_case = 1
+    .label uvalue = $d80
     jmp __b1
     // printf_uint::@1
   __b1:
@@ -8619,9 +8619,9 @@ memset: {
 // Copy block of memory (forwards)
 // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
 memcpy: {
+    .const num = $28*$19-$28
     .label destination = $400
     .label source = $400+$28
-    .const num = $28*$19-$28
     .label src_end = source+num
     .label dst = 7
     .label src = 5
@@ -8676,11 +8676,11 @@ memcpy: {
   // printf_uint
 // Print an unsigned int using a specific format
 printf_uint: {
-    .label uvalue = $d80
     .const format_min_length = $a
     .const format_justify_left = 1
     .const format_zero_padding = 0
     .const format_upper_case = 1
+    .label uvalue = $d80
     // printf_uint::@1
     // printf_buffer.sign = format.sign_always?'+':0
     // [55] *((byte*)&(struct printf_buffer_number) printf_buffer) ← (byte) 0 -- _deref_pbuc1=vbuc2 
diff --git a/src/test/ref/procedure-callingconvention-stack-0.asm b/src/test/ref/procedure-callingconvention-stack-0.asm
index 2dea9d040..85b19e47d 100644
--- a/src/test/ref/procedure-callingconvention-stack-0.asm
+++ b/src/test/ref/procedure-callingconvention-stack-0.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
 main: {
     // plus('0', 7)
     lda #'0'
diff --git a/src/test/ref/procedure-callingconvention-stack-0.log b/src/test/ref/procedure-callingconvention-stack-0.log
index 89f601ec4..9ed87f558 100644
--- a/src/test/ref/procedure-callingconvention-stack-0.log
+++ b/src/test/ref/procedure-callingconvention-stack-0.log
@@ -168,8 +168,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -287,8 +287,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -410,8 +410,8 @@ Score: 67
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/procedure-callingconvention-stack-1.asm b/src/test/ref/procedure-callingconvention-stack-1.asm
index 2dea9d040..85b19e47d 100644
--- a/src/test/ref/procedure-callingconvention-stack-1.asm
+++ b/src/test/ref/procedure-callingconvention-stack-1.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
 main: {
     // plus('0', 7)
     lda #'0'
diff --git a/src/test/ref/procedure-callingconvention-stack-1.log b/src/test/ref/procedure-callingconvention-stack-1.log
index 89f601ec4..9ed87f558 100644
--- a/src/test/ref/procedure-callingconvention-stack-1.log
+++ b/src/test/ref/procedure-callingconvention-stack-1.log
@@ -168,8 +168,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -287,8 +287,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -410,8 +410,8 @@ Score: 67
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/procedure-callingconvention-stack-10.asm b/src/test/ref/procedure-callingconvention-stack-10.asm
index d2adbf741..800845400 100644
--- a/src/test/ref/procedure-callingconvention-stack-10.asm
+++ b/src/test/ref/procedure-callingconvention-stack-10.asm
@@ -3,9 +3,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label idx = 3
 __bbegin:
   // idx = 0
diff --git a/src/test/ref/procedure-callingconvention-stack-10.log b/src/test/ref/procedure-callingconvention-stack-10.log
index b6556233f..0bd401de0 100644
--- a/src/test/ref/procedure-callingconvention-stack-10.log
+++ b/src/test/ref/procedure-callingconvention-stack-10.log
@@ -312,9 +312,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
@@ -530,9 +530,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
@@ -746,9 +746,9 @@ Score: 828
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
diff --git a/src/test/ref/procedure-callingconvention-stack-11.asm b/src/test/ref/procedure-callingconvention-stack-11.asm
index e521ab309..3b2e50fb8 100644
--- a/src/test/ref/procedure-callingconvention-stack-11.asm
+++ b/src/test/ref/procedure-callingconvention-stack-11.asm
@@ -3,10 +3,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_P2 = 2
+  .label SCREEN = $400
   .label idx = 3
 __bbegin:
   // idx = 0
diff --git a/src/test/ref/procedure-callingconvention-stack-11.log b/src/test/ref/procedure-callingconvention-stack-11.log
index ee7892321..5b4c0bad5 100644
--- a/src/test/ref/procedure-callingconvention-stack-11.log
+++ b/src/test/ref/procedure-callingconvention-stack-11.log
@@ -461,10 +461,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_P2 = 2
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
@@ -808,10 +808,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_P2 = 2
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
@@ -1120,10 +1120,10 @@ Score: 1247
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_P2 = 2
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
diff --git a/src/test/ref/procedure-callingconvention-stack-12.asm b/src/test/ref/procedure-callingconvention-stack-12.asm
index ed9071ea6..1e01bce61 100644
--- a/src/test/ref/procedure-callingconvention-stack-12.asm
+++ b/src/test/ref/procedure-callingconvention-stack-12.asm
@@ -3,8 +3,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label idx = 4
 __bbegin:
   // idx = 0
diff --git a/src/test/ref/procedure-callingconvention-stack-12.log b/src/test/ref/procedure-callingconvention-stack-12.log
index e563f54d0..a98d9beb9 100644
--- a/src/test/ref/procedure-callingconvention-stack-12.log
+++ b/src/test/ref/procedure-callingconvention-stack-12.log
@@ -255,8 +255,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label idx = 5
   // @begin
 __bbegin:
@@ -457,8 +457,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label idx = 4
   // @begin
 __bbegin:
@@ -667,8 +667,8 @@ Score: 3613
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label idx = 4
   // @begin
 __bbegin:
diff --git a/src/test/ref/procedure-callingconvention-stack-13.asm b/src/test/ref/procedure-callingconvention-stack-13.asm
index c7ad7cd0a..6ec79ee6b 100644
--- a/src/test/ref/procedure-callingconvention-stack-13.asm
+++ b/src/test/ref/procedure-callingconvention-stack-13.asm
@@ -3,8 +3,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
 main: {
     // pow2(6)
     lda #6
diff --git a/src/test/ref/procedure-callingconvention-stack-13.log b/src/test/ref/procedure-callingconvention-stack-13.log
index c01bb2cc7..da7e6b6f9 100644
--- a/src/test/ref/procedure-callingconvention-stack-13.log
+++ b/src/test/ref/procedure-callingconvention-stack-13.log
@@ -217,8 +217,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -342,8 +342,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -484,8 +484,8 @@ Score: 72
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/procedure-callingconvention-stack-2.asm b/src/test/ref/procedure-callingconvention-stack-2.asm
index d8ea0cc84..309ff5370 100644
--- a/src/test/ref/procedure-callingconvention-stack-2.asm
+++ b/src/test/ref/procedure-callingconvention-stack-2.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
 main: {
     .label __0 = 2
     // plus(0x1234, 0x2345)
diff --git a/src/test/ref/procedure-callingconvention-stack-2.log b/src/test/ref/procedure-callingconvention-stack-2.log
index 364972fe4..4a72455f4 100644
--- a/src/test/ref/procedure-callingconvention-stack-2.log
+++ b/src/test/ref/procedure-callingconvention-stack-2.log
@@ -186,8 +186,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -312,8 +312,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -461,8 +461,8 @@ Score: 146
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/procedure-callingconvention-stack-3.asm b/src/test/ref/procedure-callingconvention-stack-3.asm
index ad9184cab..9d01469e0 100644
--- a/src/test/ref/procedure-callingconvention-stack-3.asm
+++ b/src/test/ref/procedure-callingconvention-stack-3.asm
@@ -5,8 +5,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
 main: {
     .label __0 = 2
     // plus('0', 7)
diff --git a/src/test/ref/procedure-callingconvention-stack-3.log b/src/test/ref/procedure-callingconvention-stack-3.log
index 114128aa0..68ddf7449 100644
--- a/src/test/ref/procedure-callingconvention-stack-3.log
+++ b/src/test/ref/procedure-callingconvention-stack-3.log
@@ -185,8 +185,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -314,8 +314,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -466,8 +466,8 @@ Score: 146
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/procedure-callingconvention-stack-4.asm b/src/test/ref/procedure-callingconvention-stack-4.asm
index d64ce4a1f..b3a313069 100644
--- a/src/test/ref/procedure-callingconvention-stack-4.asm
+++ b/src/test/ref/procedure-callingconvention-stack-4.asm
@@ -3,8 +3,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label i = 3
 __bbegin:
   // i = 0
diff --git a/src/test/ref/procedure-callingconvention-stack-4.log b/src/test/ref/procedure-callingconvention-stack-4.log
index 870c951fc..1a33d8fd1 100644
--- a/src/test/ref/procedure-callingconvention-stack-4.log
+++ b/src/test/ref/procedure-callingconvention-stack-4.log
@@ -240,8 +240,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label i = 3
   // @begin
 __bbegin:
@@ -418,8 +418,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label i = 3
   // @begin
 __bbegin:
@@ -593,8 +593,8 @@ Score: 656
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label i = 3
   // @begin
 __bbegin:
diff --git a/src/test/ref/procedure-callingconvention-stack-5.asm b/src/test/ref/procedure-callingconvention-stack-5.asm
index d0d91316a..4412d7f44 100644
--- a/src/test/ref/procedure-callingconvention-stack-5.asm
+++ b/src/test/ref/procedure-callingconvention-stack-5.asm
@@ -3,9 +3,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_SIGNED_WORD = 2
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label current = 2
 __bbegin:
   // current = 48
diff --git a/src/test/ref/procedure-callingconvention-stack-5.log b/src/test/ref/procedure-callingconvention-stack-5.log
index b9b04ef5a..6eaa96137 100644
--- a/src/test/ref/procedure-callingconvention-stack-5.log
+++ b/src/test/ref/procedure-callingconvention-stack-5.log
@@ -190,9 +190,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_SIGNED_WORD = 2
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label current = 2
   // @begin
 __bbegin:
@@ -315,9 +315,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_SIGNED_WORD = 2
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label current = 2
   // @begin
 __bbegin:
@@ -464,9 +464,9 @@ Score: 156
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_SIGNED_WORD = 2
   .const STACK_BASE = $103
+  .label SCREEN = $400
   .label current = 2
   // @begin
 __bbegin:
diff --git a/src/test/ref/processor-port-test.asm b/src/test/ref/processor-port-test.asm
index 99b43a69f..092495325 100644
--- a/src/test/ref/processor-port-test.asm
+++ b/src/test/ref/processor-port-test.asm
@@ -3,12 +3,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in all three areas 0xA000, 0xD000, 0xE000
   .const PROCPORT_RAM_ALL = 0
   // RAM in 0xA000, 0xE000 I/O in 0xD000
@@ -19,6 +15,10 @@
   .const PROCPORT_KERNEL_IO = 6
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   .label BASIC_ROM = $a000
   .label KERNAL_ROM = $e000
   .label IO_RAM = $d000
diff --git a/src/test/ref/processor-port-test.log b/src/test/ref/processor-port-test.log
index 80769911e..ebf2a0e7f 100644
--- a/src/test/ref/processor-port-test.log
+++ b/src/test/ref/processor-port-test.log
@@ -2576,12 +2576,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in all three areas 0xA000, 0xD000, 0xE000
   .const PROCPORT_RAM_ALL = 0
   // RAM in 0xA000, 0xE000 I/O in 0xD000
@@ -2592,6 +2588,10 @@ Target platform is c64basic / MOS6502X
   .const PROCPORT_KERNEL_IO = 6
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   .label BASIC_ROM = $a000
   .label KERNAL_ROM = $e000
   .label IO_RAM = $d000
@@ -3691,12 +3691,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in all three areas 0xA000, 0xD000, 0xE000
   .const PROCPORT_RAM_ALL = 0
   // RAM in 0xA000, 0xE000 I/O in 0xD000
@@ -3707,6 +3703,10 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const PROCPORT_KERNEL_IO = 6
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   .label BASIC_ROM = $a000
   .label KERNAL_ROM = $e000
   .label IO_RAM = $d000
@@ -5124,12 +5124,8 @@ Score: 2185
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  // Processor port data direction register
-  .label PROCPORT_DDR = 0
   // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
   .const PROCPORT_DDR_MEMORY_MASK = 7
-  // Processor Port Register controlling RAM/ROM configuration and the datasette
-  .label PROCPORT = 1
   // RAM in all three areas 0xA000, 0xD000, 0xE000
   .const PROCPORT_RAM_ALL = 0
   // RAM in 0xA000, 0xE000 I/O in 0xD000
@@ -5140,6 +5136,10 @@ Score: 2185
   .const PROCPORT_KERNEL_IO = 6
   // BASIC in 0xA000, I/O in 0xD000, KERNEL in 0xE000
   .const PROCPORT_BASIC_KERNEL_IO = 7
+  // Processor port data direction register
+  .label PROCPORT_DDR = 0
+  // Processor Port Register controlling RAM/ROM configuration and the datasette
+  .label PROCPORT = 1
   .label BASIC_ROM = $a000
   .label KERNAL_ROM = $e000
   .label IO_RAM = $d000
diff --git a/src/test/ref/scan-desire-problem.asm b/src/test/ref/scan-desire-problem.asm
index f6fe30cb2..46adaf34c 100644
--- a/src/test/ref/scan-desire-problem.asm
+++ b/src/test/ref/scan-desire-problem.asm
@@ -2,6 +2,13 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const RED = 2
+  .const GREEN = 5
+  .const BLUE = 6
+  .const YELLOW = 7
   .label SPRITES_XMSB = $d010
   .label SPRITES_COLS = $d027
   .label SPRITES_ENABLE = $d015
@@ -14,13 +21,6 @@
   .label BGCOL3 = $d023
   .label BGCOL4 = $d024
   .label D018 = $d018
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const RED = 2
-  .const GREEN = 5
-  .const BLUE = 6
-  .const YELLOW = 7
   .label screen = $400
   .label charset = $2000
   .label tileset = $2800
diff --git a/src/test/ref/scan-desire-problem.log b/src/test/ref/scan-desire-problem.log
index b54d59604..23c335f07 100644
--- a/src/test/ref/scan-desire-problem.log
+++ b/src/test/ref/scan-desire-problem.log
@@ -1372,6 +1372,13 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const RED = 2
+  .const GREEN = 5
+  .const BLUE = 6
+  .const YELLOW = 7
   .label SPRITES_XMSB = $d010
   .label SPRITES_COLS = $d027
   .label SPRITES_ENABLE = $d015
@@ -1384,13 +1391,6 @@ Target platform is c64basic / MOS6502X
   .label BGCOL3 = $d023
   .label BGCOL4 = $d024
   .label D018 = $d018
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const RED = 2
-  .const GREEN = 5
-  .const BLUE = 6
-  .const YELLOW = 7
   .label screen = $400
   .label charset = $2000
   .label tileset = $2800
@@ -2082,6 +2082,13 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const RED = 2
+  .const GREEN = 5
+  .const BLUE = 6
+  .const YELLOW = 7
   .label SPRITES_XMSB = $d010
   .label SPRITES_COLS = $d027
   .label SPRITES_ENABLE = $d015
@@ -2094,13 +2101,6 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label BGCOL3 = $d023
   .label BGCOL4 = $d024
   .label D018 = $d018
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const RED = 2
-  .const GREEN = 5
-  .const BLUE = 6
-  .const YELLOW = 7
   .label screen = $400
   .label charset = $2000
   .label tileset = $2800
@@ -2898,6 +2898,13 @@ Score: 75497
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  // The colors of the C64
+  .const BLACK = 0
+  .const WHITE = 1
+  .const RED = 2
+  .const GREEN = 5
+  .const BLUE = 6
+  .const YELLOW = 7
   .label SPRITES_XMSB = $d010
   .label SPRITES_COLS = $d027
   .label SPRITES_ENABLE = $d015
@@ -2910,13 +2917,6 @@ Score: 75497
   .label BGCOL3 = $d023
   .label BGCOL4 = $d024
   .label D018 = $d018
-  // The colors of the C64
-  .const BLACK = 0
-  .const WHITE = 1
-  .const RED = 2
-  .const GREEN = 5
-  .const BLUE = 6
-  .const YELLOW = 7
   .label screen = $400
   .label charset = $2000
   .label tileset = $2800
diff --git a/src/test/ref/screen-center-angle.asm b/src/test/ref/screen-center-angle.asm
index f29019cd8..3c3cebe17 100644
--- a/src/test/ref/screen-center-angle.asm
+++ b/src/test/ref/screen-center-angle.asm
@@ -7,25 +7,25 @@
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
-  .label D018 = $d018
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#2 timer A&B as one single 32-bit value
-  .label CIA2_TIMER_AB = $dd04
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
   // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
   // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
   .const CLOCKS_PER_INIT = $12
-  .label CHARSET = $2000
-  .label SCREEN = $2800
   .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
   .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
+  .label D018 = $d018
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#2 timer A&B as one single 32-bit value
+  .label CIA2_TIMER_AB = $dd04
+  .label CHARSET = $2000
+  .label SCREEN = $2800
 main: {
-    .label BASE_SCREEN = $400
-    .label BASE_CHARSET = $1000
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
     .const toD0182_return = (>(BASE_SCREEN&$3fff)*4)|(>BASE_CHARSET)/4&$f
+    .label BASE_SCREEN = $400
+    .label BASE_CHARSET = $1000
     .label __4 = $12
     .label cyclecount = $12
     // init_font_hex(CHARSET)
diff --git a/src/test/ref/screen-center-angle.log b/src/test/ref/screen-center-angle.log
index f775fcc7a..e85bb54db 100644
--- a/src/test/ref/screen-center-angle.log
+++ b/src/test/ref/screen-center-angle.log
@@ -2526,20 +2526,20 @@ Target platform is c64basic / MOS6502X
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
-  .label D018 = $d018
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#2 timer A&B as one single 32-bit value
-  .label CIA2_TIMER_AB = $dd04
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
   // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
   // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
   .const CLOCKS_PER_INIT = $12
-  .label CHARSET = $2000
-  .label SCREEN = $2800
   .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
   .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
+  .label D018 = $d018
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#2 timer A&B as one single 32-bit value
+  .label CIA2_TIMER_AB = $dd04
+  .label CHARSET = $2000
+  .label SCREEN = $2800
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -2558,10 +2558,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label BASE_SCREEN = $400
-    .label BASE_CHARSET = $1000
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
     .const toD0182_return = (>(BASE_SCREEN&$3fff)*4)|(>BASE_CHARSET)/4&$f
+    .label BASE_SCREEN = $400
+    .label BASE_CHARSET = $1000
     .label __4 = $2f
     .label cyclecount = $33
     // [5] call init_font_hex 
@@ -3923,20 +3923,20 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
-  .label D018 = $d018
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#2 timer A&B as one single 32-bit value
-  .label CIA2_TIMER_AB = $dd04
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
   // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
   // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
   .const CLOCKS_PER_INIT = $12
-  .label CHARSET = $2000
-  .label SCREEN = $2800
   .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
   .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
+  .label D018 = $d018
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#2 timer A&B as one single 32-bit value
+  .label CIA2_TIMER_AB = $dd04
+  .label CHARSET = $2000
+  .label SCREEN = $2800
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -3955,10 +3955,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label BASE_SCREEN = $400
-    .label BASE_CHARSET = $1000
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
     .const toD0182_return = (>(BASE_SCREEN&$3fff)*4)|(>BASE_CHARSET)/4&$f
+    .label BASE_SCREEN = $400
+    .label BASE_CHARSET = $1000
     .label __4 = $12
     .label cyclecount = $12
     // [5] call init_font_hex 
@@ -5425,20 +5425,20 @@ Score: 1044967
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
-  .label D018 = $d018
-  // The CIA#2: Serial bus, RS-232, VIC memory bank
-  .label CIA2 = $dd00
-  // CIA#2 timer A&B as one single 32-bit value
-  .label CIA2_TIMER_AB = $dd04
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
   // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
   // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
   .const CLOCKS_PER_INIT = $12
-  .label CHARSET = $2000
-  .label SCREEN = $2800
   .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
   .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
+  .label D018 = $d018
+  // The CIA#2: Serial bus, RS-232, VIC memory bank
+  .label CIA2 = $dd00
+  // CIA#2 timer A&B as one single 32-bit value
+  .label CIA2_TIMER_AB = $dd04
+  .label CHARSET = $2000
+  .label SCREEN = $2800
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
@@ -5448,10 +5448,10 @@ Score: 1044967
   // @end
   // main
 main: {
-    .label BASE_SCREEN = $400
-    .label BASE_CHARSET = $1000
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
     .const toD0182_return = (>(BASE_SCREEN&$3fff)*4)|(>BASE_CHARSET)/4&$f
+    .label BASE_SCREEN = $400
+    .label BASE_CHARSET = $1000
     .label __4 = $12
     .label cyclecount = $12
     // init_font_hex(CHARSET)
diff --git a/src/test/ref/screen-center-distance.asm b/src/test/ref/screen-center-distance.asm
index 54315d11c..f66506b6f 100644
--- a/src/test/ref/screen-center-distance.asm
+++ b/src/test/ref/screen-center-distance.asm
@@ -7,30 +7,30 @@
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
+  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
+  .const CLOCKS_PER_INIT = $12
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
+  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
+  .const NUM_SQUARES = $30
   .label D018 = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
-  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
-  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
-  .const CLOCKS_PER_INIT = $12
   .label CHARSET = $2000
   .label SCREEN = $2800
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
-  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
-  .const NUM_SQUARES = $30
   // Squares for each char value SQUARES[i] = i*i
   // Initialized by init_squares()
   .label SQUARES = malloc.return
 main: {
-    .label BASE_SCREEN = $400
-    .label BASE_CHARSET = $1000
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
     .const toD0182_return = (>(BASE_SCREEN&$3fff)*4)|(>BASE_CHARSET)/4&$f
+    .label BASE_SCREEN = $400
+    .label BASE_CHARSET = $1000
     .label __4 = $c
     .label cyclecount = $c
     // init_font_hex(CHARSET)
diff --git a/src/test/ref/screen-center-distance.log b/src/test/ref/screen-center-distance.log
index 30b29e109..e158c3293 100644
--- a/src/test/ref/screen-center-distance.log
+++ b/src/test/ref/screen-center-distance.log
@@ -3054,22 +3054,22 @@ Target platform is c64basic / MOS6502X
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
+  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
+  .const CLOCKS_PER_INIT = $12
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
+  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
+  .const NUM_SQUARES = $30
   .label D018 = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
-  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
-  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
-  .const CLOCKS_PER_INIT = $12
   .label CHARSET = $2000
   .label SCREEN = $2800
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
-  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
-  .const NUM_SQUARES = $30
   // Squares for each char value SQUARES[i] = i*i
   // Initialized by init_squares()
   .label SQUARES = malloc.return
@@ -3091,10 +3091,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label BASE_SCREEN = $400
-    .label BASE_CHARSET = $1000
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
     .const toD0182_return = (>(BASE_SCREEN&$3fff)*4)|(>BASE_CHARSET)/4&$f
+    .label BASE_SCREEN = $400
+    .label BASE_CHARSET = $1000
     .label __4 = $2e
     .label cyclecount = $32
     // [5] call init_font_hex 
@@ -4573,22 +4573,22 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
+  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
+  .const CLOCKS_PER_INIT = $12
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
+  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
+  .const NUM_SQUARES = $30
   .label D018 = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
-  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
-  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
-  .const CLOCKS_PER_INIT = $12
   .label CHARSET = $2000
   .label SCREEN = $2800
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
-  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
-  .const NUM_SQUARES = $30
   // Squares for each char value SQUARES[i] = i*i
   // Initialized by init_squares()
   .label SQUARES = malloc.return
@@ -4610,10 +4610,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label BASE_SCREEN = $400
-    .label BASE_CHARSET = $1000
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
     .const toD0182_return = (>(BASE_SCREEN&$3fff)*4)|(>BASE_CHARSET)/4&$f
+    .label BASE_SCREEN = $400
+    .label BASE_CHARSET = $1000
     .label __4 = $c
     .label cyclecount = $c
     // [5] call init_font_hex 
@@ -6128,22 +6128,22 @@ Score: 203667
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
+  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
+  .const CLOCKS_PER_INIT = $12
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
+  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
+  .const NUM_SQUARES = $30
   .label D018 = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
-  // Clock cycles used to start & read the cycle clock by calling clock_start() and clock() once. Can be subtracted when calculating the number of cycles used by a routine.
-  // To make precise cycle measurements interrupts and the display must be disabled so neither steals any cycles from the code.
-  .const CLOCKS_PER_INIT = $12
   .label CHARSET = $2000
   .label SCREEN = $2800
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   // Top of the heap used by malloc()
   .label HEAP_TOP = $a000
-  // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
-  .const NUM_SQUARES = $30
   // Squares for each char value SQUARES[i] = i*i
   // Initialized by init_squares()
   .label SQUARES = malloc.return
@@ -6156,10 +6156,10 @@ Score: 203667
   // @end
   // main
 main: {
-    .label BASE_SCREEN = $400
-    .label BASE_CHARSET = $1000
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
     .const toD0182_return = (>(BASE_SCREEN&$3fff)*4)|(>BASE_CHARSET)/4&$f
+    .label BASE_SCREEN = $400
+    .label BASE_CHARSET = $1000
     .label __4 = $c
     .label cyclecount = $c
     // init_font_hex(CHARSET)
diff --git a/src/test/ref/screen-show-spiral-buckets.asm b/src/test/ref/screen-show-spiral-buckets.asm
index 407344fc3..6cbba6b3e 100644
--- a/src/test/ref/screen-show-spiral-buckets.asm
+++ b/src/test/ref/screen-show-spiral-buckets.asm
@@ -3,25 +3,25 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  // Color Ram
-  .label COLS = $d800
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
-  // Screen containing angle to center
-  .label SCREEN_FILL = $400
   // Char to fill with
   .const FILL_CHAR = '*'
   // The number of buckets in our bucket sort
   .const NUM_BUCKETS = $30
   .const SIZEOF_BYTE = 1
   .const SIZEOF_POINTER = 2
-  // Top of the heap used by malloc()
-  .label HEAP_TOP = $a000
   // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
   .const NUM_SQUARES = $30
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  // Color Ram
+  .label COLS = $d800
+  // Screen containing angle to center
+  .label SCREEN_FILL = $400
+  // Top of the heap used by malloc()
+  .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
   .label heap_head = 4
   // Squares for each char value SQUARES[i] = i*i
diff --git a/src/test/ref/screen-show-spiral-buckets.log b/src/test/ref/screen-show-spiral-buckets.log
index f676db759..8cf5ebde9 100644
--- a/src/test/ref/screen-show-spiral-buckets.log
+++ b/src/test/ref/screen-show-spiral-buckets.log
@@ -4691,25 +4691,25 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  // Color Ram
-  .label COLS = $d800
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
-  // Screen containing angle to center
-  .label SCREEN_FILL = $400
   // Char to fill with
   .const FILL_CHAR = '*'
   // The number of buckets in our bucket sort
   .const NUM_BUCKETS = $30
   .const SIZEOF_BYTE = 1
   .const SIZEOF_POINTER = 2
-  // Top of the heap used by malloc()
-  .label HEAP_TOP = $a000
   // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
   .const NUM_SQUARES = $30
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  // Color Ram
+  .label COLS = $d800
+  // Screen containing angle to center
+  .label SCREEN_FILL = $400
+  // Top of the heap used by malloc()
+  .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $15
   // Squares for each char value SQUARES[i] = i*i
@@ -7258,25 +7258,25 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  // Color Ram
-  .label COLS = $d800
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
-  // Screen containing angle to center
-  .label SCREEN_FILL = $400
   // Char to fill with
   .const FILL_CHAR = '*'
   // The number of buckets in our bucket sort
   .const NUM_BUCKETS = $30
   .const SIZEOF_BYTE = 1
   .const SIZEOF_POINTER = 2
-  // Top of the heap used by malloc()
-  .label HEAP_TOP = $a000
   // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
   .const NUM_SQUARES = $30
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  // Color Ram
+  .label COLS = $d800
+  // Screen containing angle to center
+  .label SCREEN_FILL = $400
+  // Top of the heap used by malloc()
+  .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
   .label heap_head = 4
   // Squares for each char value SQUARES[i] = i*i
@@ -9779,25 +9779,25 @@ Score: 1116714
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label RASTER = $d012
-  .label BORDERCOL = $d020
-  // Color Ram
-  .label COLS = $d800
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
-  // Screen containing angle to center
-  .label SCREEN_FILL = $400
   // Char to fill with
   .const FILL_CHAR = '*'
   // The number of buckets in our bucket sort
   .const NUM_BUCKETS = $30
   .const SIZEOF_BYTE = 1
   .const SIZEOF_POINTER = 2
-  // Top of the heap used by malloc()
-  .label HEAP_TOP = $a000
   // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
   .const NUM_SQUARES = $30
+  .label RASTER = $d012
+  .label BORDERCOL = $d020
+  // Color Ram
+  .label COLS = $d800
+  // Screen containing angle to center
+  .label SCREEN_FILL = $400
+  // Top of the heap used by malloc()
+  .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
   .label heap_head = 4
   // Squares for each char value SQUARES[i] = i*i
diff --git a/src/test/ref/screen-show-spiral.asm b/src/test/ref/screen-show-spiral.asm
index bb1be4c88..f0f5dc53a 100644
--- a/src/test/ref/screen-show-spiral.asm
+++ b/src/test/ref/screen-show-spiral.asm
@@ -5,14 +5,14 @@
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
-  // Screen containing angle to center
-  .label SCREEN_FILL = $400
   // Char to fill with
   .const FILL_CHAR = '@'
-  // Top of the heap used by malloc()
-  .label HEAP_TOP = $a000
   // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
   .const NUM_SQUARES = $30
+  // Screen containing angle to center
+  .label SCREEN_FILL = $400
+  // Top of the heap used by malloc()
+  .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $15
   // Squares for each char value SQUARES[i] = i*i
diff --git a/src/test/ref/screen-show-spiral.log b/src/test/ref/screen-show-spiral.log
index 81e370a43..cac9aa3ad 100644
--- a/src/test/ref/screen-show-spiral.log
+++ b/src/test/ref/screen-show-spiral.log
@@ -3445,14 +3445,14 @@ Target platform is c64basic / MOS6502X
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
-  // Screen containing angle to center
-  .label SCREEN_FILL = $400
   // Char to fill with
   .const FILL_CHAR = '@'
-  // Top of the heap used by malloc()
-  .label HEAP_TOP = $a000
   // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
   .const NUM_SQUARES = $30
+  // Screen containing angle to center
+  .label SCREEN_FILL = $400
+  // Top of the heap used by malloc()
+  .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $35
   // Squares for each char value SQUARES[i] = i*i
@@ -5397,14 +5397,14 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
-  // Screen containing angle to center
-  .label SCREEN_FILL = $400
   // Char to fill with
   .const FILL_CHAR = '@'
-  // Top of the heap used by malloc()
-  .label HEAP_TOP = $a000
   // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
   .const NUM_SQUARES = $30
+  // Screen containing angle to center
+  .label SCREEN_FILL = $400
+  // Top of the heap used by malloc()
+  .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $15
   // Squares for each char value SQUARES[i] = i*i
@@ -7263,14 +7263,14 @@ Score: 1112776
   .const SIZEOF_WORD = 2
   // The number of iterations performed during 16-bit CORDIC atan2 calculation
   .const CORDIC_ITERATIONS_16 = $f
-  // Screen containing angle to center
-  .label SCREEN_FILL = $400
   // Char to fill with
   .const FILL_CHAR = '@'
-  // Top of the heap used by malloc()
-  .label HEAP_TOP = $a000
   // The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt()
   .const NUM_SQUARES = $30
+  // Screen containing angle to center
+  .label SCREEN_FILL = $400
+  // Top of the heap used by malloc()
+  .label HEAP_TOP = $a000
   // Head of the heap. Moved backward each malloc()
   .label heap_head = $15
   // Squares for each char value SQUARES[i] = i*i
diff --git a/src/test/ref/semi-struct-2.asm b/src/test/ref/semi-struct-2.asm
index ab13ab356..0a30c688e 100644
--- a/src/test/ref/semi-struct-2.asm
+++ b/src/test/ref/semi-struct-2.asm
@@ -21,8 +21,6 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
   .const KEY_SPACE = $3c
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   // The size of a file ENTRY
   .const SIZEOF_ENTRY = $12
   // The maximal number of files
@@ -30,6 +28,8 @@
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label print_line_cursor = $c
   .label print_char_cursor = 2
   .label print_line_cursor_1 = 4
diff --git a/src/test/ref/semi-struct-2.log b/src/test/ref/semi-struct-2.log
index 52a368b62..246bd64d2 100644
--- a/src/test/ref/semi-struct-2.log
+++ b/src/test/ref/semi-struct-2.log
@@ -5070,8 +5070,6 @@ Target platform is c64basic / MOS6502X
 .pc = $80d "Program"
   // Global Constants & labels
   .const KEY_SPACE = $3c
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   // The size of a file ENTRY
   .const SIZEOF_ENTRY = $12
   // The maximal number of files
@@ -5079,6 +5077,8 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label print_line_cursor = $2c
   .label print_char_cursor = 7
   .label print_line_cursor_1 = 9
@@ -7217,8 +7217,6 @@ ASSEMBLER BEFORE OPTIMIZATION
 .pc = $80d "Program"
   // Global Constants & labels
   .const KEY_SPACE = $3c
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   // The size of a file ENTRY
   .const SIZEOF_ENTRY = $12
   // The maximal number of files
@@ -7226,6 +7224,8 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label print_line_cursor = $c
   .label print_char_cursor = 2
   .label print_line_cursor_1 = 4
@@ -9857,8 +9857,6 @@ Score: 3925
 .pc = $80d "Program"
   // Global Constants & labels
   .const KEY_SPACE = $3c
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   // The size of a file ENTRY
   .const SIZEOF_ENTRY = $12
   // The maximal number of files
@@ -9866,6 +9864,8 @@ Score: 3925
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   .label print_line_cursor = $c
   .label print_char_cursor = 2
   .label print_line_cursor_1 = 4
diff --git a/src/test/ref/sieve-min.asm b/src/test/ref/sieve-min.asm
index 7dbbbc38c..63605b605 100644
--- a/src/test/ref/sieve-min.asm
+++ b/src/test/ref/sieve-min.asm
@@ -1,10 +1,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const COUNT = $4000
   /* Up to what number? */
   .const SQRT_COUNT = $80
+  .label SCREEN = $400
   /* Sqrt of COUNT */
   .label sieve = $1000
   .label print_char_cursor = $a
@@ -201,8 +201,8 @@ print_uchar: {
 }
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = sieve
     .const c = 0
+    .label str = sieve
     .label end = str+COUNT
     .label dst = $c
     lda #<str
diff --git a/src/test/ref/sieve-min.log b/src/test/ref/sieve-min.log
index 024a53cfb..dcef4ba01 100644
--- a/src/test/ref/sieve-min.log
+++ b/src/test/ref/sieve-min.log
@@ -1096,10 +1096,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const COUNT = $4000
   /* Up to what number? */
   .const SQRT_COUNT = $80
+  .label SCREEN = $400
   /* Sqrt of COUNT */
   .label sieve = $1000
   .label print_char_cursor = $d
@@ -1428,8 +1428,8 @@ print_uchar: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = sieve
     .const c = 0
+    .label str = sieve
     .label end = str+COUNT
     .label dst = $10
     // [47] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -1563,10 +1563,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const COUNT = $4000
   /* Up to what number? */
   .const SQRT_COUNT = $80
+  .label SCREEN = $400
   /* Sqrt of COUNT */
   .label sieve = $1000
   .label print_char_cursor = $a
@@ -1878,8 +1878,8 @@ print_uchar: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = sieve
     .const c = 0
+    .label str = sieve
     .label end = str+COUNT
     .label dst = $c
     // [47] phi from memset to memset::@1 [phi:memset->memset::@1]
@@ -2176,10 +2176,10 @@ Score: 9762
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const COUNT = $4000
   /* Up to what number? */
   .const SQRT_COUNT = $80
+  .label SCREEN = $400
   /* Sqrt of COUNT */
   .label sieve = $1000
   .label print_char_cursor = $a
@@ -2473,8 +2473,8 @@ print_uchar: {
   // memset
 // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
 memset: {
-    .label str = sieve
     .const c = 0
+    .label str = sieve
     .label end = str+COUNT
     .label dst = $c
     // [47] phi from memset to memset::@1 [phi:memset->memset::@1]
diff --git a/src/test/ref/sieve.asm b/src/test/ref/sieve.asm
index 41841182d..6753f2197 100644
--- a/src/test/ref/sieve.asm
+++ b/src/test/ref/sieve.asm
@@ -14,17 +14,17 @@
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  .const COUNT = $4000
+  /* Up to what number? */
+  .const SQRT_COUNT = $80
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   .label D018 = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
-  .const COUNT = $4000
-  /* Up to what number? */
-  .const SQRT_COUNT = $80
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   /* Sqrt of COUNT */
   .label sieve = $1000
   // Remainder after unsigned 16-bit division
@@ -33,8 +33,8 @@
   .label print_line_cursor = $c
   .label print_char_cursor_1 = $c
 main: {
-    .label toD0181_gfx = $1800
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>toD0181_gfx)/4&$f
+    .label toD0181_gfx = $1800
     .label __10 = $f
     .label __12 = $17
     .label cyclecount = $f
diff --git a/src/test/ref/sieve.log b/src/test/ref/sieve.log
index d9cb25b36..61dcd70ab 100644
--- a/src/test/ref/sieve.log
+++ b/src/test/ref/sieve.log
@@ -3965,17 +3965,17 @@ Target platform is c64basic / MOS6502X
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  .const COUNT = $4000
+  /* Up to what number? */
+  .const SQRT_COUNT = $80
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   .label D018 = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
-  .const COUNT = $4000
-  /* Up to what number? */
-  .const SQRT_COUNT = $80
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   /* Sqrt of COUNT */
   .label sieve = $1000
   // Remainder after unsigned 16-bit division
@@ -4001,8 +4001,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label toD0181_gfx = $1800
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>toD0181_gfx)/4&$f
+    .label toD0181_gfx = $1800
     .label __10 = $3d
     .label __12 = $4d
     .label cyclecount = $41
@@ -5915,17 +5915,17 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  .const COUNT = $4000
+  /* Up to what number? */
+  .const SQRT_COUNT = $80
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   .label D018 = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
-  .const COUNT = $4000
-  /* Up to what number? */
-  .const SQRT_COUNT = $80
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   /* Sqrt of COUNT */
   .label sieve = $1000
   // Remainder after unsigned 16-bit division
@@ -5951,8 +5951,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label toD0181_gfx = $1800
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>toD0181_gfx)/4&$f
+    .label toD0181_gfx = $1800
     .label __10 = $f
     .label __12 = $17
     .label cyclecount = $f
@@ -7988,17 +7988,17 @@ Score: 82397
   .const CIA_TIMER_CONTROL_START = 1
   // Timer B Control - Timer counts (00:system cycles, 01: CNT pulses, 10: timer A underflow, 11: time A underflow while CNT is high)
   .const CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A = $40
+  .const COUNT = $4000
+  /* Up to what number? */
+  .const SQRT_COUNT = $80
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
+  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   .label D018 = $d018
   // The CIA#2: Serial bus, RS-232, VIC memory bank
   .label CIA2 = $dd00
   // CIA#2 timer A&B as one single 32-bit value
   .label CIA2_TIMER_AB = $dd04
   .label SCREEN = $400
-  .const COUNT = $4000
-  /* Up to what number? */
-  .const SQRT_COUNT = $80
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_A_CONTROL = $e
-  .const OFFSET_STRUCT_MOS6526_CIA_TIMER_B_CONTROL = $f
   /* Sqrt of COUNT */
   .label sieve = $1000
   // Remainder after unsigned 16-bit division
@@ -8015,8 +8015,8 @@ Score: 82397
   // @end
   // main
 main: {
-    .label toD0181_gfx = $1800
     .const toD0181_return = (>(SCREEN&$3fff)*4)|(>toD0181_gfx)/4&$f
+    .label toD0181_gfx = $1800
     .label __10 = $f
     .label __12 = $17
     .label cyclecount = $f
diff --git a/src/test/ref/signed-words.asm b/src/test/ref/signed-words.asm
index d3a2640b1..89235fa4d 100644
--- a/src/test/ref/signed-words.asm
+++ b/src/test/ref/signed-words.asm
@@ -1,6 +1,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const WHITE = 1
+  .const g = -5
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -9,11 +11,9 @@
   .label SPRITES_EXPAND_Y = $d017
   .label SPRITES_EXPAND_X = $d01d
   .label RASTER = $d012
-  .const WHITE = 1
   .label SCREEN = $400
   .label SPRITES_PTR = SCREEN+$3f8
   .label SPRITE = $2000
-  .const g = -5
   // Reset y velocity
   .label yvel_init = 4
   .label yvel = 4
diff --git a/src/test/ref/signed-words.log b/src/test/ref/signed-words.log
index 297826dcd..91babc664 100644
--- a/src/test/ref/signed-words.log
+++ b/src/test/ref/signed-words.log
@@ -1013,6 +1013,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const WHITE = 1
+  .const g = -5
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -1021,11 +1023,9 @@ Target platform is c64basic / MOS6502X
   .label SPRITES_EXPAND_Y = $d017
   .label SPRITES_EXPAND_X = $d01d
   .label RASTER = $d012
-  .const WHITE = 1
   .label SCREEN = $400
   .label SPRITES_PTR = SCREEN+$3f8
   .label SPRITE = $2000
-  .const g = -5
   // Reset y velocity
   .label yvel_init = 4
   .label yvel = 4
@@ -1468,6 +1468,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const WHITE = 1
+  .const g = -5
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -1476,11 +1478,9 @@ ASSEMBLER BEFORE OPTIMIZATION
   .label SPRITES_EXPAND_Y = $d017
   .label SPRITES_EXPAND_X = $d01d
   .label RASTER = $d012
-  .const WHITE = 1
   .label SCREEN = $400
   .label SPRITES_PTR = SCREEN+$3f8
   .label SPRITE = $2000
-  .const g = -5
   // Reset y velocity
   .label yvel_init = 4
   .label yvel = 4
@@ -2057,6 +2057,8 @@ Score: 6373
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const WHITE = 1
+  .const g = -5
   .label SPRITES_XPOS = $d000
   .label SPRITES_YPOS = $d001
   .label SPRITES_XMSB = $d010
@@ -2065,11 +2067,9 @@ Score: 6373
   .label SPRITES_EXPAND_Y = $d017
   .label SPRITES_EXPAND_X = $d01d
   .label RASTER = $d012
-  .const WHITE = 1
   .label SCREEN = $400
   .label SPRITES_PTR = SCREEN+$3f8
   .label SPRITE = $2000
-  .const g = -5
   // Reset y velocity
   .label yvel_init = 4
   .label yvel = 4
diff --git a/src/test/ref/sinusgenscale8.asm b/src/test/ref/sinusgenscale8.asm
index 6f1d05860..7a4761ad1 100644
--- a/src/test/ref/sinusgenscale8.asm
+++ b/src/test/ref/sinusgenscale8.asm
@@ -28,9 +28,9 @@ main: {
 sin8u_table: {
     .const min = $a
     .const max = $ff
-    .label amplitude = max-min
     .const sum = min+max
     .const mid = sum/2+1
+    .label amplitude = max-min
     .label step = $e
     .label sinx = $12
     .label sinx_sc = $a
diff --git a/src/test/ref/sinusgenscale8.log b/src/test/ref/sinusgenscale8.log
index 65311ba97..5871209b7 100644
--- a/src/test/ref/sinusgenscale8.log
+++ b/src/test/ref/sinusgenscale8.log
@@ -3724,9 +3724,9 @@ main: {
 sin8u_table: {
     .const min = $a
     .const max = $ff
-    .label amplitude = max-min
     .const sum = min+max
     .const mid = sum/2+1
+    .label amplitude = max-min
     .label __20 = $37
     .label step = $30
     .label sinx = $33
@@ -5509,9 +5509,9 @@ main: {
 sin8u_table: {
     .const min = $a
     .const max = $ff
-    .label amplitude = max-min
     .const sum = min+max
     .const mid = sum/2+1
+    .label amplitude = max-min
     .label step = $e
     .label sinx = $12
     .label sinx_sc = $a
@@ -7509,9 +7509,9 @@ main: {
 sin8u_table: {
     .const min = $a
     .const max = $ff
-    .label amplitude = max-min
     .const sum = min+max
     .const mid = sum/2+1
+    .label amplitude = max-min
     .label step = $e
     .label sinx = $12
     .label sinx_sc = $a
diff --git a/src/test/ref/sizeof-arrays.asm b/src/test/ref/sizeof-arrays.asm
index c255a751d..848056daf 100644
--- a/src/test/ref/sizeof-arrays.asm
+++ b/src/test/ref/sizeof-arrays.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_WORD = 2
+  .label SCREEN = $400
 main: {
     .const sz = 7
     // SCREEN[idx++] = '0'+sizeof(ba)/sizeof(byte)
diff --git a/src/test/ref/sizeof-arrays.log b/src/test/ref/sizeof-arrays.log
index dd49f6dc8..db35b6fe2 100644
--- a/src/test/ref/sizeof-arrays.log
+++ b/src/test/ref/sizeof-arrays.log
@@ -296,9 +296,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_WORD = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -365,9 +365,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_WORD = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -453,9 +453,9 @@ Score: 42
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_WORD = 2
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/sizeof-expr.asm b/src/test/ref/sizeof-expr.asm
index 6e4052106..c177930d1 100644
--- a/src/test/ref/sizeof-expr.asm
+++ b/src/test/ref/sizeof-expr.asm
@@ -2,11 +2,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_NUMBER = $ff
   .const SIZEOF_WORD = 2
   .const SIZEOF_POINTER = 2
+  .label SCREEN = $400
 main: {
     // SCREEN[idx++] = '0'+sizeof(0)
     lda #'0'+SIZEOF_NUMBER
diff --git a/src/test/ref/sizeof-expr.log b/src/test/ref/sizeof-expr.log
index 39ad15166..0aed96cbe 100644
--- a/src/test/ref/sizeof-expr.log
+++ b/src/test/ref/sizeof-expr.log
@@ -293,11 +293,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_NUMBER = $ff
   .const SIZEOF_WORD = 2
   .const SIZEOF_POINTER = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -371,11 +371,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_NUMBER = $ff
   .const SIZEOF_WORD = 2
   .const SIZEOF_POINTER = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -471,11 +471,11 @@ Score: 48
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_NUMBER = $ff
   .const SIZEOF_WORD = 2
   .const SIZEOF_POINTER = 2
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/sizeof-in-const-pointer.asm b/src/test/ref/sizeof-in-const-pointer.asm
new file mode 100644
index 000000000..63f7d1e31
--- /dev/null
+++ b/src/test/ref/sizeof-in-const-pointer.asm
@@ -0,0 +1,14 @@
+// Support for sizeof() in const pointer definition
+.pc = $801 "Basic"
+:BasicUpstart(main)
+.pc = $80d "Program"
+  .const SIZEOF_BYTE = 1
+  // Commodore 64 processor port
+  .label SCREEN = $400+SIZEOF_BYTE*$64
+main: {
+    // SCREEN[0] = 'a'
+    lda #'a'
+    sta SCREEN
+    // }
+    rts
+}
diff --git a/src/test/ref/sizeof-in-const-pointer.cfg b/src/test/ref/sizeof-in-const-pointer.cfg
new file mode 100644
index 000000000..6a5142472
--- /dev/null
+++ b/src/test/ref/sizeof-in-const-pointer.cfg
@@ -0,0 +1,17 @@
+@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 nomodify byte*) SCREEN) ← (byte) 'a'
+  to:main::@return
+main::@return: scope:[main]  from main
+  [5] return 
+  to:@return
diff --git a/src/test/ref/sizeof-in-const-pointer.log b/src/test/ref/sizeof-in-const-pointer.log
new file mode 100644
index 000000000..aa2a97dfd
--- /dev/null
+++ b/src/test/ref/sizeof-in-const-pointer.log
@@ -0,0 +1,232 @@
+
+CONTROL FLOW GRAPH SSA
+@begin: scope:[]  from
+  to:@1
+
+(void()) main()
+main: scope:[main]  from @1
+  *((const nomodify byte*) SCREEN + (number) 0) ← (byte) 'a'
+  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 nomodify byte*) SCREEN = (byte*)(number) $400+(const byte) SIZEOF_BYTE*(number) $64
+(const byte) SIZEOF_BYTE = (byte) 1
+(void()) main()
+(label) main::@return
+
+Adding number conversion cast (unumber) $64 in 
+Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SCREEN + (number) 0) ← (byte) 'a'
+Successful SSA optimization PassNAddNumberTypeConversions
+Adding number conversion cast (unumber) $400 in 
+Successful SSA optimization PassNAddNumberTypeConversions
+Simplifying constant integer cast $400
+Simplifying constant integer cast $64
+Simplifying constant integer cast 0
+Successful SSA optimization PassNCastSimplification
+Finalized unsigned number type (word) $400
+Finalized unsigned number type (byte) $64
+Finalized unsigned number type (byte) 0
+Successful SSA optimization PassNFinalizeNumberTypeConversions
+Simplifying expression containing zero SCREEN in [0] *((const nomodify byte*) SCREEN + (byte) 0) ← (byte) 'a'
+Successful SSA optimization PassNSimplifyExpressionWithZero
+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 nomodify byte*) SCREEN) ← (byte) 'a'
+  to:main::@return
+main::@return: scope:[main]  from main
+  [5] return 
+  to:@return
+
+
+VARIABLE REGISTER WEIGHTS
+(void()) main()
+
+Initial phi equivalence classes
+Complete equivalence classes
+
+INITIAL ASM
+Target platform is c64basic / MOS6502X
+  // File Comments
+// Support for sizeof() in const pointer definition
+  // Upstart
+.pc = $801 "Basic"
+:BasicUpstart(__bbegin)
+.pc = $80d "Program"
+  // Global Constants & labels
+  .const SIZEOF_BYTE = 1
+  // Commodore 64 processor port
+  .label SCREEN = $400+SIZEOF_BYTE*$64
+  // @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 nomodify byte*) SCREEN) ← (byte) 'a' -- _deref_pbuc1=vbuc2 
+    lda #'a'
+    sta SCREEN
+    jmp __breturn
+    // main::@return
+  __breturn:
+    // [5] return 
+    rts
+}
+  // File Data
+
+REGISTER UPLIFT POTENTIAL REGISTERS
+Statement [4] *((const nomodify byte*) SCREEN) ← (byte) 'a' [ ] ( main:2 [ ] { }  ) always clobbers reg byte a 
+
+REGISTER UPLIFT SCOPES
+Uplift Scope [main] 
+Uplift Scope [] 
+
+Uplifting [main] best 27 combination 
+Uplifting [] best 27 combination 
+
+ASSEMBLER BEFORE OPTIMIZATION
+  // File Comments
+// Support for sizeof() in const pointer definition
+  // Upstart
+.pc = $801 "Basic"
+:BasicUpstart(__bbegin)
+.pc = $80d "Program"
+  // Global Constants & labels
+  .const SIZEOF_BYTE = 1
+  // Commodore 64 processor port
+  .label SCREEN = $400+SIZEOF_BYTE*$64
+  // @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 nomodify byte*) SCREEN) ← (byte) 'a' -- _deref_pbuc1=vbuc2 
+    lda #'a'
+    sta SCREEN
+    jmp __breturn
+    // main::@return
+  __breturn:
+    // [5] 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 nomodify byte*) SCREEN = (byte*)(word) $400+(const byte) SIZEOF_BYTE*(byte) $64
+(const byte) SIZEOF_BYTE = (byte) 1
+(void()) main()
+(label) main::@return
+
+
+
+FINAL ASSEMBLER
+Score: 12
+
+  // File Comments
+// Support for sizeof() in const pointer definition
+  // Upstart
+.pc = $801 "Basic"
+:BasicUpstart(main)
+.pc = $80d "Program"
+  // Global Constants & labels
+  .const SIZEOF_BYTE = 1
+  // Commodore 64 processor port
+  .label SCREEN = $400+SIZEOF_BYTE*$64
+  // @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[0] = 'a'
+    // [4] *((const nomodify byte*) SCREEN) ← (byte) 'a' -- _deref_pbuc1=vbuc2 
+    lda #'a'
+    sta SCREEN
+    // main::@return
+    // }
+    // [5] return 
+    rts
+}
+  // File Data
+
diff --git a/src/test/ref/sizeof-in-const-pointer.sym b/src/test/ref/sizeof-in-const-pointer.sym
new file mode 100644
index 000000000..119f5d342
--- /dev/null
+++ b/src/test/ref/sizeof-in-const-pointer.sym
@@ -0,0 +1,8 @@
+(label) @1
+(label) @begin
+(label) @end
+(const nomodify byte*) SCREEN = (byte*)(word) $400+(const byte) SIZEOF_BYTE*(byte) $64
+(const byte) SIZEOF_BYTE = (byte) 1
+(void()) main()
+(label) main::@return
+
diff --git a/src/test/ref/sizeof-struct.asm b/src/test/ref/sizeof-struct.asm
index 5d32dbfad..64f2ca5ab 100644
--- a/src/test/ref/sizeof-struct.asm
+++ b/src/test/ref/sizeof-struct.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const SIZEOF_STRUCT_CIRCLE = 3
+  .label SCREEN = $400
 main: {
     // Struct Arrays
     .const NUM_POINTS = 4
diff --git a/src/test/ref/sizeof-struct.log b/src/test/ref/sizeof-struct.log
index 4521c91ea..d52c3728f 100644
--- a/src/test/ref/sizeof-struct.log
+++ b/src/test/ref/sizeof-struct.log
@@ -306,9 +306,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const SIZEOF_STRUCT_CIRCLE = 3
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -390,9 +390,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const SIZEOF_STRUCT_CIRCLE = 3
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -493,9 +493,9 @@ Score: 54
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const SIZEOF_STRUCT_CIRCLE = 3
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/sizeof-types.asm b/src/test/ref/sizeof-types.asm
index feba88c09..8d3aff1f4 100644
--- a/src/test/ref/sizeof-types.asm
+++ b/src/test/ref/sizeof-types.asm
@@ -2,7 +2,6 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_SIGNED_BYTE = 1
   .const SIZEOF_BOOL = 1
@@ -11,6 +10,7 @@
   .const SIZEOF_POINTER = 2
   .const SIZEOF_DWORD = 4
   .const SIZEOF_SIGNED_DWORD = 4
+  .label SCREEN = $400
 main: {
     // SCREEN[idx++] = '0'+sizeof(void)
     lda #'0'
diff --git a/src/test/ref/sizeof-types.log b/src/test/ref/sizeof-types.log
index 0fb902e78..6822b1006 100644
--- a/src/test/ref/sizeof-types.log
+++ b/src/test/ref/sizeof-types.log
@@ -389,7 +389,6 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_SIGNED_BYTE = 1
   .const SIZEOF_BOOL = 1
@@ -398,6 +397,7 @@ Target platform is c64basic / MOS6502X
   .const SIZEOF_POINTER = 2
   .const SIZEOF_DWORD = 4
   .const SIZEOF_SIGNED_DWORD = 4
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -519,7 +519,6 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_SIGNED_BYTE = 1
   .const SIZEOF_BOOL = 1
@@ -528,6 +527,7 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const SIZEOF_POINTER = 2
   .const SIZEOF_DWORD = 4
   .const SIZEOF_SIGNED_DWORD = 4
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -663,7 +663,6 @@ Score: 120
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_BYTE = 1
   .const SIZEOF_SIGNED_BYTE = 1
   .const SIZEOF_BOOL = 1
@@ -672,6 +671,7 @@ Score: 120
   .const SIZEOF_POINTER = 2
   .const SIZEOF_DWORD = 4
   .const SIZEOF_SIGNED_DWORD = 4
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/string-escapes-5.asm b/src/test/ref/string-escapes-5.asm
index 2939838ba..4264f496f 100644
--- a/src/test/ref/string-escapes-5.asm
+++ b/src/test/ref/string-escapes-5.asm
@@ -3,8 +3,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const CH = '\$ff'
+  .label SCREEN = $400
 main: {
     ldx #0
   __b1:
diff --git a/src/test/ref/string-escapes-5.log b/src/test/ref/string-escapes-5.log
index c430b47a0..49c4617a0 100644
--- a/src/test/ref/string-escapes-5.log
+++ b/src/test/ref/string-escapes-5.log
@@ -141,8 +141,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const CH = '\$ff'
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -229,8 +229,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const CH = '\$ff'
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -341,8 +341,8 @@ Score: 267
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const CH = '\$ff'
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-11.asm b/src/test/ref/struct-11.asm
index 8d41e85b3..26ee0c741 100644
--- a/src/test/ref/struct-11.asm
+++ b/src/test/ref/struct-11.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
 main: {
     // print_person(jesper)
     ldx jesper
diff --git a/src/test/ref/struct-11.log b/src/test/ref/struct-11.log
index 32389a5bb..bcc13a988 100644
--- a/src/test/ref/struct-11.log
+++ b/src/test/ref/struct-11.log
@@ -326,8 +326,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   .label idx = 8
   .label idx_1 = 7
   .label idx_2 = 3
@@ -512,8 +512,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -722,8 +722,8 @@ Score: 386
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-13.asm b/src/test/ref/struct-13.asm
index 9a76d5f6c..4f1f96976 100644
--- a/src/test/ref/struct-13.asm
+++ b/src/test/ref/struct-13.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 2
+  .label SCREEN = $400
 main: {
     // point.x = 2
     lda #2
diff --git a/src/test/ref/struct-13.log b/src/test/ref/struct-13.log
index 391f7c935..98c1bea34 100644
--- a/src/test/ref/struct-13.log
+++ b/src/test/ref/struct-13.log
@@ -119,8 +119,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -182,9 +182,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -266,9 +266,9 @@ Score: 34
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 2
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-14.asm b/src/test/ref/struct-14.asm
index 2c8be5469..c737a3016 100644
--- a/src/test/ref/struct-14.asm
+++ b/src/test/ref/struct-14.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     // points[0].x = 2
     lda #2
diff --git a/src/test/ref/struct-14.log b/src/test/ref/struct-14.log
index bc86f5160..9e315d42d 100644
--- a/src/test/ref/struct-14.log
+++ b/src/test/ref/struct-14.log
@@ -168,8 +168,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -230,8 +230,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -311,8 +311,8 @@ Score: 34
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-15.asm b/src/test/ref/struct-15.asm
index bc2eaca7c..ceaf2669c 100644
--- a/src/test/ref/struct-15.asm
+++ b/src/test/ref/struct-15.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     .label point2 = 4
diff --git a/src/test/ref/struct-15.log b/src/test/ref/struct-15.log
index ccc2dbc57..6fd968cdf 100644
--- a/src/test/ref/struct-15.log
+++ b/src/test/ref/struct-15.log
@@ -133,9 +133,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -215,9 +215,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -316,9 +316,9 @@ Score: 61
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-16.asm b/src/test/ref/struct-16.asm
index 270a7f26e..5b9090a81 100644
--- a/src/test/ref/struct-16.asm
+++ b/src/test/ref/struct-16.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     // point1 = { 2, 3 }
diff --git a/src/test/ref/struct-16.log b/src/test/ref/struct-16.log
index df3a908f0..8d41a7400 100644
--- a/src/test/ref/struct-16.log
+++ b/src/test/ref/struct-16.log
@@ -111,9 +111,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -176,9 +176,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -263,9 +263,9 @@ Score: 37
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-17.asm b/src/test/ref/struct-17.asm
index 53118b6e4..a49636c22 100644
--- a/src/test/ref/struct-17.asm
+++ b/src/test/ref/struct-17.asm
@@ -2,10 +2,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
+  .label SCREEN = $400
 main: {
     .label v = 2
     // v
diff --git a/src/test/ref/struct-17.log b/src/test/ref/struct-17.log
index 71ecd13c7..eb9b32aa6 100644
--- a/src/test/ref/struct-17.log
+++ b/src/test/ref/struct-17.log
@@ -161,10 +161,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -252,10 +252,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -359,10 +359,10 @@ Score: 73
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-18.asm b/src/test/ref/struct-18.asm
index 7de3bca18..308c68f83 100644
--- a/src/test/ref/struct-18.asm
+++ b/src/test/ref/struct-18.asm
@@ -2,10 +2,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
+  .label SCREEN = $400
 main: {
     .label v = 2
     // v = { {2, 3}, {4, 5} }
diff --git a/src/test/ref/struct-18.log b/src/test/ref/struct-18.log
index 405eaee6f..f351333f1 100644
--- a/src/test/ref/struct-18.log
+++ b/src/test/ref/struct-18.log
@@ -133,10 +133,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -209,10 +209,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -306,10 +306,10 @@ Score: 53
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-19.asm b/src/test/ref/struct-19.asm
index 6242ac48d..b8b07bf0e 100644
--- a/src/test/ref/struct-19.asm
+++ b/src/test/ref/struct-19.asm
@@ -2,11 +2,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label v = 2
     .label p1 = 6
diff --git a/src/test/ref/struct-19.log b/src/test/ref/struct-19.log
index c7dacf198..b1dee44db 100644
--- a/src/test/ref/struct-19.log
+++ b/src/test/ref/struct-19.log
@@ -158,11 +158,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -272,11 +272,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -407,11 +407,11 @@ Score: 114
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_VECTOR = 4
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-20.asm b/src/test/ref/struct-20.asm
index 0d32aa9ad..c6138aa12 100644
--- a/src/test/ref/struct-20.asm
+++ b/src/test/ref/struct-20.asm
@@ -2,10 +2,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label p1 = 2
     .label p2 = 4
diff --git a/src/test/ref/struct-20.log b/src/test/ref/struct-20.log
index 5a2d24692..db01f2b91 100644
--- a/src/test/ref/struct-20.log
+++ b/src/test/ref/struct-20.log
@@ -155,10 +155,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -260,10 +260,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -386,10 +386,10 @@ Score: 101
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-21.asm b/src/test/ref/struct-21.asm
index c0a003e3d..e6adb8439 100644
--- a/src/test/ref/struct-21.asm
+++ b/src/test/ref/struct-21.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label ptr = point1
     .label point1 = 2
diff --git a/src/test/ref/struct-21.log b/src/test/ref/struct-21.log
index 96a0cb908..bf7c41d1e 100644
--- a/src/test/ref/struct-21.log
+++ b/src/test/ref/struct-21.log
@@ -137,9 +137,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -203,9 +203,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -292,9 +292,9 @@ Score: 37
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-22.asm b/src/test/ref/struct-22.asm
index bf7bea347..1f3bc9d00 100644
--- a/src/test/ref/struct-22.asm
+++ b/src/test/ref/struct-22.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     .label point2 = 4
diff --git a/src/test/ref/struct-22.log b/src/test/ref/struct-22.log
index c20fcf882..57ab355e2 100644
--- a/src/test/ref/struct-22.log
+++ b/src/test/ref/struct-22.log
@@ -194,9 +194,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -312,9 +312,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -461,9 +461,9 @@ Score: 78
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-23.asm b/src/test/ref/struct-23.asm
index f3e8b1e8c..205ac8065 100644
--- a/src/test/ref/struct-23.asm
+++ b/src/test/ref/struct-23.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     .label point2 = 4
diff --git a/src/test/ref/struct-23.log b/src/test/ref/struct-23.log
index ac1cf753c..6100af305 100644
--- a/src/test/ref/struct-23.log
+++ b/src/test/ref/struct-23.log
@@ -338,8 +338,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -509,8 +509,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -684,8 +684,8 @@ Score: 74
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-24.asm b/src/test/ref/struct-24.asm
index da07f6fe5..e5fd890c7 100644
--- a/src/test/ref/struct-24.asm
+++ b/src/test/ref/struct-24.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     // point1
diff --git a/src/test/ref/struct-24.log b/src/test/ref/struct-24.log
index 0410bf4b9..c9fae33b8 100644
--- a/src/test/ref/struct-24.log
+++ b/src/test/ref/struct-24.log
@@ -146,9 +146,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -226,9 +226,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -323,9 +323,9 @@ Score: 59
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-25.asm b/src/test/ref/struct-25.asm
index 05d266619..456f09270 100644
--- a/src/test/ref/struct-25.asm
+++ b/src/test/ref/struct-25.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 4
+  .label SCREEN = $400
 main: {
     // SCREEN[0] = sizeof(struct Point)
     lda #SIZEOF_STRUCT_POINT
diff --git a/src/test/ref/struct-25.log b/src/test/ref/struct-25.log
index 9476d259d..1d5ee8b32 100644
--- a/src/test/ref/struct-25.log
+++ b/src/test/ref/struct-25.log
@@ -89,8 +89,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 4
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -138,8 +138,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 4
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -208,8 +208,8 @@ Score: 12
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 4
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-26.asm b/src/test/ref/struct-26.asm
index 1d53d27e9..33dc4ad6d 100644
--- a/src/test/ref/struct-26.asm
+++ b/src/test/ref/struct-26.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     .label point2 = 5
diff --git a/src/test/ref/struct-26.log b/src/test/ref/struct-26.log
index e7aca5192..64ed7cfef 100644
--- a/src/test/ref/struct-26.log
+++ b/src/test/ref/struct-26.log
@@ -156,9 +156,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -246,9 +246,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -353,9 +353,9 @@ Score: 75
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-27.asm b/src/test/ref/struct-27.asm
index 7ccd96c9d..e665ed3a3 100644
--- a/src/test/ref/struct-27.asm
+++ b/src/test/ref/struct-27.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 4
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     // point1 = { 2, "jg" }
diff --git a/src/test/ref/struct-27.log b/src/test/ref/struct-27.log
index 6d2c4e042..479117653 100644
--- a/src/test/ref/struct-27.log
+++ b/src/test/ref/struct-27.log
@@ -127,9 +127,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 4
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -198,9 +198,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 4
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -290,9 +290,9 @@ Score: 45
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 4
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-28.asm b/src/test/ref/struct-28.asm
index c93bb82a3..e7015ff02 100644
--- a/src/test/ref/struct-28.asm
+++ b/src/test/ref/struct-28.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     // point1 = { 2, { 'j', 'g' } }
diff --git a/src/test/ref/struct-28.log b/src/test/ref/struct-28.log
index f36ed2677..fc996a7d7 100644
--- a/src/test/ref/struct-28.log
+++ b/src/test/ref/struct-28.log
@@ -127,9 +127,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -196,9 +196,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -286,9 +286,9 @@ Score: 45
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 3
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-29.asm b/src/test/ref/struct-29.asm
index 29087d860..960103f4a 100644
--- a/src/test/ref/struct-29.asm
+++ b/src/test/ref/struct-29.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
 main: {
     // SCREEN[0] = point1.x
     lda point1
diff --git a/src/test/ref/struct-29.log b/src/test/ref/struct-29.log
index 6c3640432..4d55ad440 100644
--- a/src/test/ref/struct-29.log
+++ b/src/test/ref/struct-29.log
@@ -121,8 +121,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -180,8 +180,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -259,8 +259,8 @@ Score: 30
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-32.asm b/src/test/ref/struct-32.asm
index 1a8d8cd9f..908d7c410 100644
--- a/src/test/ref/struct-32.asm
+++ b/src/test/ref/struct-32.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label point1 = 2
     .label point2 = 4
diff --git a/src/test/ref/struct-32.log b/src/test/ref/struct-32.log
index 925a8942e..9a12e2fa6 100644
--- a/src/test/ref/struct-32.log
+++ b/src/test/ref/struct-32.log
@@ -133,9 +133,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -215,9 +215,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -316,9 +316,9 @@ Score: 61
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-33.asm b/src/test/ref/struct-33.asm
index 9a76d5f6c..4f1f96976 100644
--- a/src/test/ref/struct-33.asm
+++ b/src/test/ref/struct-33.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 2
+  .label SCREEN = $400
 main: {
     // point.x = 2
     lda #2
diff --git a/src/test/ref/struct-33.log b/src/test/ref/struct-33.log
index 391f7c935..98c1bea34 100644
--- a/src/test/ref/struct-33.log
+++ b/src/test/ref/struct-33.log
@@ -119,8 +119,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -182,9 +182,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -266,9 +266,9 @@ Score: 34
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 2
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-34.asm b/src/test/ref/struct-34.asm
index f09704c82..0d053cc0d 100644
--- a/src/test/ref/struct-34.asm
+++ b/src/test/ref/struct-34.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const point_x = 2
   .const point_y = 3
+  .label SCREEN = $400
 main: {
     // SCREEN[0] = point.x
     lda #point_x
diff --git a/src/test/ref/struct-34.log b/src/test/ref/struct-34.log
index c2bc48470..08ce3e591 100644
--- a/src/test/ref/struct-34.log
+++ b/src/test/ref/struct-34.log
@@ -154,9 +154,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const point_x = 2
   .const point_y = 3
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -208,9 +208,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const point_x = 2
   .const point_y = 3
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -285,9 +285,9 @@ Score: 18
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const point_x = 2
   .const point_y = 3
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-35.asm b/src/test/ref/struct-35.asm
index 9e42f1764..b99f460e6 100644
--- a/src/test/ref/struct-35.asm
+++ b/src/test/ref/struct-35.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label p2 = point2
     // *p2 = point1
diff --git a/src/test/ref/struct-35.log b/src/test/ref/struct-35.log
index 70fe399ba..297f21494 100644
--- a/src/test/ref/struct-35.log
+++ b/src/test/ref/struct-35.log
@@ -115,9 +115,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -182,9 +182,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -272,9 +272,9 @@ Score: 38
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-36.asm b/src/test/ref/struct-36.asm
index 0d46e8073..b15b8b6b2 100644
--- a/src/test/ref/struct-36.asm
+++ b/src/test/ref/struct-36.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
 main: {
     // SCREEN[0] = point1.x
     lda point1
diff --git a/src/test/ref/struct-36.log b/src/test/ref/struct-36.log
index 088faefba..27fe972d3 100644
--- a/src/test/ref/struct-36.log
+++ b/src/test/ref/struct-36.log
@@ -121,8 +121,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -182,8 +182,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -263,8 +263,8 @@ Score: 30
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_INITIALS = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-37.asm b/src/test/ref/struct-37.asm
index 26f7d409b..3ec66a243 100644
--- a/src/test/ref/struct-37.asm
+++ b/src/test/ref/struct-37.asm
@@ -4,9 +4,9 @@
 .pc = $80d "Program"
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SPLINEVECTOR16_Y = 1
+  .label SCREEN = $400
 main: {
     .label to_x = 3
     .label to_y = 4
diff --git a/src/test/ref/struct-37.log b/src/test/ref/struct-37.log
index b5d99bc75..ce1a32a4a 100644
--- a/src/test/ref/struct-37.log
+++ b/src/test/ref/struct-37.log
@@ -211,9 +211,9 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SPLINEVECTOR16_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -355,9 +355,9 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SPLINEVECTOR16_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -521,9 +521,9 @@ Score: 711
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SPLINEVECTOR16_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-38.asm b/src/test/ref/struct-38.asm
index 68bfdae4c..6fab1b720 100644
--- a/src/test/ref/struct-38.asm
+++ b/src/test/ref/struct-38.asm
@@ -4,9 +4,9 @@
 .pc = $80d "Program"
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SPLINEVECTOR16_Y = 2
+  .label SCREEN = $400
 main: {
     .label to_x = 3
     .label to_y = 5
diff --git a/src/test/ref/struct-38.log b/src/test/ref/struct-38.log
index 2aa62fcec..cff425edf 100644
--- a/src/test/ref/struct-38.log
+++ b/src/test/ref/struct-38.log
@@ -230,9 +230,9 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SPLINEVECTOR16_Y = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -413,9 +413,9 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SPLINEVECTOR16_Y = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -599,9 +599,9 @@ Score: 1181
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const OFFSET_STRUCT_SPLINEVECTOR16_Y = 2
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-39.asm b/src/test/ref/struct-39.asm
index 689548339..520a26669 100644
--- a/src/test/ref/struct-39.asm
+++ b/src/test/ref/struct-39.asm
@@ -4,10 +4,10 @@
 .pc = $80d "Program"
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_VECTOR_Y = 2
+  .label SCREEN = $400
 main: {
     .label to = 4
     .label j = 3
diff --git a/src/test/ref/struct-39.log b/src/test/ref/struct-39.log
index f6673a71e..d1df2b9f0 100644
--- a/src/test/ref/struct-39.log
+++ b/src/test/ref/struct-39.log
@@ -222,10 +222,10 @@ Target platform is c64basic / MOS6502X
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_VECTOR_Y = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -402,10 +402,10 @@ ASSEMBLER BEFORE OPTIMIZATION
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_VECTOR_Y = 2
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -590,10 +590,10 @@ Score: 1141
   // Global Constants & labels
   .const MOVE_TO = 0
   .const SPLINE_TO = 1
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SEGMENT_TO = 1
   .const SIZEOF_STRUCT_VECTOR = 4
   .const OFFSET_STRUCT_VECTOR_Y = 2
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-4.asm b/src/test/ref/struct-4.asm
index 80c820ade..52787883a 100644
--- a/src/test/ref/struct-4.asm
+++ b/src/test/ref/struct-4.asm
@@ -3,10 +3,10 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const x = 2
     .const y = 3
     .const p_y = y+1
+    .label SCREEN = $400
     // SCREEN[0] = p.x
     lda #x
     sta SCREEN
diff --git a/src/test/ref/struct-4.log b/src/test/ref/struct-4.log
index bd21f4bef..46d7a98b9 100644
--- a/src/test/ref/struct-4.log
+++ b/src/test/ref/struct-4.log
@@ -137,10 +137,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const x = 2
     .const y = 3
     .const p_y = y+1
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::x -- _deref_pbuc1=vbuc2 
     lda #x
     sta SCREEN
@@ -192,10 +192,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const x = 2
     .const y = 3
     .const p_y = y+1
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::x -- _deref_pbuc1=vbuc2 
     lda #x
     sta SCREEN
@@ -263,10 +263,10 @@ Score: 18
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const x = 2
     .const y = 3
     .const p_y = y+1
+    .label SCREEN = $400
     // SCREEN[0] = p.x
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::x -- _deref_pbuc1=vbuc2 
     lda #x
diff --git a/src/test/ref/struct-41.asm b/src/test/ref/struct-41.asm
index f282d916e..db88569d3 100644
--- a/src/test/ref/struct-41.asm
+++ b/src/test/ref/struct-41.asm
@@ -2,11 +2,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const SIZEOF_STRUCT_POINT = 2
   .const SIZEOF_STRUCT_VECTOR = 4
+  .label SCREEN = $400
 main: {
     .const v1_p_x = 2
     .const v1_p_y = 3
diff --git a/src/test/ref/struct-41.log b/src/test/ref/struct-41.log
index df8a9b277..9f3302187 100644
--- a/src/test/ref/struct-41.log
+++ b/src/test/ref/struct-41.log
@@ -446,11 +446,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const SIZEOF_STRUCT_POINT = 2
   .const SIZEOF_STRUCT_VECTOR = 4
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -667,11 +667,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const SIZEOF_STRUCT_POINT = 2
   .const SIZEOF_STRUCT_VECTOR = 4
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -873,11 +873,11 @@ Score: 218
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const OFFSET_STRUCT_VECTOR_Q = 2
   .const SIZEOF_STRUCT_POINT = 2
   .const SIZEOF_STRUCT_VECTOR = 4
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-42.asm b/src/test/ref/struct-42.asm
index 2da7adc5e..8db08a8e9 100644
--- a/src/test/ref/struct-42.asm
+++ b/src/test/ref/struct-42.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label i = 2
     lda #0
diff --git a/src/test/ref/struct-42.log b/src/test/ref/struct-42.log
index aa24a9a6e..5dc06aa92 100644
--- a/src/test/ref/struct-42.log
+++ b/src/test/ref/struct-42.log
@@ -188,9 +188,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -298,9 +298,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -431,9 +431,9 @@ Score: 467
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-6.asm b/src/test/ref/struct-6.asm
index 0da76ab68..532a54d80 100644
--- a/src/test/ref/struct-6.asm
+++ b/src/test/ref/struct-6.asm
@@ -3,10 +3,10 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = 5
+    .label SCREEN = $400
     // SCREEN[0] = c.center.x
     lda #p_x
     sta SCREEN
diff --git a/src/test/ref/struct-6.log b/src/test/ref/struct-6.log
index 899544fe0..3a6d1bf55 100644
--- a/src/test/ref/struct-6.log
+++ b/src/test/ref/struct-6.log
@@ -140,10 +140,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = 5
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
     sta SCREEN
@@ -201,10 +201,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = 5
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
     sta SCREEN
@@ -278,10 +278,10 @@ Score: 24
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = 5
+    .label SCREEN = $400
     // SCREEN[0] = c.center.x
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
diff --git a/src/test/ref/struct-7.asm b/src/test/ref/struct-7.asm
index 24d5c9f49..877411e65 100644
--- a/src/test/ref/struct-7.asm
+++ b/src/test/ref/struct-7.asm
@@ -3,13 +3,13 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const t_c1_radius = 3
     .const t_c2_radius = 6
     .const t_c1_center_x = 1
     .const t_c1_center_y = 2
     .const t_c2_center_x = 4
     .const t_c2_center_y = 5
+    .label SCREEN = $400
     // SCREEN[0] = t.c1.center.x
     lda #t_c1_center_x
     sta SCREEN
diff --git a/src/test/ref/struct-7.log b/src/test/ref/struct-7.log
index ba63c9251..c0e957688 100644
--- a/src/test/ref/struct-7.log
+++ b/src/test/ref/struct-7.log
@@ -157,13 +157,13 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const t_c1_radius = 3
     .const t_c2_radius = 6
     .const t_c1_center_x = 1
     .const t_c1_center_y = 2
     .const t_c2_center_x = 4
     .const t_c2_center_y = 5
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::t_c1_center_x -- _deref_pbuc1=vbuc2 
     lda #t_c1_center_x
     sta SCREEN
@@ -235,13 +235,13 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const t_c1_radius = 3
     .const t_c2_radius = 6
     .const t_c1_center_x = 1
     .const t_c1_center_y = 2
     .const t_c2_center_x = 4
     .const t_c2_center_y = 5
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::t_c1_center_x -- _deref_pbuc1=vbuc2 
     lda #t_c1_center_x
     sta SCREEN
@@ -330,13 +330,13 @@ Score: 42
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const t_c1_radius = 3
     .const t_c2_radius = 6
     .const t_c1_center_x = 1
     .const t_c1_center_y = 2
     .const t_c2_center_x = 4
     .const t_c2_center_y = 5
+    .label SCREEN = $400
     // SCREEN[0] = t.c1.center.x
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::t_c1_center_x -- _deref_pbuc1=vbuc2 
     lda #t_c1_center_x
diff --git a/src/test/ref/struct-8.asm b/src/test/ref/struct-8.asm
index 9791e1971..d9034ae38 100644
--- a/src/test/ref/struct-8.asm
+++ b/src/test/ref/struct-8.asm
@@ -3,10 +3,10 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = 5
+    .label SCREEN = $400
     // SCREEN[0] = point.x
     lda #p_x
     sta SCREEN
diff --git a/src/test/ref/struct-8.log b/src/test/ref/struct-8.log
index b4dea2cda..f9093dd42 100644
--- a/src/test/ref/struct-8.log
+++ b/src/test/ref/struct-8.log
@@ -151,10 +151,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = 5
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
     sta SCREEN
@@ -212,10 +212,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = 5
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
     sta SCREEN
@@ -291,10 +291,10 @@ Score: 24
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = 5
+    .label SCREEN = $400
     // SCREEN[0] = point.x
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
diff --git a/src/test/ref/struct-9.asm b/src/test/ref/struct-9.asm
index a7c4ee1c6..c75cba2bb 100644
--- a/src/test/ref/struct-9.asm
+++ b/src/test/ref/struct-9.asm
@@ -3,10 +3,10 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = $c
+    .label SCREEN = $400
     // SCREEN[0] = c.center.x
     lda #p_x
     sta SCREEN
diff --git a/src/test/ref/struct-9.log b/src/test/ref/struct-9.log
index a18290126..5dd85084e 100644
--- a/src/test/ref/struct-9.log
+++ b/src/test/ref/struct-9.log
@@ -162,10 +162,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = $c
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
     sta SCREEN
@@ -223,10 +223,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = $c
+    .label SCREEN = $400
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
     sta SCREEN
@@ -301,10 +301,10 @@ Score: 24
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = $a
     .const p_y = $a
     .const c_radius = $c
+    .label SCREEN = $400
     // SCREEN[0] = c.center.x
     // [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
diff --git a/src/test/ref/struct-pointer-to-member.asm b/src/test/ref/struct-pointer-to-member.asm
new file mode 100644
index 000000000..868831b79
--- /dev/null
+++ b/src/test/ref/struct-pointer-to-member.asm
@@ -0,0 +1,19 @@
+// Support for pointer to struct member
+.pc = $801 "Basic"
+:BasicUpstart(main)
+.pc = $80d "Program"
+  .const OFFSET_STRUCT_SCREEN_COLORS_BG0 = 1
+  // Commodore 64 processor port
+  .label COLORS = $d020
+  // The background color
+  .label BGCOL = COLORS+OFFSET_STRUCT_SCREEN_COLORS_BG0
+main: {
+    // COLORS->BORDER = 0
+    lda #0
+    sta COLORS
+    // *BGCOL = 6
+    lda #6
+    sta BGCOL
+    // }
+    rts
+}
diff --git a/src/test/ref/struct-pointer-to-member.cfg b/src/test/ref/struct-pointer-to-member.cfg
new file mode 100644
index 000000000..3069db6b4
--- /dev/null
+++ b/src/test/ref/struct-pointer-to-member.cfg
@@ -0,0 +1,18 @@
+@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] *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS) ← (byte) 0
+  [5] *((const nomodify byte*) BGCOL) ← (byte) 6
+  to:main::@return
+main::@return: scope:[main]  from main
+  [6] return 
+  to:@return
diff --git a/src/test/ref/struct-pointer-to-member.log b/src/test/ref/struct-pointer-to-member.log
new file mode 100644
index 000000000..088b8da90
--- /dev/null
+++ b/src/test/ref/struct-pointer-to-member.log
@@ -0,0 +1,274 @@
+
+CONTROL FLOW GRAPH SSA
+@begin: scope:[]  from
+  to:@1
+
+(void()) main()
+main: scope:[main]  from @1
+  *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BORDER) ← (number) 0
+  *((const nomodify byte*) BGCOL) ← (number) 6
+  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 nomodify byte*) BGCOL = (byte*)(byte*)(const nomodify struct SCREEN_COLORS*) COLORS+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BG0
+(const nomodify struct SCREEN_COLORS*) COLORS = (struct SCREEN_COLORS*)(number) $d020
+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BG0 = (byte) 1
+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BORDER = (byte) 0
+(byte) SCREEN_COLORS::BG0
+(byte) SCREEN_COLORS::BG1
+(byte) SCREEN_COLORS::BG2
+(byte) SCREEN_COLORS::BG3
+(byte) SCREEN_COLORS::BORDER
+(void()) main()
+(label) main::@return
+
+Adding number conversion cast (unumber) 0 in *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BORDER) ← (number) 0
+Adding number conversion cast (unumber) 6 in *((const nomodify byte*) BGCOL) ← (number) 6
+Successful SSA optimization PassNAddNumberTypeConversions
+Inlining cast *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BORDER) ← (unumber)(number) 0
+Inlining cast *((const nomodify byte*) BGCOL) ← (unumber)(number) 6
+Successful SSA optimization Pass2InlineCast
+Simplifying constant pointer cast (struct SCREEN_COLORS*) 53280
+Simplifying constant integer cast (byte*)(const nomodify struct SCREEN_COLORS*) COLORS+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BG0
+Simplifying constant integer cast 0
+Simplifying constant integer cast 6
+Successful SSA optimization PassNCastSimplification
+Finalized unsigned number type (byte) 0
+Finalized unsigned number type (byte) 6
+Successful SSA optimization PassNFinalizeNumberTypeConversions
+Simplifying expression containing zero (byte*)COLORS in [0] *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BORDER) ← (byte) 0
+Successful SSA optimization PassNSimplifyExpressionWithZero
+Eliminating unused constant (const byte) OFFSET_STRUCT_SCREEN_COLORS_BORDER
+Successful SSA optimization PassNEliminateUnusedVars
+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] *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS) ← (byte) 0
+  [5] *((const nomodify byte*) BGCOL) ← (byte) 6
+  to:main::@return
+main::@return: scope:[main]  from main
+  [6] return 
+  to:@return
+
+
+VARIABLE REGISTER WEIGHTS
+(byte) SCREEN_COLORS::BG0
+(byte) SCREEN_COLORS::BG1
+(byte) SCREEN_COLORS::BG2
+(byte) SCREEN_COLORS::BG3
+(byte) SCREEN_COLORS::BORDER
+(void()) main()
+
+Initial phi equivalence classes
+Complete equivalence classes
+
+INITIAL ASM
+Target platform is c64basic / MOS6502X
+  // File Comments
+// Support for pointer to struct member
+  // Upstart
+.pc = $801 "Basic"
+:BasicUpstart(__bbegin)
+.pc = $80d "Program"
+  // Global Constants & labels
+  .const OFFSET_STRUCT_SCREEN_COLORS_BG0 = 1
+  // Commodore 64 processor port
+  .label COLORS = $d020
+  // The background color
+  .label BGCOL = COLORS+OFFSET_STRUCT_SCREEN_COLORS_BG0
+  // @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] *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS) ← (byte) 0 -- _deref_pbuc1=vbuc2 
+    lda #0
+    sta COLORS
+    // [5] *((const nomodify byte*) BGCOL) ← (byte) 6 -- _deref_pbuc1=vbuc2 
+    lda #6
+    sta BGCOL
+    jmp __breturn
+    // main::@return
+  __breturn:
+    // [6] return 
+    rts
+}
+  // File Data
+
+REGISTER UPLIFT POTENTIAL REGISTERS
+Statement [4] *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS) ← (byte) 0 [ ] ( main:2 [ ] { }  ) always clobbers reg byte a 
+Statement [5] *((const nomodify byte*) BGCOL) ← (byte) 6 [ ] ( main:2 [ ] { }  ) always clobbers reg byte a 
+
+REGISTER UPLIFT SCOPES
+Uplift Scope [SCREEN_COLORS] 
+Uplift Scope [main] 
+Uplift Scope [] 
+
+Uplifting [SCREEN_COLORS] best 33 combination 
+Uplifting [main] best 33 combination 
+Uplifting [] best 33 combination 
+
+ASSEMBLER BEFORE OPTIMIZATION
+  // File Comments
+// Support for pointer to struct member
+  // Upstart
+.pc = $801 "Basic"
+:BasicUpstart(__bbegin)
+.pc = $80d "Program"
+  // Global Constants & labels
+  .const OFFSET_STRUCT_SCREEN_COLORS_BG0 = 1
+  // Commodore 64 processor port
+  .label COLORS = $d020
+  // The background color
+  .label BGCOL = COLORS+OFFSET_STRUCT_SCREEN_COLORS_BG0
+  // @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] *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS) ← (byte) 0 -- _deref_pbuc1=vbuc2 
+    lda #0
+    sta COLORS
+    // [5] *((const nomodify byte*) BGCOL) ← (byte) 6 -- _deref_pbuc1=vbuc2 
+    lda #6
+    sta BGCOL
+    jmp __breturn
+    // main::@return
+  __breturn:
+    // [6] 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 nomodify byte*) BGCOL = (byte*)(const nomodify struct SCREEN_COLORS*) COLORS+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BG0
+(const nomodify struct SCREEN_COLORS*) COLORS = (struct SCREEN_COLORS*) 53280
+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BG0 = (byte) 1
+(byte) SCREEN_COLORS::BG0
+(byte) SCREEN_COLORS::BG1
+(byte) SCREEN_COLORS::BG2
+(byte) SCREEN_COLORS::BG3
+(byte) SCREEN_COLORS::BORDER
+(void()) main()
+(label) main::@return
+
+
+
+FINAL ASSEMBLER
+Score: 18
+
+  // File Comments
+// Support for pointer to struct member
+  // Upstart
+.pc = $801 "Basic"
+:BasicUpstart(main)
+.pc = $80d "Program"
+  // Global Constants & labels
+  .const OFFSET_STRUCT_SCREEN_COLORS_BG0 = 1
+  // Commodore 64 processor port
+  .label COLORS = $d020
+  // The background color
+  .label BGCOL = COLORS+OFFSET_STRUCT_SCREEN_COLORS_BG0
+  // @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: {
+    // COLORS->BORDER = 0
+    // [4] *((byte*)(const nomodify struct SCREEN_COLORS*) COLORS) ← (byte) 0 -- _deref_pbuc1=vbuc2 
+    lda #0
+    sta COLORS
+    // *BGCOL = 6
+    // [5] *((const nomodify byte*) BGCOL) ← (byte) 6 -- _deref_pbuc1=vbuc2 
+    lda #6
+    sta BGCOL
+    // main::@return
+    // }
+    // [6] return 
+    rts
+}
+  // File Data
+
diff --git a/src/test/ref/struct-pointer-to-member.sym b/src/test/ref/struct-pointer-to-member.sym
new file mode 100644
index 000000000..124f81d1b
--- /dev/null
+++ b/src/test/ref/struct-pointer-to-member.sym
@@ -0,0 +1,14 @@
+(label) @1
+(label) @begin
+(label) @end
+(const nomodify byte*) BGCOL = (byte*)(const nomodify struct SCREEN_COLORS*) COLORS+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BG0
+(const nomodify struct SCREEN_COLORS*) COLORS = (struct SCREEN_COLORS*) 53280
+(const byte) OFFSET_STRUCT_SCREEN_COLORS_BG0 = (byte) 1
+(byte) SCREEN_COLORS::BG0
+(byte) SCREEN_COLORS::BG1
+(byte) SCREEN_COLORS::BG2
+(byte) SCREEN_COLORS::BG3
+(byte) SCREEN_COLORS::BORDER
+(void()) main()
+(label) main::@return
+
diff --git a/src/test/ref/struct-ptr-16.asm b/src/test/ref/struct-ptr-16.asm
index bb6eb224b..7892bfe40 100644
--- a/src/test/ref/struct-ptr-16.asm
+++ b/src/test/ref/struct-ptr-16.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label p0 = $a000
   .label p1 = $b000
   .label p2 = $e000
diff --git a/src/test/ref/struct-ptr-16.log b/src/test/ref/struct-ptr-16.log
index 3e5860956..f6632792d 100644
--- a/src/test/ref/struct-ptr-16.log
+++ b/src/test/ref/struct-ptr-16.log
@@ -466,8 +466,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label p0 = $a000
   .label p1 = $b000
   .label p2 = $e000
@@ -706,8 +706,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label p0 = $a000
   .label p1 = $b000
   .label p2 = $e000
@@ -962,8 +962,8 @@ Score: 463
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label p0 = $a000
   .label p1 = $b000
   .label p2 = $e000
diff --git a/src/test/ref/struct-ptr-17.asm b/src/test/ref/struct-ptr-17.asm
index 0315272b9..30dda1f39 100644
--- a/src/test/ref/struct-ptr-17.asm
+++ b/src/test/ref/struct-ptr-17.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label __1_x = 2
     // get(0)
diff --git a/src/test/ref/struct-ptr-17.log b/src/test/ref/struct-ptr-17.log
index ac2dfe6c8..abd00c961 100644
--- a/src/test/ref/struct-ptr-17.log
+++ b/src/test/ref/struct-ptr-17.log
@@ -310,8 +310,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -468,8 +468,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -646,8 +646,8 @@ Score: 381
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-ptr-18.asm b/src/test/ref/struct-ptr-18.asm
index 642e2da89..46fe75179 100644
--- a/src/test/ref/struct-ptr-18.asm
+++ b/src/test/ref/struct-ptr-18.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label i = 2
     // points[0] = { 1, 2 }
diff --git a/src/test/ref/struct-ptr-18.log b/src/test/ref/struct-ptr-18.log
index 04c9c96fe..2bc363e79 100644
--- a/src/test/ref/struct-ptr-18.log
+++ b/src/test/ref/struct-ptr-18.log
@@ -290,9 +290,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label idx = 7
   .label idx_1 = 3
   // @begin
@@ -446,9 +446,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -626,9 +626,9 @@ Score: 528
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-ptr-19.asm b/src/test/ref/struct-ptr-19.asm
index bf889d990..42fa69d42 100644
--- a/src/test/ref/struct-ptr-19.asm
+++ b/src/test/ref/struct-ptr-19.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
 main: {
     .label ptr = point
     .label point = 2
diff --git a/src/test/ref/struct-ptr-19.log b/src/test/ref/struct-ptr-19.log
index 2eb0d15cd..9f923d094 100644
--- a/src/test/ref/struct-ptr-19.log
+++ b/src/test/ref/struct-ptr-19.log
@@ -261,9 +261,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label idx = 5
   .label idx_1 = 3
   // @begin
@@ -386,9 +386,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -539,9 +539,9 @@ Score: 72
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_POINT = 2
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-ptr-20.asm b/src/test/ref/struct-ptr-20.asm
index c18a4a864..f841aeaa5 100644
--- a/src/test/ref/struct-ptr-20.asm
+++ b/src/test/ref/struct-ptr-20.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_SETTING = 2
   .const OFFSET_STRUCT_SETTING_ID = 1
+  .label SCREEN = $400
 main: {
     .const len = 3*SIZEOF_STRUCT_SETTING/SIZEOF_STRUCT_SETTING
     .label setting = 2
diff --git a/src/test/ref/struct-ptr-20.log b/src/test/ref/struct-ptr-20.log
index 795b9e2a7..590aac5b9 100644
--- a/src/test/ref/struct-ptr-20.log
+++ b/src/test/ref/struct-ptr-20.log
@@ -266,9 +266,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_SETTING = 2
   .const OFFSET_STRUCT_SETTING_ID = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -389,9 +389,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_SETTING = 2
   .const OFFSET_STRUCT_SETTING_ID = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -546,9 +546,9 @@ Score: 771
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_SETTING = 2
   .const OFFSET_STRUCT_SETTING_ID = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-ptr-21.asm b/src/test/ref/struct-ptr-21.asm
index 3135a581a..697bbe425 100644
--- a/src/test/ref/struct-ptr-21.asm
+++ b/src/test/ref/struct-ptr-21.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SETTING_BUF = 1
+  .label SCREEN = $400
 main: {
     ldx #0
   __b1:
diff --git a/src/test/ref/struct-ptr-21.log b/src/test/ref/struct-ptr-21.log
index ac8f887e6..8ca93dbd9 100644
--- a/src/test/ref/struct-ptr-21.log
+++ b/src/test/ref/struct-ptr-21.log
@@ -191,8 +191,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SETTING_BUF = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -286,8 +286,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SETTING_BUF = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -404,8 +404,8 @@ Score: 571
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_SETTING_BUF = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-ptr-23.asm b/src/test/ref/struct-ptr-23.asm
index 08b4cff0c..660c663dc 100644
--- a/src/test/ref/struct-ptr-23.asm
+++ b/src/test/ref/struct-ptr-23.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = 5
   .const OFFSET_STRUCT_PERSON_INITIALS = 1
+  .label SCREEN = $400
 main: {
     .label person = persons+SIZEOF_STRUCT_PERSON
     // print_person(person)
diff --git a/src/test/ref/struct-ptr-23.log b/src/test/ref/struct-ptr-23.log
index 90934dad8..5e63ad129 100644
--- a/src/test/ref/struct-ptr-23.log
+++ b/src/test/ref/struct-ptr-23.log
@@ -332,9 +332,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = 5
   .const OFFSET_STRUCT_PERSON_INITIALS = 1
+  .label SCREEN = $400
   .label idx = 6
   .label idx_1 = 7
   .label idx_2 = 8
@@ -548,9 +548,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = 5
   .const OFFSET_STRUCT_PERSON_INITIALS = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -753,9 +753,9 @@ Score: 159
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = 5
   .const OFFSET_STRUCT_PERSON_INITIALS = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-ptr-28.asm b/src/test/ref/struct-ptr-28.asm
index 02a9b19b4..174f71819 100644
--- a/src/test/ref/struct-ptr-28.asm
+++ b/src/test/ref/struct-ptr-28.asm
@@ -4,9 +4,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = $11
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
 main: {
     .label jesper = 8
     .label henriette = $19
diff --git a/src/test/ref/struct-ptr-28.log b/src/test/ref/struct-ptr-28.log
index 4cda83e2e..652aad5f5 100644
--- a/src/test/ref/struct-ptr-28.log
+++ b/src/test/ref/struct-ptr-28.log
@@ -349,9 +349,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = $11
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   .label idx = 7
   .label idx_1 = 6
   .label idx_2 = 4
@@ -578,9 +578,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = $11
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -819,9 +819,9 @@ Score: 772
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = $11
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/struct-ptr-30.asm b/src/test/ref/struct-ptr-30.asm
index 892a31d6b..ad0c3a13b 100644
--- a/src/test/ref/struct-ptr-30.asm
+++ b/src/test/ref/struct-ptr-30.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 3
+  .label SCREEN = $400
   .label idx = 3
 main: {
     .label i = 2
diff --git a/src/test/ref/struct-ptr-30.log b/src/test/ref/struct-ptr-30.log
index 41d1d72a9..e8bda15be 100644
--- a/src/test/ref/struct-ptr-30.log
+++ b/src/test/ref/struct-ptr-30.log
@@ -303,8 +303,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
+  .label SCREEN = $400
   .label idx = 9
   .label idx_1 = $b
   .label idx_2 = $d
@@ -493,9 +493,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 3
+  .label SCREEN = $400
   .label idx = 3
   // @begin
 __bbegin:
@@ -695,9 +695,9 @@ Score: 639
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const OFFSET_STRUCT_POINT_Y = 1
   .const SIZEOF_STRUCT_POINT = 3
+  .label SCREEN = $400
   .label idx = 3
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
diff --git a/src/test/ref/struct-ptr-31.asm b/src/test/ref/struct-ptr-31.asm
index a5a8406de..89262d3cc 100644
--- a/src/test/ref/struct-ptr-31.asm
+++ b/src/test/ref/struct-ptr-31.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = $11
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
 main: {
     // print_person(persons)
     ldx #0
diff --git a/src/test/ref/struct-ptr-31.log b/src/test/ref/struct-ptr-31.log
index 4b251472b..82b428d93 100644
--- a/src/test/ref/struct-ptr-31.log
+++ b/src/test/ref/struct-ptr-31.log
@@ -336,9 +336,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = $11
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   .label idx = 7
   .label idx_1 = 6
   .label idx_2 = 4
@@ -543,9 +543,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = $11
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -767,9 +767,9 @@ Score: 740
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const SIZEOF_STRUCT_PERSON = $11
   .const OFFSET_STRUCT_PERSON_NAME = 1
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/switch-2.asm b/src/test/ref/switch-2.asm
index 3b841b7fe..afaadcbad 100644
--- a/src/test/ref/switch-2.asm
+++ b/src/test/ref/switch-2.asm
@@ -3,8 +3,8 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
-    .label SCREEN = $400
     .const b = 1
+    .label SCREEN = $400
     // SCREEN[0] = b
     lda #b
     sta SCREEN
diff --git a/src/test/ref/switch-2.log b/src/test/ref/switch-2.log
index a1eabe804..2b11efa02 100644
--- a/src/test/ref/switch-2.log
+++ b/src/test/ref/switch-2.log
@@ -147,8 +147,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const b = 1
+    .label SCREEN = $400
     jmp __b1
     // main::@1
   __b1:
@@ -199,8 +199,8 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const b = 1
+    .label SCREEN = $400
     jmp __b1
     // main::@1
   __b1:
@@ -268,8 +268,8 @@ Score: 12
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const b = 1
+    .label SCREEN = $400
     // main::@1
     // SCREEN[0] = b
     // [5] *((const byte*) main::SCREEN) ← (const byte) main::b#1 -- _deref_pbuc1=vbuc2 
diff --git a/src/test/ref/test-comments-block.asm b/src/test/ref/test-comments-block.asm
index ad9b4dba4..b9dfbd8fe 100644
--- a/src/test/ref/test-comments-block.asm
+++ b/src/test/ref/test-comments-block.asm
@@ -4,10 +4,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  // The C64 screen
-  .label SCREEN = $400
   // One of the bytes used for addition
   .const a = 'a'
+  // The C64 screen
+  .label SCREEN = $400
 /* The program entry point */
 main: {
     ldx #0
diff --git a/src/test/ref/test-comments-block.log b/src/test/ref/test-comments-block.log
index 4e3fb4446..9ffc29e7f 100644
--- a/src/test/ref/test-comments-block.log
+++ b/src/test/ref/test-comments-block.log
@@ -235,10 +235,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The C64 screen
-  .label SCREEN = $400
   // One of the bytes used for addition
   .const a = 'a'
+  // The C64 screen
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -361,10 +361,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The C64 screen
-  .label SCREEN = $400
   // One of the bytes used for addition
   .const a = 'a'
+  // The C64 screen
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -519,10 +519,10 @@ Score: 271
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The C64 screen
-  .label SCREEN = $400
   // One of the bytes used for addition
   .const a = 'a'
+  // The C64 screen
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/test-comments-single.asm b/src/test/ref/test-comments-single.asm
index 05e542cc9..8a0fa75e8 100644
--- a/src/test/ref/test-comments-single.asm
+++ b/src/test/ref/test-comments-single.asm
@@ -3,10 +3,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  // The C64 screen
-  .label SCREEN = $400
   // One of the bytes used for addition
   .const a = 'a'
+  // The C64 screen
+  .label SCREEN = $400
 // The program entry point
 main: {
     ldx #0
diff --git a/src/test/ref/test-comments-single.log b/src/test/ref/test-comments-single.log
index fea462202..ee1a326c5 100644
--- a/src/test/ref/test-comments-single.log
+++ b/src/test/ref/test-comments-single.log
@@ -234,10 +234,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The C64 screen
-  .label SCREEN = $400
   // One of the bytes used for addition
   .const a = 'a'
+  // The C64 screen
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -358,10 +358,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The C64 screen
-  .label SCREEN = $400
   // One of the bytes used for addition
   .const a = 'a'
+  // The C64 screen
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -514,10 +514,10 @@ Score: 271
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The C64 screen
-  .label SCREEN = $400
   // One of the bytes used for addition
   .const a = 'a'
+  // The C64 screen
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/test-keyboard-space.asm b/src/test/ref/test-keyboard-space.asm
index 16d28890b..6a6a2ca89 100644
--- a/src/test/ref/test-keyboard-space.asm
+++ b/src/test/ref/test-keyboard-space.asm
@@ -3,15 +3,15 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
   .const KEY_SPACE = $3c
-  .label RASTER = $d012
-  .label BGCOL = $d021
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const GREEN = 5
   .const BLUE = 6
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BGCOL = $d021
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
 main: {
     // keyboard_init()
     jsr keyboard_init
diff --git a/src/test/ref/test-keyboard-space.log b/src/test/ref/test-keyboard-space.log
index 89e778c36..90179888e 100644
--- a/src/test/ref/test-keyboard-space.log
+++ b/src/test/ref/test-keyboard-space.log
@@ -541,15 +541,15 @@ Target platform is c64basic / MOS6502X
 .pc = $80d "Program"
   // Global Constants & labels
   .const KEY_SPACE = $3c
-  .label RASTER = $d012
-  .label BGCOL = $d021
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const GREEN = 5
   .const BLUE = 6
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BGCOL = $d021
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -734,15 +734,15 @@ ASSEMBLER BEFORE OPTIMIZATION
 .pc = $80d "Program"
   // Global Constants & labels
   .const KEY_SPACE = $3c
-  .label RASTER = $d012
-  .label BGCOL = $d021
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const GREEN = 5
   .const BLUE = 6
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BGCOL = $d021
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1047,15 +1047,15 @@ Score: 1141
 .pc = $80d "Program"
   // Global Constants & labels
   .const KEY_SPACE = $3c
-  .label RASTER = $d012
-  .label BGCOL = $d021
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const GREEN = 5
   .const BLUE = 6
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  .label BGCOL = $d021
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/test-keyboard.asm b/src/test/ref/test-keyboard.asm
index 997b10fb6..6ae5ccb86 100644
--- a/src/test/ref/test-keyboard.asm
+++ b/src/test/ref/test-keyboard.asm
@@ -52,12 +52,12 @@
   .const KEY_2 = $3b
   .const KEY_SPACE = $3c
   .const KEY_Q = $3e
-  .label RASTER = $d012
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
 main: {
     .label sc = 2
     .label screen = 5
diff --git a/src/test/ref/test-keyboard.log b/src/test/ref/test-keyboard.log
index 5956665f2..4d5bc5e64 100644
--- a/src/test/ref/test-keyboard.log
+++ b/src/test/ref/test-keyboard.log
@@ -1194,12 +1194,12 @@ Target platform is c64basic / MOS6502X
   .const KEY_2 = $3b
   .const KEY_SPACE = $3c
   .const KEY_Q = $3e
-  .label RASTER = $d012
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1773,12 +1773,12 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const KEY_2 = $3b
   .const KEY_SPACE = $3c
   .const KEY_Q = $3e
-  .label RASTER = $d012
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -2538,12 +2538,12 @@ Score: 57707
   .const KEY_2 = $3b
   .const KEY_SPACE = $3c
   .const KEY_Q = $3e
-  .label RASTER = $d012
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B_DDR = 3
   .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1
+  .label RASTER = $d012
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/tetris-npe.asm b/src/test/ref/tetris-npe.asm
index cbf0e6ab1..34802e7ca 100644
--- a/src/test/ref/tetris-npe.asm
+++ b/src/test/ref/tetris-npe.asm
@@ -2,9 +2,9 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
+  .const RATE = $32
   .label RASTER = $d012
   .label SCREEN = $400
-  .const RATE = $32
 main: {
     ldx #0
     ldy #RATE
diff --git a/src/test/ref/tetris-npe.log b/src/test/ref/tetris-npe.log
index 9ad0b0884..a21b5ed36 100644
--- a/src/test/ref/tetris-npe.log
+++ b/src/test/ref/tetris-npe.log
@@ -226,9 +226,9 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const RATE = $32
   .label RASTER = $d012
   .label SCREEN = $400
-  .const RATE = $32
   .label counter = 2
   .label ypos = 3
   // @begin
@@ -322,9 +322,9 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const RATE = $32
   .label RASTER = $d012
   .label SCREEN = $400
-  .const RATE = $32
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -453,9 +453,9 @@ Score: 10110
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
+  .const RATE = $32
   .label RASTER = $d012
   .label SCREEN = $400
-  .const RATE = $32
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/tod-1.asm b/src/test/ref/tod-1.asm
index c64e861d2..7121cbbf9 100644
--- a/src/test/ref/tod-1.asm
+++ b/src/test/ref/tod-1.asm
@@ -2,18 +2,12 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  // The text screen address
-  .label CONIO_SCREEN_TEXT = $400
-  // The color screen address
-  .label CONIO_SCREEN_COLORS = $d800
   // The screen width
   .const CONIO_WIDTH = $28
   // The screen height
   .const CONIO_HEIGHT = $19
   // The default text color
   .const CONIO_TEXTCOLOR_DEFAULT = $e
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
   .const OFFSET_STRUCT_TIME_OF_DAY_HOURS = 3
@@ -23,6 +17,12 @@
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_MIN = $a
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
+  // The text screen address
+  .label CONIO_SCREEN_TEXT = $400
+  // The color screen address
+  .label CONIO_SCREEN_COLORS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // The current cursor y-position
   .label conio_cursor_y = 4
   // The current cursor address
diff --git a/src/test/ref/tod-1.log b/src/test/ref/tod-1.log
index 55444722c..0e0a6b9f0 100644
--- a/src/test/ref/tod-1.log
+++ b/src/test/ref/tod-1.log
@@ -1839,18 +1839,12 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The text screen address
-  .label CONIO_SCREEN_TEXT = $400
-  // The color screen address
-  .label CONIO_SCREEN_COLORS = $d800
   // The screen width
   .const CONIO_WIDTH = $28
   // The screen height
   .const CONIO_HEIGHT = $19
   // The default text color
   .const CONIO_TEXTCOLOR_DEFAULT = $e
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
   .const OFFSET_STRUCT_TIME_OF_DAY_HOURS = 3
@@ -1860,6 +1854,12 @@ Target platform is c64basic / MOS6502X
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_MIN = $a
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
+  // The text screen address
+  .label CONIO_SCREEN_TEXT = $400
+  // The color screen address
+  .label CONIO_SCREEN_COLORS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // The current cursor y-position
   .label conio_cursor_y = 5
   // The current cursor address
@@ -2605,18 +2605,12 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The text screen address
-  .label CONIO_SCREEN_TEXT = $400
-  // The color screen address
-  .label CONIO_SCREEN_COLORS = $d800
   // The screen width
   .const CONIO_WIDTH = $28
   // The screen height
   .const CONIO_HEIGHT = $19
   // The default text color
   .const CONIO_TEXTCOLOR_DEFAULT = $e
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
   .const OFFSET_STRUCT_TIME_OF_DAY_HOURS = 3
@@ -2626,6 +2620,12 @@ ASSEMBLER BEFORE OPTIMIZATION
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_MIN = $a
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
+  // The text screen address
+  .label CONIO_SCREEN_TEXT = $400
+  // The color screen address
+  .label CONIO_SCREEN_COLORS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // The current cursor y-position
   .label conio_cursor_y = 4
   // The current cursor address
@@ -3433,18 +3433,12 @@ Score: 5331
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The text screen address
-  .label CONIO_SCREEN_TEXT = $400
-  // The color screen address
-  .label CONIO_SCREEN_COLORS = $d800
   // The screen width
   .const CONIO_WIDTH = $28
   // The screen height
   .const CONIO_HEIGHT = $19
   // The default text color
   .const CONIO_TEXTCOLOR_DEFAULT = $e
-  // The CIA#1: keyboard matrix, joystick #1/#2
-  .label CIA1 = $dc00
   .const OFFSET_STRUCT_TIME_OF_DAY_SEC = 1
   .const OFFSET_STRUCT_TIME_OF_DAY_MIN = 2
   .const OFFSET_STRUCT_TIME_OF_DAY_HOURS = 3
@@ -3454,6 +3448,12 @@ Score: 5331
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_MIN = $a
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_SEC = 9
   .const OFFSET_STRUCT_MOS6526_CIA_TOD_10THS = 8
+  // The text screen address
+  .label CONIO_SCREEN_TEXT = $400
+  // The color screen address
+  .label CONIO_SCREEN_COLORS = $d800
+  // The CIA#1: keyboard matrix, joystick #1/#2
+  .label CIA1 = $dc00
   // The current cursor y-position
   .label conio_cursor_y = 4
   // The current cursor address
diff --git a/src/test/ref/tod018-problem.asm b/src/test/ref/tod018-problem.asm
index 6ea5a3a17..3e2e63990 100644
--- a/src/test/ref/tod018-problem.asm
+++ b/src/test/ref/tod018-problem.asm
@@ -3,9 +3,9 @@
 :BasicUpstart(main)
 .pc = $80d "Program"
 main: {
+    .const d018val = >screen&$3fff
     .label D018 = $d018
     .label screen = $400
-    .const d018val = >screen&$3fff
     // *D018 = d018val
     lda #d018val
     sta D018
diff --git a/src/test/ref/tod018-problem.log b/src/test/ref/tod018-problem.log
index 4f11aee44..67e84eebf 100644
--- a/src/test/ref/tod018-problem.log
+++ b/src/test/ref/tod018-problem.log
@@ -103,9 +103,9 @@ __bend_from___b1:
 __bend:
   // main
 main: {
+    .const d018val = >screen&$3fff
     .label D018 = $d018
     .label screen = $400
-    .const d018val = >screen&$3fff
     // [4] *((const nomodify byte*) main::D018) ← (const byte) main::d018val -- _deref_pbuc1=vbuc2 
     lda #d018val
     sta D018
@@ -151,9 +151,9 @@ __bend_from___b1:
 __bend:
   // main
 main: {
+    .const d018val = >screen&$3fff
     .label D018 = $d018
     .label screen = $400
-    .const d018val = >screen&$3fff
     // [4] *((const nomodify byte*) main::D018) ← (const byte) main::d018val -- _deref_pbuc1=vbuc2 
     lda #d018val
     sta D018
@@ -213,9 +213,9 @@ Score: 12
   // @end
   // main
 main: {
+    .const d018val = >screen&$3fff
     .label D018 = $d018
     .label screen = $400
-    .const d018val = >screen&$3fff
     // *D018 = d018val
     // [4] *((const nomodify byte*) main::D018) ← (const byte) main::d018val -- _deref_pbuc1=vbuc2 
     lda #d018val
diff --git a/src/test/ref/toupper-1.asm b/src/test/ref/toupper-1.asm
index 7899903f3..047f100eb 100644
--- a/src/test/ref/toupper-1.asm
+++ b/src/test/ref/toupper-1.asm
@@ -2,16 +2,16 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  // The text screen address
-  .label CONIO_SCREEN_TEXT = $400
-  // The color screen address
-  .label CONIO_SCREEN_COLORS = $d800
   // The screen width
   .const CONIO_WIDTH = $28
   // The screen height
   .const CONIO_HEIGHT = $19
   // The default text color
   .const CONIO_TEXTCOLOR_DEFAULT = $e
+  // The text screen address
+  .label CONIO_SCREEN_TEXT = $400
+  // The color screen address
+  .label CONIO_SCREEN_COLORS = $d800
   // The current cursor x-position
   .label conio_cursor_x = 7
   // The current cursor y-position
diff --git a/src/test/ref/toupper-1.log b/src/test/ref/toupper-1.log
index a7c2077ad..4cf5551fb 100644
--- a/src/test/ref/toupper-1.log
+++ b/src/test/ref/toupper-1.log
@@ -1453,16 +1453,16 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The text screen address
-  .label CONIO_SCREEN_TEXT = $400
-  // The color screen address
-  .label CONIO_SCREEN_COLORS = $d800
   // The screen width
   .const CONIO_WIDTH = $28
   // The screen height
   .const CONIO_HEIGHT = $19
   // The default text color
   .const CONIO_TEXTCOLOR_DEFAULT = $e
+  // The text screen address
+  .label CONIO_SCREEN_TEXT = $400
+  // The color screen address
+  .label CONIO_SCREEN_COLORS = $d800
   // The current cursor x-position
   .label conio_cursor_x = $a
   // The current cursor y-position
@@ -2042,16 +2042,16 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The text screen address
-  .label CONIO_SCREEN_TEXT = $400
-  // The color screen address
-  .label CONIO_SCREEN_COLORS = $d800
   // The screen width
   .const CONIO_WIDTH = $28
   // The screen height
   .const CONIO_HEIGHT = $19
   // The default text color
   .const CONIO_TEXTCOLOR_DEFAULT = $e
+  // The text screen address
+  .label CONIO_SCREEN_TEXT = $400
+  // The color screen address
+  .label CONIO_SCREEN_COLORS = $d800
   // The current cursor x-position
   .label conio_cursor_x = 7
   // The current cursor y-position
@@ -2730,16 +2730,16 @@ Score: 4337
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  // The text screen address
-  .label CONIO_SCREEN_TEXT = $400
-  // The color screen address
-  .label CONIO_SCREEN_COLORS = $d800
   // The screen width
   .const CONIO_WIDTH = $28
   // The screen height
   .const CONIO_HEIGHT = $19
   // The default text color
   .const CONIO_TEXTCOLOR_DEFAULT = $e
+  // The text screen address
+  .label CONIO_SCREEN_TEXT = $400
+  // The color screen address
+  .label CONIO_SCREEN_COLORS = $d800
   // The current cursor x-position
   .label conio_cursor_x = 7
   // The current cursor y-position
diff --git a/src/test/ref/true-inline-words.asm b/src/test/ref/true-inline-words.asm
index 654fda1ee..439207231 100644
--- a/src/test/ref/true-inline-words.asm
+++ b/src/test/ref/true-inline-words.asm
@@ -4,11 +4,11 @@
 main: {
     // constant byte array
     .const b = 4
+    .const w = b*$100
+    .const w2 = 1*$100+1+w
     // Test the result
     .label pos = $501
     .label bgcol = $d021
-    .const w = b*$100
-    .const w2 = 1*$100+1+w
     // constant inline words inside expression
     .label sc = w2
     // *sc = bs[1]
diff --git a/src/test/ref/true-inline-words.log b/src/test/ref/true-inline-words.log
index b899597b6..f7664550e 100644
--- a/src/test/ref/true-inline-words.log
+++ b/src/test/ref/true-inline-words.log
@@ -218,11 +218,11 @@ __bend:
 main: {
     // constant byte array
     .const b = 4
+    .const w = b*$100
+    .const w2 = 1*$100+1+w
     // Test the result
     .label pos = $501
     .label bgcol = $d021
-    .const w = b*$100
-    .const w2 = 1*$100+1+w
     // constant inline words inside expression
     .label sc = w2
     // [4] *((const byte*) main::sc#0) ← *((const byte*) main::bs+(byte) 1) -- _deref_pbuc1=_deref_pbuc2 
@@ -292,11 +292,11 @@ __bend:
 main: {
     // constant byte array
     .const b = 4
+    .const w = b*$100
+    .const w2 = 1*$100+1+w
     // Test the result
     .label pos = $501
     .label bgcol = $d021
-    .const w = b*$100
-    .const w2 = 1*$100+1+w
     // constant inline words inside expression
     .label sc = w2
     // [4] *((const byte*) main::sc#0) ← *((const byte*) main::bs+(byte) 1) -- _deref_pbuc1=_deref_pbuc2 
@@ -390,11 +390,11 @@ Score: 40
 main: {
     // constant byte array
     .const b = 4
+    .const w = b*$100
+    .const w2 = 1*$100+1+w
     // Test the result
     .label pos = $501
     .label bgcol = $d021
-    .const w = b*$100
-    .const w2 = 1*$100+1+w
     // constant inline words inside expression
     .label sc = w2
     // *sc = bs[1]
diff --git a/src/test/ref/typedef-1.asm b/src/test/ref/typedef-1.asm
index 6aa448311..4d47999ef 100644
--- a/src/test/ref/typedef-1.asm
+++ b/src/test/ref/typedef-1.asm
@@ -3,9 +3,9 @@
 .pc = $80d "Program"
   .const OFFSET_STRUCT_POINTDEF_Y = 1
 main: {
-    .label SCREEN = $400
     .const p_x = 4
     .const p_y = 7
+    .label SCREEN = $400
     // *SCREEN = p
     lda #p_x
     sta SCREEN
diff --git a/src/test/ref/typedef-1.log b/src/test/ref/typedef-1.log
index 24027fb22..6ddb87940 100644
--- a/src/test/ref/typedef-1.log
+++ b/src/test/ref/typedef-1.log
@@ -132,9 +132,9 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = 4
     .const p_y = 7
+    .label SCREEN = $400
     // [4] *((byte*)(const struct PointDef*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
     sta SCREEN
@@ -186,9 +186,9 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = 4
     .const p_y = 7
+    .label SCREEN = $400
     // [4] *((byte*)(const struct PointDef*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
     sta SCREEN
@@ -254,9 +254,9 @@ Score: 18
   // @end
   // main
 main: {
-    .label SCREEN = $400
     .const p_x = 4
     .const p_y = 7
+    .label SCREEN = $400
     // *SCREEN = p
     // [4] *((byte*)(const struct PointDef*) main::SCREEN) ← (const byte) main::p_x -- _deref_pbuc1=vbuc2 
     lda #p_x
diff --git a/src/test/ref/typedef-4.asm b/src/test/ref/typedef-4.asm
index 58b65591e..7b6dc3f59 100644
--- a/src/test/ref/typedef-4.asm
+++ b/src/test/ref/typedef-4.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const c = 'c'
+  .label SCREEN = $400
   .label v = 2
 __bbegin:
   // v = 'v'
diff --git a/src/test/ref/typedef-4.log b/src/test/ref/typedef-4.log
index ba671dacd..0e8124cfa 100644
--- a/src/test/ref/typedef-4.log
+++ b/src/test/ref/typedef-4.log
@@ -96,8 +96,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const c = 'c'
+  .label SCREEN = $400
   .label v = 2
   // @begin
 __bbegin:
@@ -155,8 +155,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const c = 'c'
+  .label SCREEN = $400
   .label v = 2
   // @begin
 __bbegin:
@@ -229,8 +229,8 @@ Score: 36
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const c = 'c'
+  .label SCREEN = $400
   .label v = 2
   // @begin
 __bbegin:
diff --git a/src/test/ref/typeid-plus-bytes.asm b/src/test/ref/typeid-plus-bytes.asm
index 8576e8085..6a362e348 100644
--- a/src/test/ref/typeid-plus-bytes.asm
+++ b/src/test/ref/typeid-plus-bytes.asm
@@ -2,10 +2,10 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
-  .label SSCREEN = $400
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
+  .label SCREEN = $400
+  .label SSCREEN = $400
 main: {
     // testUnsigned()
     jsr testUnsigned
diff --git a/src/test/ref/typeid-plus-bytes.log b/src/test/ref/typeid-plus-bytes.log
index 8d5bd4252..28c4bb793 100644
--- a/src/test/ref/typeid-plus-bytes.log
+++ b/src/test/ref/typeid-plus-bytes.log
@@ -1111,10 +1111,10 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
-  .label SSCREEN = $400
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
+  .label SCREEN = $400
+  .label SSCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1482,10 +1482,10 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
-  .label SSCREEN = $400
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
+  .label SCREEN = $400
+  .label SSCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1849,10 +1849,10 @@ Score: 340
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
-  .label SSCREEN = $400
   .const TYPEID_BYTE = 1
   .const TYPEID_SIGNED_BYTE = 2
+  .label SCREEN = $400
+  .label SSCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/unary-plus.asm b/src/test/ref/unary-plus.asm
index 8e1dc60f7..6dee0b0cf 100644
--- a/src/test/ref/unary-plus.asm
+++ b/src/test/ref/unary-plus.asm
@@ -4,10 +4,10 @@
 .pc = $80d "Program"
   .const SIZEOF_SIGNED_WORD = 2
 main: {
-    .label SCREEN = $400
-    .label SCREEN2 = $428
     .const i = 3
     .const j = 3
+    .label SCREEN = $400
+    .label SCREEN2 = $428
     // SCREEN[0] = i
     lda #i
     sta SCREEN
diff --git a/src/test/ref/unary-plus.log b/src/test/ref/unary-plus.log
index bcee436df..47daf7e6a 100644
--- a/src/test/ref/unary-plus.log
+++ b/src/test/ref/unary-plus.log
@@ -152,10 +152,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
-    .label SCREEN2 = $428
     .const i = 3
     .const j = 3
+    .label SCREEN = $400
+    .label SCREEN2 = $428
     // [4] *((const byte*) main::SCREEN) ← (const byte) main::i -- _deref_pbuc1=vbuc2 
     lda #i
     sta SCREEN
@@ -218,10 +218,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
-    .label SCREEN = $400
-    .label SCREEN2 = $428
     .const i = 3
     .const j = 3
+    .label SCREEN = $400
+    .label SCREEN2 = $428
     // [4] *((const byte*) main::SCREEN) ← (const byte) main::i -- _deref_pbuc1=vbuc2 
     lda #i
     sta SCREEN
@@ -297,10 +297,10 @@ Score: 42
   // @end
   // main
 main: {
-    .label SCREEN = $400
-    .label SCREEN2 = $428
     .const i = 3
     .const j = 3
+    .label SCREEN = $400
+    .label SCREEN2 = $428
     // SCREEN[0] = i
     // [4] *((const byte*) main::SCREEN) ← (const byte) main::i -- _deref_pbuc1=vbuc2 
     lda #i
diff --git a/src/test/ref/uninitialized.asm b/src/test/ref/uninitialized.asm
index e2e907c6e..9c38cd461 100644
--- a/src/test/ref/uninitialized.asm
+++ b/src/test/ref/uninitialized.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
   .const b = 0
+  .label SCREEN = $400
 main: {
     // SCREEN[0] = b
     lda #b
diff --git a/src/test/ref/uninitialized.log b/src/test/ref/uninitialized.log
index 8573d424c..d3520a669 100644
--- a/src/test/ref/uninitialized.log
+++ b/src/test/ref/uninitialized.log
@@ -145,8 +145,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const b = 0
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -208,8 +208,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const b = 0
+  .label SCREEN = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -292,8 +292,8 @@ Score: 30
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
   .const b = 0
+  .label SCREEN = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/var-forward-problem.asm b/src/test/ref/var-forward-problem.asm
index ae1a3b3c6..7aef3442b 100644
--- a/src/test/ref/var-forward-problem.asm
+++ b/src/test/ref/var-forward-problem.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label screen = $400
   .const b = 'a'
+  .label screen = $400
 main: {
     // *screen = b
     lda #b
diff --git a/src/test/ref/var-forward-problem.log b/src/test/ref/var-forward-problem.log
index b9638a7e1..3fc7ddc43 100644
--- a/src/test/ref/var-forward-problem.log
+++ b/src/test/ref/var-forward-problem.log
@@ -80,8 +80,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen = $400
   .const b = 'a'
+  .label screen = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -127,8 +127,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen = $400
   .const b = 'a'
+  .label screen = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -195,8 +195,8 @@ Score: 12
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen = $400
   .const b = 'a'
+  .label screen = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/var-forward-problem2.asm b/src/test/ref/var-forward-problem2.asm
index ae1a3b3c6..7aef3442b 100644
--- a/src/test/ref/var-forward-problem2.asm
+++ b/src/test/ref/var-forward-problem2.asm
@@ -2,8 +2,8 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label screen = $400
   .const b = 'a'
+  .label screen = $400
 main: {
     // *screen = b
     lda #b
diff --git a/src/test/ref/var-forward-problem2.log b/src/test/ref/var-forward-problem2.log
index 1591e46b0..31e0c616c 100644
--- a/src/test/ref/var-forward-problem2.log
+++ b/src/test/ref/var-forward-problem2.log
@@ -126,8 +126,8 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen = $400
   .const b = 'a'
+  .label screen = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -173,8 +173,8 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen = $400
   .const b = 'a'
+  .label screen = $400
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -243,8 +243,8 @@ Score: 12
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label screen = $400
   .const b = 'a'
+  .label screen = $400
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/voronoi.asm b/src/test/ref/voronoi.asm
index 1fab2cf4a..3b30f5be8 100644
--- a/src/test/ref/voronoi.asm
+++ b/src/test/ref/voronoi.asm
@@ -2,11 +2,11 @@
 .pc = $801 "Basic"
 :BasicUpstart(main)
 .pc = $80d "Program"
-  .label SCREEN = $400
-  .label COLORS = $d800
   .const FILL = $e6
   // The total number of voronoi points
   .const numpoints = 6
+  .label SCREEN = $400
+  .label COLORS = $d800
 main: {
     // initscreen()
     jsr initscreen
diff --git a/src/test/ref/voronoi.log b/src/test/ref/voronoi.log
index 89fe661ee..8e4718cd3 100644
--- a/src/test/ref/voronoi.log
+++ b/src/test/ref/voronoi.log
@@ -1251,11 +1251,11 @@ Target platform is c64basic / MOS6502X
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
-  .label COLORS = $d800
   .const FILL = $e6
   // The total number of voronoi points
   .const numpoints = 6
+  .label SCREEN = $400
+  .label COLORS = $d800
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -1883,11 +1883,11 @@ ASSEMBLER BEFORE OPTIMIZATION
 :BasicUpstart(__bbegin)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
-  .label COLORS = $d800
   .const FILL = $e6
   // The total number of voronoi points
   .const numpoints = 6
+  .label SCREEN = $400
+  .label COLORS = $d800
   // @begin
 __bbegin:
   // [1] phi from @begin to @1 [phi:@begin->@1]
@@ -2570,11 +2570,11 @@ Score: 1568618
 :BasicUpstart(main)
 .pc = $80d "Program"
   // Global Constants & labels
-  .label SCREEN = $400
-  .label COLORS = $d800
   .const FILL = $e6
   // The total number of voronoi points
   .const numpoints = 6
+  .label SCREEN = $400
+  .label COLORS = $d800
   // @begin
   // [1] phi from @begin to @1 [phi:@begin->@1]
   // @1
diff --git a/src/test/ref/word-pointer-math-1.asm b/src/test/ref/word-pointer-math-1.asm
index 5dd0e35e0..f03cc766e 100644
--- a/src/test/ref/word-pointer-math-1.asm
+++ b/src/test/ref/word-pointer-math-1.asm
@@ -4,10 +4,10 @@
 .pc = $80d "Program"
   .const SIZEOF_WORD = 2
 main: {
+    .const wd = (w2-w1)/SIZEOF_WORD
     .label SCREEN = $400
     .label w1 = $1000
     .label w2 = $1140
-    .const wd = (w2-w1)/SIZEOF_WORD
     // *SCREEN = wd
     lda #<wd
     sta SCREEN
diff --git a/src/test/ref/word-pointer-math-1.log b/src/test/ref/word-pointer-math-1.log
index a93e84ea1..b935a0952 100644
--- a/src/test/ref/word-pointer-math-1.log
+++ b/src/test/ref/word-pointer-math-1.log
@@ -119,10 +119,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
+    .const wd = (w2-w1)/SIZEOF_WORD
     .label SCREEN = $400
     .label w1 = $1000
     .label w2 = $1140
-    .const wd = (w2-w1)/SIZEOF_WORD
     // [4] *((const nomodify word*) main::SCREEN) ← (const word) main::wd#0 -- _deref_pwuc1=vwuc2 
     lda #<wd
     sta SCREEN
@@ -171,10 +171,10 @@ __bend_from___b1:
 __bend:
   // main
 main: {
+    .const wd = (w2-w1)/SIZEOF_WORD
     .label SCREEN = $400
     .label w1 = $1000
     .label w2 = $1140
-    .const wd = (w2-w1)/SIZEOF_WORD
     // [4] *((const nomodify word*) main::SCREEN) ← (const word) main::wd#0 -- _deref_pwuc1=vwuc2 
     lda #<wd
     sta SCREEN
@@ -240,10 +240,10 @@ Score: 18
   // @end
   // main
 main: {
+    .const wd = (w2-w1)/SIZEOF_WORD
     .label SCREEN = $400
     .label w1 = $1000
     .label w2 = $1140
-    .const wd = (w2-w1)/SIZEOF_WORD
     // *SCREEN = wd
     // [4] *((const nomodify word*) main::SCREEN) ← (const word) main::wd#0 -- _deref_pwuc1=vwuc2 
     lda #<wd