Resolved forward reference irq to interrupt(HARDWARE_CLOBBER)(void()) irq()
Identified constant variable (byte*) BORDERCOL
Identified constant variable (byte*) RASTER
Identified constant variable (byte) DARK_GREY
Identified constant variable (byte) BLACK

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) BORDERCOL#0 ← ((byte*)) (number) $d020
  (byte*) RASTER#0 ← ((byte*)) (number) $d012
  (byte) DARK_GREY#0 ← (number) $b
  (byte) BLACK#0 ← (number) 0
  (void()**) KERNEL_IRQ#0 ← ((void()**)) (number) $314
  to:@1
main: scope:[main]  from @2
  (void()*~) main::$0 ← & interrupt(HARDWARE_CLOBBER)(void()) irq()
  *((void()**) KERNEL_IRQ#0) ← (void()*~) main::$0
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
@1: scope:[]  from @begin
  (byte) irq_raster_next#0 ← (number) 0
  to:@2
irq: scope:[irq]  from
  (byte) irq_raster_next#3 ← phi( @2/(byte) irq_raster_next#5 )
  *((byte*) BORDERCOL#0) ← (byte) DARK_GREY#0
  (byte) irq_raster_next#1 ← (byte) irq_raster_next#3 + (number) $15
  (byte) irq::raster_next#0 ← (byte) irq_raster_next#1
  (number~) irq::$0 ← (byte) irq::raster_next#0 & (number) 7
  (bool~) irq::$1 ← (number~) irq::$0 == (number) 0
  (bool~) irq::$2 ← ! (bool~) irq::$1
  if((bool~) irq::$2) goto irq::@1
  to:irq::@2
irq::@1: scope:[irq]  from irq irq::@2
  (byte) irq_raster_next#6 ← phi( irq/(byte) irq_raster_next#1 irq::@2/(byte) irq_raster_next#7 )
  (byte) irq::raster_next#2 ← phi( irq/(byte) irq::raster_next#0 irq::@2/(byte) irq::raster_next#1 )
  *((byte*) RASTER#0) ← (byte) irq::raster_next#2
  *((byte*) BORDERCOL#0) ← (byte) BLACK#0
  to:irq::@return
irq::@2: scope:[irq]  from irq
  (byte) irq_raster_next#7 ← phi( irq/(byte) irq_raster_next#1 )
  (byte) irq::raster_next#3 ← phi( irq/(byte) irq::raster_next#0 )
  (byte) irq::raster_next#1 ← (byte) irq::raster_next#3 - (number) 1
  to:irq::@1
irq::@return: scope:[irq]  from irq::@1
  (byte) irq_raster_next#4 ← phi( irq::@1/(byte) irq_raster_next#6 )
  (byte) irq_raster_next#2 ← (byte) irq_raster_next#4
  return 
  to:@return
@2: scope:[]  from @1
  (byte) irq_raster_next#5 ← phi( @1/(byte) irq_raster_next#0 )
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @3
(label) @begin
(label) @end
(byte) BLACK
(byte) BLACK#0
(byte*) BORDERCOL
(byte*) BORDERCOL#0
(byte) DARK_GREY
(byte) DARK_GREY#0
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
(byte*) RASTER
(byte*) RASTER#0
interrupt(HARDWARE_CLOBBER)(void()) irq()
(number~) irq::$0
(bool~) irq::$1
(bool~) irq::$2
(label) irq::@1
(label) irq::@2
(label) irq::@return
(byte) irq::raster_next
(byte) irq::raster_next#0
(byte) irq::raster_next#1
(byte) irq::raster_next#2
(byte) irq::raster_next#3
(byte) irq_raster_next
(byte) irq_raster_next#0
(byte) irq_raster_next#1
(byte) irq_raster_next#2
(byte) irq_raster_next#3
(byte) irq_raster_next#4
(byte) irq_raster_next#5
(byte) irq_raster_next#6
(byte) irq_raster_next#7
(void()) main()
(void()*~) main::$0
(label) main::@return

Adding number conversion cast (unumber) $b in (byte) DARK_GREY#0 ← (number) $b
Adding number conversion cast (unumber) 0 in (byte) BLACK#0 ← (number) 0
Adding number conversion cast (unumber) 0 in (byte) irq_raster_next#0 ← (number) 0
Adding number conversion cast (unumber) $15 in (byte) irq_raster_next#1 ← (byte) irq_raster_next#3 + (number) $15
Adding number conversion cast (unumber) 7 in (number~) irq::$0 ← (byte) irq::raster_next#0 & (number) 7
Adding number conversion cast (unumber) irq::$0 in (number~) irq::$0 ← (byte) irq::raster_next#0 & (unumber)(number) 7
Adding number conversion cast (unumber) 0 in (bool~) irq::$1 ← (unumber~) irq::$0 == (number) 0
Adding number conversion cast (unumber) 1 in (byte) irq::raster_next#1 ← (byte) irq::raster_next#3 - (number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) BORDERCOL#0 ← (byte*)(number) $d020
Inlining cast (byte*) RASTER#0 ← (byte*)(number) $d012
Inlining cast (byte) DARK_GREY#0 ← (unumber)(number) $b
Inlining cast (byte) BLACK#0 ← (unumber)(number) 0
Inlining cast (void()**) KERNEL_IRQ#0 ← (void()**)(number) $314
Inlining cast (byte) irq_raster_next#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53266
Simplifying constant integer cast $b
Simplifying constant integer cast 0
Simplifying constant pointer cast (void()**) 788
Simplifying constant integer cast 0
Simplifying constant integer cast $15
Simplifying constant integer cast 7
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $b
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $15
Finalized unsigned number type (byte) 7
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) irq::$0 ← (byte) irq::raster_next#0 & (byte) 7
Inversing boolean not [15] (bool~) irq::$2 ← (byte~) irq::$0 != (byte) 0 from [14] (bool~) irq::$1 ← (byte~) irq::$0 == (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) irq::raster_next#0 = (byte) irq::raster_next#3 
Alias (byte) irq_raster_next#1 = (byte) irq_raster_next#7 
Alias (byte) irq_raster_next#2 = (byte) irq_raster_next#4 (byte) irq_raster_next#6 
Alias (byte) irq_raster_next#0 = (byte) irq_raster_next#5 
Successful SSA optimization Pass2AliasElimination
Alias (byte) irq_raster_next#1 = (byte) irq_raster_next#2 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) irq_raster_next#3 (byte) irq_raster_next#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) irq::$2 [16] if((byte~) irq::$0!=(byte) 0) goto irq::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [5] (void()*~) main::$0 ← & interrupt(HARDWARE_CLOBBER)(void()) irq()
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) BORDERCOL#0 = (byte*) 53280
Constant (const byte*) RASTER#0 = (byte*) 53266
Constant (const byte) DARK_GREY#0 = $b
Constant (const byte) BLACK#0 = 0
Constant (const void()**) KERNEL_IRQ#0 = (void()**) 788
Constant (const void()*) main::$0 = &irq
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::$0 = &interrupt(HARDWARE_CLOBBER)(void()) irq()
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting irq::@3(between irq and irq::@1)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:3 

Created 1 initial phi equivalence classes
Coalesced [14] irq::raster_next#5 ← irq::raster_next#1
Coalesced [19] irq::raster_next#4 ← irq::raster_next#0
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @3
Culled Empty Block (label) irq::@3
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] (byte) irq_raster_next#0 ← (byte) 0
  to:@2
@2: scope:[]  from @1
  [2] phi()
  [3] call main 
  to:@end
@end: scope:[]  from @2
  [4] phi()
main: scope:[main]  from @2
  [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq()
  to:main::@return
main::@return: scope:[main]  from main
  [6] return 
  to:@return
irq: scope:[irq]  from
  [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0
  [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte) $15
  [9] (byte) irq::raster_next#0 ← (byte) irq_raster_next#1
  [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte) 7
  [11] if((byte~) irq::$0!=(byte) 0) goto irq::@1
  to:irq::@2
irq::@2: scope:[irq]  from irq
  [12] (byte) irq::raster_next#1 ← (byte) irq::raster_next#0 - (byte) 1
  to:irq::@1
irq::@1: scope:[irq]  from irq irq::@2
  [13] (byte) irq::raster_next#2 ← phi( irq/(byte) irq::raster_next#0 irq::@2/(byte) irq::raster_next#1 )
  [14] *((const byte*) RASTER#0) ← (byte) irq::raster_next#2
  [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0
  to:irq::@return
irq::@return: scope:[irq]  from irq::@1
  [16] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) BLACK
(byte*) BORDERCOL
(byte) DARK_GREY
(void()**) KERNEL_IRQ
(byte*) RASTER
interrupt(HARDWARE_CLOBBER)(void()) irq()
(byte~) irq::$0 4.0
(byte) irq::raster_next
(byte) irq::raster_next#0 2.6666666666666665
(byte) irq::raster_next#1 4.0
(byte) irq::raster_next#2 6.0
(byte) irq_raster_next
(byte) irq_raster_next#0 4.0
(byte) irq_raster_next#1 4.0
(void()) main()

Initial phi equivalence classes
[ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
Coalescing volatile variable equivalence classes [ irq_raster_next#0 ] and [ irq_raster_next#1 ]
Added variable irq::$0 to zero page equivalence class [ irq::$0 ]
Complete equivalence classes
[ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
[ irq_raster_next#0 irq_raster_next#1 ]
[ irq::$0 ]
Allocated zp ZP_BYTE:2 [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
Allocated zp ZP_BYTE:3 [ irq_raster_next#0 irq_raster_next#1 ]
Allocated zp ZP_BYTE:4 [ irq::$0 ]

INITIAL ASM
  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label BORDERCOL = $d020
  .label RASTER = $d012
  .const DARK_GREY = $b
  .const BLACK = 0
  .label KERNEL_IRQ = $314
  .label irq_raster_next = 3
  // @begin
bbegin:
  jmp b1
  // @1
b1:
  // [1] (byte) irq_raster_next#0 ← (byte) 0 -- vbuz1=vbuc1 
  lda #0
  sta irq_raster_next
  // [2] phi from @1 to @2 [phi:@1->@2]
b2_from_b1:
  jmp b2
  // @2
b2:
  // [3] call main 
  jsr main
  // [4] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
  // @end
bend:
  // main
main: {
    // [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    jmp breturn
    // main::@return
  breturn:
    // [6] return 
    rts
}
  // irq
irq: {
    .label _0 = 4
    .label raster_next = 2
    // entry interrupt(HARDWARE_CLOBBER)
    sta rega+1
    stx regx+1
    sty regy+1
    // [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 -- _deref_pbuc1=vbuc2 
    lda #DARK_GREY
    sta BORDERCOL
    // [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte) $15 -- vbuz1=vbuz1_plus_vbuc1 
    lax irq_raster_next
    axs #-[$15]
    stx irq_raster_next
    // [9] (byte) irq::raster_next#0 ← (byte) irq_raster_next#1 -- vbuz1=vbuz2 
    // Setup next interrupt
    lda irq_raster_next
    sta raster_next
    // [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte) 7 -- vbuz1=vbuz2_band_vbuc1 
    lda #7
    and raster_next
    sta _0
    // [11] if((byte~) irq::$0!=(byte) 0) goto irq::@1 -- vbuz1_neq_0_then_la1 
    lda _0
    cmp #0
    bne b1_from_irq
    jmp b2
    // irq::@2
  b2:
    // [12] (byte) irq::raster_next#1 ← (byte) irq::raster_next#0 - (byte) 1 -- vbuz1=vbuz1_minus_1 
    dec raster_next
    // [13] phi from irq irq::@2 to irq::@1 [phi:irq/irq::@2->irq::@1]
  b1_from_irq:
  b1_from_b2:
    // [13] phi (byte) irq::raster_next#2 = (byte) irq::raster_next#0 [phi:irq/irq::@2->irq::@1#0] -- register_copy 
    jmp b1
    // irq::@1
  b1:
    // [14] *((const byte*) RASTER#0) ← (byte) irq::raster_next#2 -- _deref_pbuc1=vbuz1 
    lda raster_next
    sta RASTER
    // [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BORDERCOL
    jmp breturn
    // irq::@return
  breturn:
    // [16] return  - exit interrupt(HARDWARE_CLOBBER)
  rega:
    lda #00
  regx:
    ldx #00
  regy:
    ldy #00
    rti
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] (byte) irq_raster_next#0 ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() [ ] ( main:3 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 [ irq_raster_next#0 ] (  [ irq_raster_next#0 ] ) always clobbers reg byte a 
Statement [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte) $15 [ irq_raster_next#1 ] (  [ irq_raster_next#1 ] ) always clobbers reg byte a reg byte x 
Statement [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [16] return  [ ] (  [ ] ) always clobbers reg byte a reg byte x reg byte y 
Potential registers zp ZP_BYTE:2 [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ irq_raster_next#0 irq_raster_next#1 ] : zp ZP_BYTE:3 , 
Potential registers zp ZP_BYTE:4 [ irq::$0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [irq] 12.67: zp ZP_BYTE:2 [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ] 4: zp ZP_BYTE:4 [ irq::$0 ] 
Uplift Scope [] 8: zp ZP_BYTE:3 [ irq_raster_next#0 irq_raster_next#1 ] 
Uplift Scope [main] 

Uplifting [irq] best 246 combination reg byte x [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ] reg byte a [ irq::$0 ] 
Uplifting [] best 246 combination zp ZP_BYTE:3 [ irq_raster_next#0 irq_raster_next#1 ] 
Uplifting [main] best 246 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ irq_raster_next#0 irq_raster_next#1 ]
Uplifting [] best 246 combination zp ZP_BYTE:3 [ irq_raster_next#0 irq_raster_next#1 ] 
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ irq_raster_next#0 irq_raster_next#1 ]
Interrupt procedure irq clobbers AXCNZ
Removing interrupt register storage sty regy+1 in SEG16 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regy: in SEG30 [16] return  - exit interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage ldy #00 in SEG30 [16] return  - exit interrupt(HARDWARE_CLOBBER)

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label BORDERCOL = $d020
  .label RASTER = $d012
  .const DARK_GREY = $b
  .const BLACK = 0
  .label KERNEL_IRQ = $314
  .label irq_raster_next = 2
  // @begin
bbegin:
  jmp b1
  // @1
b1:
  // [1] (byte) irq_raster_next#0 ← (byte) 0 -- vbuz1=vbuc1 
  lda #0
  sta irq_raster_next
  // [2] phi from @1 to @2 [phi:@1->@2]
b2_from_b1:
  jmp b2
  // @2
b2:
  // [3] call main 
  jsr main
  // [4] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
  // @end
bend:
  // main
main: {
    // [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    jmp breturn
    // main::@return
  breturn:
    // [6] return 
    rts
}
  // irq
irq: {
    // entry interrupt(HARDWARE_CLOBBER)
    sta rega+1
    stx regx+1
    // [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 -- _deref_pbuc1=vbuc2 
    lda #DARK_GREY
    sta BORDERCOL
    // [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte) $15 -- vbuz1=vbuz1_plus_vbuc1 
    lax irq_raster_next
    axs #-[$15]
    stx irq_raster_next
    // [9] (byte) irq::raster_next#0 ← (byte) irq_raster_next#1 -- vbuxx=vbuz1 
    // Setup next interrupt
    ldx irq_raster_next
    // [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte) 7 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #7
    // [11] if((byte~) irq::$0!=(byte) 0) goto irq::@1 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne b1_from_irq
    jmp b2
    // irq::@2
  b2:
    // [12] (byte) irq::raster_next#1 ← (byte) irq::raster_next#0 - (byte) 1 -- vbuxx=vbuxx_minus_1 
    dex
    // [13] phi from irq irq::@2 to irq::@1 [phi:irq/irq::@2->irq::@1]
  b1_from_irq:
  b1_from_b2:
    // [13] phi (byte) irq::raster_next#2 = (byte) irq::raster_next#0 [phi:irq/irq::@2->irq::@1#0] -- register_copy 
    jmp b1
    // irq::@1
  b1:
    // [14] *((const byte*) RASTER#0) ← (byte) irq::raster_next#2 -- _deref_pbuc1=vbuxx 
    stx RASTER
    // [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BORDERCOL
    jmp breturn
    // irq::@return
  breturn:
    // [16] return  - exit interrupt(HARDWARE_CLOBBER)
  rega:
    lda #00
  regx:
    ldx #00
    rti
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp breturn
Removing instruction jmp b2
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction ldx irq_raster_next
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label b1_from_irq with b1
Removing instruction b1:
Removing instruction b2_from_b1:
Removing instruction bend_from_b2:
Removing instruction b1_from_irq:
Removing instruction b1_from_b2:
Removing instruction breturn:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b2:
Removing instruction bend:
Removing instruction breturn:
Removing instruction b2:
Succesful ASM optimization Pass5UnusedLabelElimination
Adding RTS to root block 
Succesful ASM optimization Pass5AddMainRts

FINAL SYMBOL TABLE
(label) @1
(label) @2
(label) @begin
(label) @end
(byte) BLACK
(const byte) BLACK#0 BLACK = (byte) 0
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = (byte*) 53280
(byte) DARK_GREY
(const byte) DARK_GREY#0 DARK_GREY = (byte) $b
(void()**) KERNEL_IRQ
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = (void()**) 788
(byte*) RASTER
(const byte*) RASTER#0 RASTER = (byte*) 53266
interrupt(HARDWARE_CLOBBER)(void()) irq()
(byte~) irq::$0 reg byte a 4.0
(label) irq::@1
(label) irq::@2
(label) irq::@return
(byte) irq::raster_next
(byte) irq::raster_next#0 reg byte x 2.6666666666666665
(byte) irq::raster_next#1 reg byte x 4.0
(byte) irq::raster_next#2 reg byte x 6.0
(byte) irq_raster_next
(byte) irq_raster_next#0 irq_raster_next zp ZP_BYTE:2 4.0
(byte) irq_raster_next#1 irq_raster_next zp ZP_BYTE:2 4.0
(void()) main()
(label) main::@return

reg byte x [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
zp ZP_BYTE:2 [ irq_raster_next#0 irq_raster_next#1 ]
reg byte a [ irq::$0 ]


FINAL ASSEMBLER
Score: 159

  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label BORDERCOL = $d020
  .label RASTER = $d012
  .const DARK_GREY = $b
  .const BLACK = 0
  .label KERNEL_IRQ = $314
  .label irq_raster_next = 2
  // @begin
bbegin:
  // @1
  // irq_raster_next = 0
  // [1] (byte) irq_raster_next#0 ← (byte) 0 -- vbuz1=vbuc1 
  lda #0
  sta irq_raster_next
  // [2] phi from @1 to @2 [phi:@1->@2]
  // @2
  // [3] call main 
  jsr main
  rts
  // [4] phi from @2 to @end [phi:@2->@end]
  // @end
  // main
main: {
    // *KERNEL_IRQ = &irq
    // [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    // main::@return
    // }
    // [6] return 
    rts
}
  // irq
irq: {
    // entry interrupt(HARDWARE_CLOBBER)
    sta rega+1
    stx regx+1
    // *BORDERCOL = DARK_GREY
    // [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 -- _deref_pbuc1=vbuc2 
    lda #DARK_GREY
    sta BORDERCOL
    // irq_raster_next += 21
    // [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte) $15 -- vbuz1=vbuz1_plus_vbuc1 
    lax irq_raster_next
    axs #-[$15]
    stx irq_raster_next
    // raster_next = irq_raster_next
    // [9] (byte) irq::raster_next#0 ← (byte) irq_raster_next#1 -- vbuxx=vbuz1 
  // Setup next interrupt
    // raster_next&7
    // [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte) 7 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #7
    // if((raster_next&7)==0)
    // [11] if((byte~) irq::$0!=(byte) 0) goto irq::@1 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne b1
    // irq::@2
    // raster_next -=1
    // [12] (byte) irq::raster_next#1 ← (byte) irq::raster_next#0 - (byte) 1 -- vbuxx=vbuxx_minus_1 
    dex
    // [13] phi from irq irq::@2 to irq::@1 [phi:irq/irq::@2->irq::@1]
    // [13] phi (byte) irq::raster_next#2 = (byte) irq::raster_next#0 [phi:irq/irq::@2->irq::@1#0] -- register_copy 
    // irq::@1
  b1:
    // *RASTER = raster_next
    // [14] *((const byte*) RASTER#0) ← (byte) irq::raster_next#2 -- _deref_pbuc1=vbuxx 
    stx RASTER
    // *BORDERCOL = BLACK
    // [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BORDERCOL
    // irq::@return
    // }
    // [16] return  - exit interrupt(HARDWARE_CLOBBER)
  rega:
    lda #00
  regx:
    ldx #00
    rti
}
  // File Data

