mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-29 03:56:15 +00:00
580 lines
19 KiB
Plaintext
580 lines
19 KiB
Plaintext
Resolved forward reference irq to interrupt(HARDWARE_ALL)(void()) irq()
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
to:@1
|
|
|
|
(void()) main()
|
|
main: scope:[main] from @1
|
|
asm { sei }
|
|
*((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK
|
|
*((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO
|
|
*((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR
|
|
*((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (number) $80
|
|
*((const nomodify byte*) RASTER) ← (number) 0
|
|
*((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER
|
|
*((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_ALL)(void()) 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
|
|
*((const nomodify byte*) FGCOL) ← ++ *((const nomodify byte*) FGCOL)
|
|
to:main::@1
|
|
main::@return: scope:[main] from main::@1
|
|
return
|
|
to:@return
|
|
|
|
interrupt(HARDWARE_ALL)(void()) irq()
|
|
irq: scope:[irq] from
|
|
*((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE
|
|
*((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK
|
|
*((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER
|
|
to:irq::@return
|
|
irq::@return: scope:[irq] from irq
|
|
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*) BG_COLOR = (byte*)(number) $d020
|
|
(const nomodify byte) BLACK = (byte) 0
|
|
(const nomodify byte*) CIA1_INTERRUPT = (byte*)(number) $dc0d
|
|
(const nomodify byte) CIA_INTERRUPT_CLEAR = (byte) $7f
|
|
(const nomodify byte*) FGCOL = (byte*)(number) $d021
|
|
(const nomodify void()**) HARDWARE_IRQ = (void()**)(number) $fffe
|
|
(const nomodify byte*) IRQ_ENABLE = (byte*)(number) $d01a
|
|
(const nomodify byte) IRQ_RASTER = (byte) 1
|
|
(const nomodify byte*) IRQ_STATUS = (byte*)(number) $d019
|
|
(const nomodify byte*) PROCPORT = (byte*)(number) 1
|
|
(const nomodify byte*) PROCPORT_DDR = (byte*)(number) 0
|
|
(const nomodify byte) PROCPORT_DDR_MEMORY_MASK = (byte) 7
|
|
(const nomodify byte) PROCPORT_RAM_IO = (byte) $35
|
|
(const nomodify byte*) RASTER = (byte*)(number) $d012
|
|
(const nomodify byte*) VIC_CONTROL = (byte*)(number) $d011
|
|
(const nomodify byte) WHITE = (byte) 1
|
|
interrupt(HARDWARE_ALL)(void()) irq()
|
|
(label) irq::@return
|
|
(void()) main()
|
|
(label) main::@1
|
|
(label) main::@2
|
|
(label) main::@return
|
|
|
|
Adding number conversion cast (unumber) $80 in *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (number) $80
|
|
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) RASTER) ← (number) 0
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Inlining cast *((const nomodify byte*) RASTER) ← (unumber)(number) 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
|
|
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
|
|
Adding NOP phi() at start of main::@1
|
|
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
|
|
Culled Empty Block (label) main::@1
|
|
Renumbering block main::@2 to main::@1
|
|
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
|
|
asm { sei }
|
|
[5] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK
|
|
[6] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO
|
|
[7] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR
|
|
[8] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80
|
|
[9] *((const nomodify byte*) RASTER) ← (byte) 0
|
|
[10] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER
|
|
[11] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_ALL)(void()) irq()
|
|
asm { cli }
|
|
to:main::@1
|
|
main::@1: scope:[main] from main main::@1
|
|
[13] *((const nomodify byte*) FGCOL) ← ++ *((const nomodify byte*) FGCOL)
|
|
to:main::@1
|
|
|
|
interrupt(HARDWARE_ALL)(void()) irq()
|
|
irq: scope:[irq] from
|
|
[14] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE
|
|
[15] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK
|
|
[16] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER
|
|
to:irq::@return
|
|
irq::@return: scope:[irq] from irq
|
|
[17] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
interrupt(HARDWARE_ALL)(void()) irq()
|
|
(void()) main()
|
|
|
|
Initial phi equivalence classes
|
|
Complete equivalence classes
|
|
|
|
INITIAL ASM
|
|
Target platform is c64basic / MOS6502X
|
|
// File Comments
|
|
// A minimal working raster IRQ
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
: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
|
|
.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
|
|
// @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
|
|
// RAM in $A000, $E000 CHAR ROM in $D000
|
|
main: {
|
|
// asm { sei }
|
|
sei
|
|
// [5] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK -- _deref_pbuc1=vbuc2
|
|
// Disable kernal & basic
|
|
lda #PROCPORT_DDR_MEMORY_MASK
|
|
sta PROCPORT_DDR
|
|
// [6] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO -- _deref_pbuc1=vbuc2
|
|
lda #PROCPORT_RAM_IO
|
|
sta PROCPORT
|
|
// [7] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// [8] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VIC_CONTROL
|
|
sta VIC_CONTROL
|
|
// [9] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
|
lda #0
|
|
sta RASTER
|
|
// [10] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// [11] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_ALL)(void()) irq() -- _deref_pptc1=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] *((const nomodify byte*) FGCOL) ← ++ *((const nomodify byte*) FGCOL) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc FGCOL
|
|
jmp __b1
|
|
}
|
|
// irq
|
|
// Interrupt Routine
|
|
irq: {
|
|
// entry interrupt(HARDWARE_ALL)
|
|
sta rega+1
|
|
stx regx+1
|
|
sty regy+1
|
|
// [14] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
|
lda #WHITE
|
|
sta BG_COLOR
|
|
// [15] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
|
lda #BLACK
|
|
sta BG_COLOR
|
|
// [16] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
jmp __breturn
|
|
// irq::@return
|
|
__breturn:
|
|
// [17] return - exit interrupt(HARDWARE_ALL)
|
|
rega:
|
|
lda #00
|
|
regx:
|
|
ldx #00
|
|
regy:
|
|
ldy #00
|
|
rti
|
|
}
|
|
// File Data
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [5] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [6] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [7] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [8] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [9] *((const nomodify byte*) RASTER) ← (byte) 0 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [10] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [11] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_ALL)(void()) irq() [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [14] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [15] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [16] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER [ ] ( [ ] { } ) always clobbers reg byte a
|
|
Statement [17] return [ ] ( [ ] { } ) always clobbers reg byte a reg byte x reg byte y
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [main]
|
|
Uplift Scope [irq]
|
|
Uplift Scope []
|
|
|
|
Uplifting [main] best 314 combination
|
|
Uplifting [irq] best 314 combination
|
|
Uplifting [] best 314 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// A minimal working raster IRQ
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
: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
|
|
.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
|
|
// @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
|
|
// RAM in $A000, $E000 CHAR ROM in $D000
|
|
main: {
|
|
// asm { sei }
|
|
sei
|
|
// [5] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK -- _deref_pbuc1=vbuc2
|
|
// Disable kernal & basic
|
|
lda #PROCPORT_DDR_MEMORY_MASK
|
|
sta PROCPORT_DDR
|
|
// [6] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO -- _deref_pbuc1=vbuc2
|
|
lda #PROCPORT_RAM_IO
|
|
sta PROCPORT
|
|
// [7] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// [8] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VIC_CONTROL
|
|
sta VIC_CONTROL
|
|
// [9] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
|
lda #0
|
|
sta RASTER
|
|
// [10] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// [11] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_ALL)(void()) irq() -- _deref_pptc1=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] *((const nomodify byte*) FGCOL) ← ++ *((const nomodify byte*) FGCOL) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc FGCOL
|
|
jmp __b1
|
|
}
|
|
// irq
|
|
// Interrupt Routine
|
|
irq: {
|
|
// entry interrupt(HARDWARE_ALL)
|
|
sta rega+1
|
|
stx regx+1
|
|
sty regy+1
|
|
// [14] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
|
lda #WHITE
|
|
sta BG_COLOR
|
|
// [15] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
|
lda #BLACK
|
|
sta BG_COLOR
|
|
// [16] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
jmp __breturn
|
|
// irq::@return
|
|
__breturn:
|
|
// [17] return - exit interrupt(HARDWARE_ALL)
|
|
rega:
|
|
lda #00
|
|
regx:
|
|
ldx #00
|
|
regy:
|
|
ldy #00
|
|
rti
|
|
}
|
|
// File Data
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __bend
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction __b1_from___bbegin:
|
|
Removing instruction __b1:
|
|
Removing instruction __bend_from___b1:
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
Removing instruction __bbegin:
|
|
Removing instruction __bend:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
Removing instruction jsr main
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
|
|
FINAL SYMBOL TABLE
|
|
(label) @1
|
|
(label) @begin
|
|
(label) @end
|
|
(const nomodify byte*) BG_COLOR = (byte*) 53280
|
|
(const nomodify byte) BLACK = (byte) 0
|
|
(const nomodify byte*) CIA1_INTERRUPT = (byte*) 56333
|
|
(const nomodify byte) CIA_INTERRUPT_CLEAR = (byte) $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 = (byte) 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 = (byte) 7
|
|
(const nomodify byte) PROCPORT_RAM_IO = (byte) $35
|
|
(const nomodify byte*) RASTER = (byte*) 53266
|
|
(const nomodify byte*) VIC_CONTROL = (byte*) 53265
|
|
(const nomodify byte) WHITE = (byte) 1
|
|
interrupt(HARDWARE_ALL)(void()) irq()
|
|
(label) irq::@return
|
|
(void()) main()
|
|
(label) main::@1
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 296
|
|
|
|
// File Comments
|
|
// A minimal working raster IRQ
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
: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
|
|
.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
|
|
// @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
|
|
// RAM in $A000, $E000 CHAR ROM in $D000
|
|
main: {
|
|
// asm
|
|
// asm { sei }
|
|
sei
|
|
// *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK
|
|
// [5] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK -- _deref_pbuc1=vbuc2
|
|
// Disable kernal & basic
|
|
lda #PROCPORT_DDR_MEMORY_MASK
|
|
sta PROCPORT_DDR
|
|
// *PROCPORT = PROCPORT_RAM_IO
|
|
// [6] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO -- _deref_pbuc1=vbuc2
|
|
lda #PROCPORT_RAM_IO
|
|
sta PROCPORT
|
|
// *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
|
|
// [7] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
|
|
// Disable CIA 1 Timer IRQ
|
|
lda #CIA_INTERRUPT_CLEAR
|
|
sta CIA1_INTERRUPT
|
|
// *VIC_CONTROL |=$80
|
|
// [8] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
|
// Set raster line to $100
|
|
lda #$80
|
|
ora VIC_CONTROL
|
|
sta VIC_CONTROL
|
|
// *RASTER = $00
|
|
// [9] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
|
lda #0
|
|
sta RASTER
|
|
// *IRQ_ENABLE = IRQ_RASTER
|
|
// [10] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Enable Raster Interrupt
|
|
lda #IRQ_RASTER
|
|
sta IRQ_ENABLE
|
|
// *HARDWARE_IRQ = &irq
|
|
// [11] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_ALL)(void()) irq() -- _deref_pptc1=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] *((const nomodify byte*) FGCOL) ← ++ *((const nomodify byte*) FGCOL) -- _deref_pbuc1=_inc__deref_pbuc1
|
|
inc FGCOL
|
|
jmp __b1
|
|
}
|
|
// irq
|
|
// Interrupt Routine
|
|
irq: {
|
|
// entry interrupt(HARDWARE_ALL)
|
|
sta rega+1
|
|
stx regx+1
|
|
sty regy+1
|
|
// *BG_COLOR = WHITE
|
|
// [14] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
|
lda #WHITE
|
|
sta BG_COLOR
|
|
// *BG_COLOR = BLACK
|
|
// [15] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
|
lda #BLACK
|
|
sta BG_COLOR
|
|
// *IRQ_STATUS = IRQ_RASTER
|
|
// [16] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2
|
|
// Acknowledge the IRQ
|
|
lda #IRQ_RASTER
|
|
sta IRQ_STATUS
|
|
// irq::@return
|
|
// }
|
|
// [17] return - exit interrupt(HARDWARE_ALL)
|
|
rega:
|
|
lda #00
|
|
regx:
|
|
ldx #00
|
|
regy:
|
|
ldy #00
|
|
rti
|
|
}
|
|
// File Data
|
|
|