Resolved forward reference irq to __interrupt(rom_min_c64) void irq()

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  *KERNEL_IRQ = &irq
  to:main::@1
main::@1: scope:[main]  from main main::@2
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  *FGCOL = ++ *FGCOL
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return

__interrupt(rom_min_c64) void irq()
irq: scope:[irq]  from
  *BG_COLOR = ++ *BG_COLOR
  asm { lda$dc0d  }
  to:irq::@return
irq::@return: scope:[irq]  from irq
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  call main
  to:__start::@1
__start::@1: scope:[__start]  from __start
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  return 
  to:@return

SYMBOL TABLE SSA
__constant char * const BG_COLOR = (char *)$d020
__constant char * const FGCOL = (char *)$d021
__constant void (** const KERNEL_IRQ)() = (void (**)())$314
void __start()
__interrupt(rom_min_c64) void irq()
void main()

Simplifying constant pointer cast (void (**)()) 788
Simplifying constant pointer cast (char *) 53280
Simplifying constant pointer cast (char *) 53281
Successful SSA optimization PassNCastSimplification
if() condition always true - replacing block destination [1] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding NOP phi() at start of main::@1
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label main::@1
Renumbering block main::@2 to main::@1

FINAL CONTROL FLOW GRAPH

__interrupt(rom_min_c64) void irq()
irq: scope:[irq]  from
  [0] *BG_COLOR = ++ *BG_COLOR
  asm { lda$dc0d  }
  to:irq::@return
irq::@return: scope:[irq]  from irq
  [2] return 
  to:@return

void main()
main: scope:[main]  from
  [3] *KERNEL_IRQ = &irq
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [4] *FGCOL = ++ *FGCOL
  to:main::@1


VARIABLE REGISTER WEIGHTS
__interrupt(rom_min_c64) void irq()
void main()

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement asm { lda$dc0d  } always clobbers reg byte a 
Statement [3] *KERNEL_IRQ = &irq [ ] (  [ ] { }  ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [irq] 
Uplift Scope [] 

Uplifting [main] best 148 combination 
Uplifting [irq] best 148 combination 
Uplifting [] best 148 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="test-interrupt.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .label KERNEL_IRQ = $314
  .label BG_COLOR = $d020
  .label FGCOL = $d021
.segment Code
  // irq
irq: {
    // interrupt(isr_rom_min_c64_entry) -- isr_rom_min_c64_entry 
    // [0] *BG_COLOR = ++ *BG_COLOR -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BG_COLOR
    // asm { lda$dc0d  }
    lda $dc0d
    jmp __breturn
    // irq::@return
  __breturn:
    // [2] return 
    // interrupt(isr_rom_min_c64_exit) -- isr_rom_min_c64_exit 
    jmp $ea81
}
  // main
main: {
    // [3] *KERNEL_IRQ = &irq -- _deref_qprc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    jmp __b1
    // main::@1
  __b1:
    // [4] *FGCOL = ++ *FGCOL -- _deref_pbuc1=_inc__deref_pbuc1 
    inc FGCOL
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const BG_COLOR = (char *) 53280
__constant char * const FGCOL = (char *) 53281
__constant void (** const KERNEL_IRQ)() = (void (**)()) 788
__interrupt(rom_min_c64) void irq()
void main()



FINAL ASSEMBLER
Score: 142

  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="test-interrupt.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .label KERNEL_IRQ = $314
  .label BG_COLOR = $d020
  .label FGCOL = $d021
.segment Code
  // irq
irq: {
    // interrupt(isr_rom_min_c64_entry) -- isr_rom_min_c64_entry 
    // (*BG_COLOR)++;
    // [0] *BG_COLOR = ++ *BG_COLOR -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BG_COLOR
    // asm
    // asm { lda$dc0d  }
    lda $dc0d
    // irq::@return
    // }
    // [2] return 
    // interrupt(isr_rom_min_c64_exit) -- isr_rom_min_c64_exit 
    jmp $ea81
}
  // main
main: {
    // *KERNEL_IRQ = &irq
    // [3] *KERNEL_IRQ = &irq -- _deref_qprc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    // main::@1
  __b1:
    // (*FGCOL)++;
    // [4] *FGCOL = ++ *FGCOL -- _deref_pbuc1=_inc__deref_pbuc1 
    inc FGCOL
    jmp __b1
}
  // File Data

