mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-06-09 18:29:36 +00:00
423 lines
12 KiB
Plaintext
423 lines
12 KiB
Plaintext
Resolved forward reference irq to __interrupt(hardware_all) void irq()
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
void main()
|
|
main: scope:[main] from __start
|
|
asm { sei }
|
|
*PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK
|
|
*PROCPORT = PROCPORT_RAM_IO
|
|
*CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
|
|
*VICII_CONTROL = *VICII_CONTROL | $80
|
|
*RASTER = 0
|
|
*IRQ_ENABLE = IRQ_RASTER
|
|
*HARDWARE_IRQ = &irq
|
|
asm { cli }
|
|
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(hardware_all) void irq()
|
|
irq: scope:[irq] from
|
|
*BG_COLOR = WHITE
|
|
*BG_COLOR = BLACK
|
|
*IRQ_STATUS = IRQ_RASTER
|
|
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
|
|
const nomodify byte* BG_COLOR = (byte*)$d020
|
|
const nomodify byte BLACK = 0
|
|
const nomodify byte* CIA1_INTERRUPT = (byte*)$dc0d
|
|
const nomodify byte CIA_INTERRUPT_CLEAR = $7f
|
|
const nomodify byte* FGCOL = (byte*)$d021
|
|
const nomodify void()** HARDWARE_IRQ = (void()**)$fffe
|
|
const nomodify byte* IRQ_ENABLE = (byte*)$d01a
|
|
const nomodify byte IRQ_RASTER = 1
|
|
const nomodify byte* IRQ_STATUS = (byte*)$d019
|
|
const nomodify byte* PROCPORT = (byte*)1
|
|
const nomodify byte* PROCPORT_DDR = (byte*)0
|
|
const nomodify byte PROCPORT_DDR_MEMORY_MASK = 7
|
|
const nomodify byte PROCPORT_RAM_IO = $35
|
|
const nomodify byte* RASTER = (byte*)$d012
|
|
const nomodify byte* VICII_CONTROL = (byte*)$d011
|
|
const nomodify byte WHITE = 1
|
|
void __start()
|
|
__interrupt(hardware_all) void irq()
|
|
void main()
|
|
|
|
Adding number conversion cast (unumber) $80 in *VICII_CONTROL = *VICII_CONTROL | $80
|
|
Adding number conversion cast (unumber) 0 in *RASTER = 0
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Inlining cast *RASTER = (unumber)0
|
|
Successful SSA optimization Pass2InlineCast
|
|
Simplifying constant pointer cast (void()**) 65534
|
|
Simplifying constant pointer cast (byte*) 53266
|
|
Simplifying constant pointer cast (byte*) 53265
|
|
Simplifying constant pointer cast (byte*) 53273
|
|
Simplifying constant pointer cast (byte*) 53274
|
|
Simplifying constant pointer cast (byte*) 53280
|
|
Simplifying constant pointer cast (byte*) 53281
|
|
Simplifying constant pointer cast (byte*) 56333
|
|
Simplifying constant pointer cast (byte*) 0
|
|
Simplifying constant pointer cast (byte*) 1
|
|
Simplifying constant integer cast $80
|
|
Simplifying constant integer cast 0
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) $80
|
|
Finalized unsigned number type (byte) 0
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
if() condition always true - replacing block destination [9] 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(hardware_all) void irq()
|
|
irq: scope:[irq] from
|
|
[0] *BG_COLOR = WHITE
|
|
[1] *BG_COLOR = BLACK
|
|
[2] *IRQ_STATUS = IRQ_RASTER
|
|
to:irq::@return
|
|
irq::@return: scope:[irq] from irq
|
|
[3] return
|
|
to:@return
|
|
|
|
void main()
|
|
main: scope:[main] from
|
|
asm { sei }
|
|
[5] *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK
|
|
[6] *PROCPORT = PROCPORT_RAM_IO
|
|
[7] *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
|
|
[8] *VICII_CONTROL = *VICII_CONTROL | $80
|
|
[9] *RASTER = 0
|
|
[10] *IRQ_ENABLE = IRQ_RASTER
|
|
[11] *HARDWARE_IRQ = &irq
|
|
asm { cli }
|
|
to:main::@1
|
|
main::@1: scope:[main] from main main::@1
|
|
[13] *FGCOL = ++ *FGCOL
|
|
to:main::@1
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
__interrupt(hardware_all) void irq()
|
|
void main()
|
|
|
|
Initial phi equivalence classes
|
|
Complete equivalence classes
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [0] *BG_COLOR = WHITE [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [1] *BG_COLOR = BLACK [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [2] *IRQ_STATUS = IRQ_RASTER [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [3] return [ ] ( [ ] { } ) always clobbers reg byte a reg byte x reg byte y
|
|
Statement [5] *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [6] *PROCPORT = PROCPORT_RAM_IO [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [7] *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [8] *VICII_CONTROL = *VICII_CONTROL | $80 [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [9] *RASTER = 0 [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [10] *IRQ_ENABLE = IRQ_RASTER [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [11] *HARDWARE_IRQ = &irq [ ] ( [ ] { } ) always clobbers reg byte a
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [main]
|
|
Uplift Scope [irq]
|
|
Uplift Scope []
|
|
|
|
Uplifting [main] best 410 combination
|
|
Uplifting [irq] best 410 combination
|
|
Uplifting [] best 410 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// A minimal working raster IRQ
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="irq-hardware.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
|
|
.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 VICII_CONTROL = $d011
|
|
.label IRQ_STATUS = $d019
|
|
.label IRQ_ENABLE = $d01a
|
|
.label BG_COLOR = $d020
|
|
.label FGCOL = $d021
|
|
.label CIA1_INTERRUPT = $dc0d
|
|
// Processor port data direction register
|
|
.label PROCPORT_DDR = 0
|
|
// Processor Port Register controlling RAM/ROM configuration and the datasette
|
|
.label PROCPORT = 1
|
|
.segment Code
|
|
// irq
|
|
// Interrupt Routine
|
|
irq: {
|
|
// interrupt(isr_hardware_all_entry) -- isr_hardware_all_entry
|
|
sta rega+1
|
|
stx regx+1
|
|
sty regy+1
|
|
// [0] *BG_COLOR = WHITE -- _deref_pbuc1=vbuc2
|
|
lda #WHITE
|
|
sta BG_COLOR
|
|
// [1] *BG_COLOR = BLACK -- _deref_pbuc1=vbuc2
|
|
lda #BLACK
|
|
sta BG_COLOR
|
|
// [2] *IRQ_STATUS = IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
jmp __breturn
|
|
// irq::@return
|
|
__breturn:
|
|
// [3] return
|
|
// interrupt(isr_hardware_all_exit) -- isr_hardware_all_exit
|
|
rega:
|
|
lda #0
|
|
regx:
|
|
ldx #0
|
|
regy:
|
|
ldy #0
|
|
rti
|
|
}
|
|
// main
|
|
// RAM in $A000, $E000 CHAR ROM in $D000
|
|
main: {
|
|
// asm { sei }
|
|
sei
|
|
// [5] *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK -- _deref_pbuc1=vbuc2
|
|
// Disable kernal & basic
|
|
lda #PROCPORT_DDR_MEMORY_MASK
|
|
sta PROCPORT_DDR
|
|
// [6] *PROCPORT = PROCPORT_RAM_IO -- _deref_pbuc1=vbuc2
|
|
lda #PROCPORT_RAM_IO
|
|
sta PROCPORT
|
|
// [7] *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// [8] *VICII_CONTROL = *VICII_CONTROL | $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VICII_CONTROL
|
|
sta VICII_CONTROL
|
|
// [9] *RASTER = 0 -- _deref_pbuc1=vbuc2
|
|
lda #0
|
|
sta RASTER
|
|
// [10] *IRQ_ENABLE = IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// [11] *HARDWARE_IRQ = &irq -- _deref_qprc1=pprc2
|
|
// Set the IRQ routine
|
|
lda #<irq
|
|
sta HARDWARE_IRQ
|
|
lda #>irq
|
|
sta HARDWARE_IRQ+1
|
|
// asm { cli }
|
|
cli
|
|
jmp __b1
|
|
// main::@1
|
|
__b1:
|
|
// [13] *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 Pass5RedundantLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
const nomodify byte* BG_COLOR = (byte*) 53280
|
|
const nomodify byte BLACK = 0
|
|
const nomodify byte* CIA1_INTERRUPT = (byte*) 56333
|
|
const nomodify byte CIA_INTERRUPT_CLEAR = $7f
|
|
const nomodify byte* FGCOL = (byte*) 53281
|
|
const nomodify void()** HARDWARE_IRQ = (void()**) 65534
|
|
const nomodify byte* IRQ_ENABLE = (byte*) 53274
|
|
const nomodify byte IRQ_RASTER = 1
|
|
const nomodify byte* IRQ_STATUS = (byte*) 53273
|
|
const nomodify byte* PROCPORT = (byte*) 1
|
|
const nomodify byte* PROCPORT_DDR = (byte*) 0
|
|
const nomodify byte PROCPORT_DDR_MEMORY_MASK = 7
|
|
const nomodify byte PROCPORT_RAM_IO = $35
|
|
const nomodify byte* RASTER = (byte*) 53266
|
|
const nomodify byte* VICII_CONTROL = (byte*) 53265
|
|
const nomodify byte WHITE = 1
|
|
__interrupt(hardware_all) void irq()
|
|
void main()
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 404
|
|
|
|
// File Comments
|
|
// A minimal working raster IRQ
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="irq-hardware.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
|
|
.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 VICII_CONTROL = $d011
|
|
.label IRQ_STATUS = $d019
|
|
.label IRQ_ENABLE = $d01a
|
|
.label BG_COLOR = $d020
|
|
.label FGCOL = $d021
|
|
.label CIA1_INTERRUPT = $dc0d
|
|
// Processor port data direction register
|
|
.label PROCPORT_DDR = 0
|
|
// Processor Port Register controlling RAM/ROM configuration and the datasette
|
|
.label PROCPORT = 1
|
|
.segment Code
|
|
// irq
|
|
// Interrupt Routine
|
|
irq: {
|
|
// interrupt(isr_hardware_all_entry) -- isr_hardware_all_entry
|
|
sta rega+1
|
|
stx regx+1
|
|
sty regy+1
|
|
// *BG_COLOR = WHITE
|
|
// [0] *BG_COLOR = WHITE -- _deref_pbuc1=vbuc2
|
|
lda #WHITE
|
|
sta BG_COLOR
|
|
// *BG_COLOR = BLACK
|
|
// [1] *BG_COLOR = BLACK -- _deref_pbuc1=vbuc2
|
|
lda #BLACK
|
|
sta BG_COLOR
|
|
// *IRQ_STATUS = IRQ_RASTER
|
|
// [2] *IRQ_STATUS = IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
// irq::@return
|
|
// }
|
|
// [3] return
|
|
// interrupt(isr_hardware_all_exit) -- isr_hardware_all_exit
|
|
rega:
|
|
lda #0
|
|
regx:
|
|
ldx #0
|
|
regy:
|
|
ldy #0
|
|
rti
|
|
}
|
|
// main
|
|
// RAM in $A000, $E000 CHAR ROM in $D000
|
|
main: {
|
|
// asm
|
|
// asm { sei }
|
|
sei
|
|
// *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK
|
|
// [5] *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK -- _deref_pbuc1=vbuc2
|
|
// Disable kernal & basic
|
|
lda #PROCPORT_DDR_MEMORY_MASK
|
|
sta PROCPORT_DDR
|
|
// *PROCPORT = PROCPORT_RAM_IO
|
|
// [6] *PROCPORT = PROCPORT_RAM_IO -- _deref_pbuc1=vbuc2
|
|
lda #PROCPORT_RAM_IO
|
|
sta PROCPORT
|
|
// *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
|
|
// [7] *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// *VICII_CONTROL |=$80
|
|
// [8] *VICII_CONTROL = *VICII_CONTROL | $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VICII_CONTROL
|
|
sta VICII_CONTROL
|
|
// *RASTER = $00
|
|
// [9] *RASTER = 0 -- _deref_pbuc1=vbuc2
|
|
lda #0
|
|
sta RASTER
|
|
// *IRQ_ENABLE = IRQ_RASTER
|
|
// [10] *IRQ_ENABLE = IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// *HARDWARE_IRQ = &irq
|
|
// [11] *HARDWARE_IRQ = &irq -- _deref_qprc1=pprc2
|
|
// Set the IRQ routine
|
|
lda #<irq
|
|
sta HARDWARE_IRQ
|
|
lda #>irq
|
|
sta HARDWARE_IRQ+1
|
|
// asm
|
|
// asm { cli }
|
|
cli
|
|
// main::@1
|
|
__b1:
|
|
// (*FGCOL)++;
|
|
// [13] *FGCOL = ++ *FGCOL -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc FGCOL
|
|
jmp __b1
|
|
}
|
|
// File Data
|
|
|