Resolved forward reference far to far CONTROL FLOW GRAPH SSA void main() main: scope:[main] from __start asm { inx lda#$12 phw#$1234 lda$12 lda$12,x ldx$12,y lda($12,x) lda($12),y ora($12),z lda($12,sp),y lda$1234 lda$1234,x lda$1234,y beqlbl1 lbeqfar bbr0$12,lbl2 lbl1: jmp($1234) lbl2: jmp($1234,x) lbl3: lda(($12)),z ldq(($12)) } to:main::@return main::@return: scope:[main] from main 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 void __start() const byte* far[] = { $60 } void main() 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 Finalized unsigned number type (word) $2000 Successful SSA optimization PassNFinalizeNumberTypeConversions CALL GRAPH Created 0 initial phi equivalence classes Coalesced down to 0 phi equivalence classes FINAL CONTROL FLOW GRAPH void main() main: scope:[main] from asm { inx lda#$12 phw#$1234 lda$12 lda$12,x ldx$12,y lda($12,x) lda($12),y ora($12),z lda($12,sp),y lda$1234 lda$1234,x lda$1234,y beqlbl1 lbeqfar bbr0$12,lbl2 lbl1: jmp($1234) lbl2: jmp($1234,x) lbl3: lda(($12)),z ldq(($12)) } to:main::@return main::@return: scope:[main] from main [1] return to:@return VARIABLE REGISTER WEIGHTS void main() Initial phi equivalence classes Complete equivalence classes REGISTER UPLIFT POTENTIAL REGISTERS Statement asm { inx lda#$12 phw#$1234 lda$12 lda$12,x ldx$12,y lda($12,x) lda($12),y ora($12),z lda($12,sp),y lda$1234 lda$1234,x lda$1234,y beqlbl1 lbeqfar bbr0$12,lbl2 lbl1: jmp($1234) lbl2: jmp($1234,x) lbl3: lda(($12)),z ldq(($12)) } always clobbers reg byte a reg byte x reg byte y reg byte z REGISTER UPLIFT SCOPES Uplift Scope [main] Uplift Scope [] Uplifting [main] best 106 combination Uplifting [] best 106 combination ASSEMBLER BEFORE OPTIMIZATION // File Comments // Tests the different ASM addressing modes // Upstart .cpu _45gs02 // Commodore 64 PRG executable file .file [name="cpu-45gs02-addressing-modes.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 .segment Code // main main: { // asm { inx lda#$12 phw#$1234 lda$12 lda$12,x ldx$12,y lda($12,x) lda($12),y ora($12),z lda($12,sp),y lda$1234 lda$1234,x lda$1234,y beqlbl1 lbeqfar bbr0$12,lbl2 lbl1: jmp($1234) lbl2: jmp($1234,x) lbl3: lda(($12)),z ldq(($12)) } inx lda #$12 phw #$1234 lda.z $12 lda.z $12,x ldx.z $12,y lda ($12,x) lda ($12),y ora.z ($12),z lda.z ($12,sp),y lda $1234 lda $1234,x lda $1234,y beq lbl1 lbeq far bbr0 $12,lbl2 lbl1: jmp ($1234) lbl2: jmp ($1234,x) lbl3: lda.z (($12)),z ldq.z (($12)) jmp __breturn // main::@return __breturn: // [1] return rts } // File Data .segment Data .pc = $2000 "far" far: .byte $60 ASSEMBLER OPTIMIZATIONS Removing instruction jmp __breturn Succesful ASM optimization Pass5NextJumpElimination Removing instruction __breturn: Succesful ASM optimization Pass5UnusedLabelElimination FINAL SYMBOL TABLE const byte* far[] = { $60 } void main() FINAL ASSEMBLER Score: 103 // File Comments // Tests the different ASM addressing modes // Upstart .cpu _45gs02 // Commodore 64 PRG executable file .file [name="cpu-45gs02-addressing-modes.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 .segment Code // main main: { // asm // asm { inx lda#$12 phw#$1234 lda$12 lda$12,x ldx$12,y lda($12,x) lda($12),y ora($12),z lda($12,sp),y lda$1234 lda$1234,x lda$1234,y beqlbl1 lbeqfar bbr0$12,lbl2 lbl1: jmp($1234) lbl2: jmp($1234,x) lbl3: lda(($12)),z ldq(($12)) } inx lda #$12 phw #$1234 lda.z $12 lda.z $12,x ldx.z $12,y lda ($12,x) lda ($12),y ora.z ($12),z lda.z ($12,sp),y lda $1234 lda $1234,x lda $1234,y beq lbl1 lbeq far bbr0 $12,lbl2 lbl1: jmp ($1234) lbl2: jmp ($1234,x) lbl3: lda.z (($12)),z ldq.z (($12)) // main::@return // } // [1] return rts } // File Data .segment Data .pc = $2000 "far" far: .byte $60