1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-10-21 17:24:39 +00:00
kickc/src/test/ref/irq-raster.log

502 lines
16 KiB
Plaintext
Raw Normal View History

2018-08-10 18:32:45 +00:00
Resolved forward reference irq to interrupt(KERNEL_MIN)(void()) irq()
2018-08-05 22:37:40 +00:00
2018-08-22 22:24:32 +00:00
CONTROL FLOW GRAPH SSA
2018-08-05 22:37:40 +00:00
@begin: scope:[] from
(void()**) KERNEL_IRQ#0 ← ((void()**)) (word/signed word/dword/signed dword) 788
(byte*) RASTER#0 ← ((byte*)) (word/dword/signed dword) 53266
(byte*) VIC_CONTROL#0 ← ((byte*)) (word/dword/signed dword) 53265
(byte*) IRQ_STATUS#0 ← ((byte*)) (word/dword/signed dword) 53273
(byte*) IRQ_ENABLE#0 ← ((byte*)) (word/dword/signed dword) 53274
(byte) IRQ_RASTER#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
(byte) IRQ_COLLISION_BG#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
(byte) IRQ_COLLISION_SPRITE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
(byte) IRQ_LIGHTPEN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 8
2018-08-05 22:37:40 +00:00
(byte*) BGCOL#0 ← ((byte*)) (word/dword/signed dword) 53280
(byte) WHITE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
(byte) BLACK#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
(byte*) CIA1_INTERRUPT#0 ← ((byte*)) (word/dword/signed dword) 56333
(byte) CIA_INTERRUPT_CLEAR#0 ← (byte/signed byte/word/signed word/dword/signed dword) 127
to:@2
main: scope:[main] from @2
asm { sei }
*((byte*) CIA1_INTERRUPT#0) ← (byte) CIA_INTERRUPT_CLEAR#0
*((byte*) VIC_CONTROL#0) ← *((byte*) VIC_CONTROL#0) | (byte/word/signed word/dword/signed dword) 128
*((byte*) RASTER#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0
*((byte*) IRQ_ENABLE#0) ← (byte) IRQ_RASTER#0
2018-08-10 18:32:45 +00:00
(void()*~) main::$0 ← & interrupt(KERNEL_MIN)(void()) irq()
2018-08-05 22:37:40 +00:00
*((void()**) KERNEL_IRQ#0) ← (void()*~) main::$0
asm { cli }
to:main::@return
main::@return: scope:[main] from main
return
to:@return
irq: scope:[irq] from
*((byte*) BGCOL#0) ← (byte) WHITE#0
*((byte*) BGCOL#0) ← (byte) BLACK#0
*((byte*) IRQ_STATUS#0) ← (byte) IRQ_RASTER#0
to:irq::@return
irq::@return: scope:[irq] from irq
return
to:@return
@2: scope:[] from @begin
call main
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) BGCOL
(byte*) BGCOL#0
(byte) BLACK
(byte) BLACK#0
(byte*) CIA1_INTERRUPT
(byte*) CIA1_INTERRUPT#0
(byte) CIA_INTERRUPT_CLEAR
(byte) CIA_INTERRUPT_CLEAR#0
(byte) IRQ_COLLISION_BG
(byte) IRQ_COLLISION_BG#0
(byte) IRQ_COLLISION_SPRITE
(byte) IRQ_COLLISION_SPRITE#0
2018-08-05 22:37:40 +00:00
(byte*) IRQ_ENABLE
(byte*) IRQ_ENABLE#0
(byte) IRQ_LIGHTPEN
(byte) IRQ_LIGHTPEN#0
2018-08-05 22:37:40 +00:00
(byte) IRQ_RASTER
(byte) IRQ_RASTER#0
(byte*) IRQ_STATUS
(byte*) IRQ_STATUS#0
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
(byte*) RASTER
(byte*) RASTER#0
(byte*) VIC_CONTROL
(byte*) VIC_CONTROL#0
(byte) WHITE
(byte) WHITE#0
2018-08-10 18:32:45 +00:00
interrupt(KERNEL_MIN)(void()) irq()
2018-08-05 22:37:40 +00:00
(label) irq::@return
(void()) main()
(void()*~) main::$0
(label) main::@return
Culled Empty Block (label) @3
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2CullEmptyBlocks
2018-08-05 22:37:40 +00:00
Constant (const void()**) KERNEL_IRQ#0 = ((void()**))788
Constant (const byte*) RASTER#0 = ((byte*))53266
Constant (const byte*) VIC_CONTROL#0 = ((byte*))53265
Constant (const byte*) IRQ_STATUS#0 = ((byte*))53273
Constant (const byte*) IRQ_ENABLE#0 = ((byte*))53274
Constant (const byte) IRQ_RASTER#0 = 1
Constant (const byte) IRQ_COLLISION_BG#0 = 2
Constant (const byte) IRQ_COLLISION_SPRITE#0 = 4
Constant (const byte) IRQ_LIGHTPEN#0 = 8
2018-08-05 22:37:40 +00:00
Constant (const byte*) BGCOL#0 = ((byte*))53280
Constant (const byte) WHITE#0 = 1
Constant (const byte) BLACK#0 = 0
Constant (const byte*) CIA1_INTERRUPT#0 = ((byte*))56333
Constant (const byte) CIA_INTERRUPT_CLEAR#0 = 127
Constant (const void()*) main::$0 = &irq
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2ConstantIdentification
Successful SSA optimization PassNEliminateUnusedVars
2018-08-10 18:32:45 +00:00
Constant inlined main::$0 = &interrupt(KERNEL_MIN)(void()) irq()
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2ConstantInlining
2018-08-05 22:37:40 +00:00
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
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
2018-11-11 20:51:36 +00:00
[0] phi()
2018-08-05 22:37:40 +00:00
to:@2
@2: scope:[] from @begin
2018-11-11 20:51:36 +00:00
[1] phi()
[2] call main
2018-08-05 22:37:40 +00:00
to:@end
@end: scope:[] from @2
2018-11-11 20:51:36 +00:00
[3] phi()
2018-08-05 22:37:40 +00:00
main: scope:[main] from @2
asm { sei }
2018-11-11 20:51:36 +00:00
[5] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0
[6] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (byte/word/signed word/dword/signed dword) 128
[7] *((const byte*) RASTER#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0
[8] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0
[9] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq()
2018-08-05 22:37:40 +00:00
asm { cli }
to:main::@return
main::@return: scope:[main] from main
2018-11-11 20:51:36 +00:00
[11] return
2018-08-05 22:37:40 +00:00
to:@return
irq: scope:[irq] from
2018-11-11 20:51:36 +00:00
[12] *((const byte*) BGCOL#0) ← (const byte) WHITE#0
[13] *((const byte*) BGCOL#0) ← (const byte) BLACK#0
[14] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0
2018-08-05 22:37:40 +00:00
to:irq::@return
irq::@return: scope:[irq] from irq
2018-11-11 20:51:36 +00:00
[15] return
2018-08-05 22:37:40 +00:00
to:@return
VARIABLE REGISTER WEIGHTS
(byte*) BGCOL
(byte) BLACK
(byte*) CIA1_INTERRUPT
(byte) CIA_INTERRUPT_CLEAR
(byte) IRQ_COLLISION_BG
(byte) IRQ_COLLISION_SPRITE
2018-08-05 22:37:40 +00:00
(byte*) IRQ_ENABLE
(byte) IRQ_LIGHTPEN
2018-08-05 22:37:40 +00:00
(byte) IRQ_RASTER
(byte*) IRQ_STATUS
(void()**) KERNEL_IRQ
(byte*) RASTER
(byte*) VIC_CONTROL
(byte) WHITE
2018-08-10 18:32:45 +00:00
interrupt(KERNEL_MIN)(void()) irq()
2018-08-05 22:37:40 +00:00
(void()) main()
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
//SEG0 File Comments
2019-02-17 23:12:29 +00:00
// A minimal working raster IRQ
//SEG1 Basic Upstart
2018-08-05 22:37:40 +00:00
.pc = $801 "Basic"
:BasicUpstart(bbegin)
2018-08-05 22:37:40 +00:00
.pc = $80d "Program"
//SEG2 Global Constants & labels
2018-08-05 22:37:40 +00:00
.label KERNEL_IRQ = $314
.label RASTER = $d012
.label VIC_CONTROL = $d011
.label IRQ_STATUS = $d019
.label IRQ_ENABLE = $d01a
.const IRQ_RASTER = 1
.label BGCOL = $d020
.const WHITE = 1
.const BLACK = 0
.label CIA1_INTERRUPT = $dc0d
.const CIA_INTERRUPT_CLEAR = $7f
//SEG3 @begin
2018-08-05 22:37:40 +00:00
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
2018-08-05 22:37:40 +00:00
b2_from_bbegin:
jmp b2
//SEG5 @2
2018-08-05 22:37:40 +00:00
b2:
//SEG6 [2] call main
2018-08-05 22:37:40 +00:00
jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
2018-08-05 22:37:40 +00:00
bend_from_b2:
jmp bend
//SEG8 @end
2018-08-05 22:37:40 +00:00
bend:
//SEG9 main
2018-08-05 22:37:40 +00:00
main: {
//SEG10 asm { sei }
2018-08-05 22:37:40 +00:00
sei
//SEG11 [5] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Disable CIA 1 Timer IRQ
2018-08-05 22:37:40 +00:00
lda #CIA_INTERRUPT_CLEAR
sta CIA1_INTERRUPT
//SEG12 [6] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (byte/word/signed word/dword/signed dword) 128 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
2019-02-17 23:12:29 +00:00
// Set raster line to $100
2018-08-05 22:37:40 +00:00
lda VIC_CONTROL
ora #$80
sta VIC_CONTROL
//SEG13 [7] *((const byte*) RASTER#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #0
sta RASTER
//SEG14 [8] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Enable Raster Interrupt
2018-08-05 22:37:40 +00:00
lda #IRQ_RASTER
sta IRQ_ENABLE
//SEG15 [9] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2
2019-02-17 23:12:29 +00:00
// Set the IRQ routine
2018-08-05 22:37:40 +00:00
lda #<irq
sta KERNEL_IRQ
lda #>irq
sta KERNEL_IRQ+1
//SEG16 asm { cli }
2018-08-05 22:37:40 +00:00
cli
jmp breturn
//SEG17 main::@return
2018-08-05 22:37:40 +00:00
breturn:
//SEG18 [11] return
2018-08-05 22:37:40 +00:00
rts
}
//SEG19 irq
2019-02-17 23:12:29 +00:00
// Interrupt Routine
2018-08-05 22:37:40 +00:00
irq: {
//SEG20 entry interrupt(KERNEL_MIN)
//SEG21 [12] *((const byte*) BGCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #WHITE
sta BGCOL
//SEG22 [13] *((const byte*) BGCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #BLACK
sta BGCOL
//SEG23 [14] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Acknowledge the IRQ
2018-08-05 22:37:40 +00:00
lda #IRQ_RASTER
sta IRQ_STATUS
jmp breturn
//SEG24 irq::@return
2018-08-05 22:37:40 +00:00
breturn:
//SEG25 [15] return - exit interrupt(KERNEL_MIN)
2018-08-05 22:37:40 +00:00
jmp $ea81
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (byte/word/signed word/dword/signed dword) 128 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) RASTER#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
2018-08-10 18:32:45 +00:00
Statement [9] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() [ ] ( main:2 [ ] ) always clobbers reg byte a
2018-12-25 20:47:19 +00:00
Statement [12] *((const byte*) BGCOL#0) ← (const byte) WHITE#0 [ ] ( [ ] ) always clobbers reg byte a
Statement [13] *((const byte*) BGCOL#0) ← (const byte) BLACK#0 [ ] ( [ ] ) always clobbers reg byte a
Statement [14] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 [ ] ( [ ] ) always clobbers reg byte a
2018-08-05 22:37:40 +00:00
REGISTER UPLIFT SCOPES
Uplift Scope [main]
Uplift Scope [irq]
Uplift Scope []
Uplifting [main] best 89 combination
Uplifting [irq] best 89 combination
Uplifting [] best 89 combination
2018-08-05 22:37:40 +00:00
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
2019-02-17 23:12:29 +00:00
// A minimal working raster IRQ
//SEG1 Basic Upstart
2018-08-05 22:37:40 +00:00
.pc = $801 "Basic"
:BasicUpstart(bbegin)
2018-08-05 22:37:40 +00:00
.pc = $80d "Program"
//SEG2 Global Constants & labels
2018-08-05 22:37:40 +00:00
.label KERNEL_IRQ = $314
.label RASTER = $d012
.label VIC_CONTROL = $d011
.label IRQ_STATUS = $d019
.label IRQ_ENABLE = $d01a
.const IRQ_RASTER = 1
.label BGCOL = $d020
.const WHITE = 1
.const BLACK = 0
.label CIA1_INTERRUPT = $dc0d
.const CIA_INTERRUPT_CLEAR = $7f
//SEG3 @begin
2018-08-05 22:37:40 +00:00
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
2018-08-05 22:37:40 +00:00
b2_from_bbegin:
jmp b2
//SEG5 @2
2018-08-05 22:37:40 +00:00
b2:
//SEG6 [2] call main
2018-08-05 22:37:40 +00:00
jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
2018-08-05 22:37:40 +00:00
bend_from_b2:
jmp bend
//SEG8 @end
2018-08-05 22:37:40 +00:00
bend:
//SEG9 main
2018-08-05 22:37:40 +00:00
main: {
//SEG10 asm { sei }
2018-08-05 22:37:40 +00:00
sei
//SEG11 [5] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Disable CIA 1 Timer IRQ
2018-08-05 22:37:40 +00:00
lda #CIA_INTERRUPT_CLEAR
sta CIA1_INTERRUPT
//SEG12 [6] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (byte/word/signed word/dword/signed dword) 128 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
2019-02-17 23:12:29 +00:00
// Set raster line to $100
2018-08-05 22:37:40 +00:00
lda VIC_CONTROL
ora #$80
sta VIC_CONTROL
//SEG13 [7] *((const byte*) RASTER#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #0
sta RASTER
//SEG14 [8] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Enable Raster Interrupt
2018-08-05 22:37:40 +00:00
lda #IRQ_RASTER
sta IRQ_ENABLE
//SEG15 [9] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2
2019-02-17 23:12:29 +00:00
// Set the IRQ routine
2018-08-05 22:37:40 +00:00
lda #<irq
sta KERNEL_IRQ
lda #>irq
sta KERNEL_IRQ+1
//SEG16 asm { cli }
2018-08-05 22:37:40 +00:00
cli
jmp breturn
//SEG17 main::@return
2018-08-05 22:37:40 +00:00
breturn:
//SEG18 [11] return
2018-08-05 22:37:40 +00:00
rts
}
//SEG19 irq
2019-02-17 23:12:29 +00:00
// Interrupt Routine
2018-08-05 22:37:40 +00:00
irq: {
//SEG20 entry interrupt(KERNEL_MIN)
//SEG21 [12] *((const byte*) BGCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #WHITE
sta BGCOL
//SEG22 [13] *((const byte*) BGCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #BLACK
sta BGCOL
//SEG23 [14] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Acknowledge the IRQ
2018-08-05 22:37:40 +00:00
lda #IRQ_RASTER
sta IRQ_STATUS
jmp breturn
//SEG24 irq::@return
2018-08-05 22:37:40 +00:00
breturn:
//SEG25 [15] return - exit interrupt(KERNEL_MIN)
2018-08-05 22:37:40 +00:00
jmp $ea81
}
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b2_from_bbegin:
Removing instruction b2:
2018-08-05 22:37:40 +00:00
Removing instruction bend_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
2018-08-05 22:37:40 +00:00
FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = ((byte*))(word/dword/signed dword) 53280
(byte) BLACK
(const byte) BLACK#0 BLACK = (byte/signed byte/word/signed word/dword/signed dword) 0
(byte*) CIA1_INTERRUPT
(const byte*) CIA1_INTERRUPT#0 CIA1_INTERRUPT = ((byte*))(word/dword/signed dword) 56333
(byte) CIA_INTERRUPT_CLEAR
(const byte) CIA_INTERRUPT_CLEAR#0 CIA_INTERRUPT_CLEAR = (byte/signed byte/word/signed word/dword/signed dword) 127
(byte) IRQ_COLLISION_BG
(byte) IRQ_COLLISION_SPRITE
2018-08-05 22:37:40 +00:00
(byte*) IRQ_ENABLE
(const byte*) IRQ_ENABLE#0 IRQ_ENABLE = ((byte*))(word/dword/signed dword) 53274
(byte) IRQ_LIGHTPEN
2018-08-05 22:37:40 +00:00
(byte) IRQ_RASTER
(const byte) IRQ_RASTER#0 IRQ_RASTER = (byte/signed byte/word/signed word/dword/signed dword) 1
(byte*) IRQ_STATUS
(const byte*) IRQ_STATUS#0 IRQ_STATUS = ((byte*))(word/dword/signed dword) 53273
(void()**) KERNEL_IRQ
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = ((void()**))(word/signed word/dword/signed dword) 788
(byte*) RASTER
(const byte*) RASTER#0 RASTER = ((byte*))(word/dword/signed dword) 53266
(byte*) VIC_CONTROL
(const byte*) VIC_CONTROL#0 VIC_CONTROL = ((byte*))(word/dword/signed dword) 53265
(byte) WHITE
(const byte) WHITE#0 WHITE = (byte/signed byte/word/signed word/dword/signed dword) 1
2018-08-10 18:32:45 +00:00
interrupt(KERNEL_MIN)(void()) irq()
2018-08-05 22:37:40 +00:00
(label) irq::@return
(void()) main()
(label) main::@return
FINAL ASSEMBLER
Score: 71
2018-08-05 22:37:40 +00:00
//SEG0 File Comments
2019-02-17 23:12:29 +00:00
// A minimal working raster IRQ
//SEG1 Basic Upstart
2018-08-05 22:37:40 +00:00
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
2018-08-05 22:37:40 +00:00
.label KERNEL_IRQ = $314
.label RASTER = $d012
.label VIC_CONTROL = $d011
.label IRQ_STATUS = $d019
.label IRQ_ENABLE = $d01a
.const IRQ_RASTER = 1
.label BGCOL = $d020
.const WHITE = 1
.const BLACK = 0
.label CIA1_INTERRUPT = $dc0d
.const CIA_INTERRUPT_CLEAR = $7f
//SEG3 @begin
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG5 @2
//SEG6 [2] call main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
//SEG8 @end
//SEG9 main
2018-08-05 22:37:40 +00:00
main: {
//SEG10 asm { sei }
2018-08-05 22:37:40 +00:00
sei
//SEG11 [5] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Disable CIA 1 Timer IRQ
2018-08-05 22:37:40 +00:00
lda #CIA_INTERRUPT_CLEAR
sta CIA1_INTERRUPT
//SEG12 [6] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (byte/word/signed word/dword/signed dword) 128 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
2019-02-17 23:12:29 +00:00
// Set raster line to $100
2018-08-05 22:37:40 +00:00
lda VIC_CONTROL
ora #$80
sta VIC_CONTROL
//SEG13 [7] *((const byte*) RASTER#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #0
sta RASTER
//SEG14 [8] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Enable Raster Interrupt
2018-08-05 22:37:40 +00:00
lda #IRQ_RASTER
sta IRQ_ENABLE
//SEG15 [9] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2
2019-02-17 23:12:29 +00:00
// Set the IRQ routine
2018-08-05 22:37:40 +00:00
lda #<irq
sta KERNEL_IRQ
lda #>irq
sta KERNEL_IRQ+1
//SEG16 asm { cli }
2018-08-05 22:37:40 +00:00
cli
//SEG17 main::@return
//SEG18 [11] return
2018-08-05 22:37:40 +00:00
rts
}
//SEG19 irq
2019-02-17 23:12:29 +00:00
// Interrupt Routine
2018-08-05 22:37:40 +00:00
irq: {
//SEG20 entry interrupt(KERNEL_MIN)
//SEG21 [12] *((const byte*) BGCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #WHITE
sta BGCOL
//SEG22 [13] *((const byte*) BGCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2
2018-08-05 22:37:40 +00:00
lda #BLACK
sta BGCOL
//SEG23 [14] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2
2019-02-17 23:12:29 +00:00
// Acknowledge the IRQ
2018-08-05 22:37:40 +00:00
lda #IRQ_RASTER
sta IRQ_STATUS
//SEG24 irq::@return
//SEG25 [15] return - exit interrupt(KERNEL_MIN)
2018-08-05 22:37:40 +00:00
jmp $ea81
}