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
|
2020-04-25 18:10:49 +00:00
|
|
|
to:@1
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2020-04-25 18:10:49 +00:00
|
|
|
main: scope:[main] from @1
|
2018-08-05 22:37:40 +00:00
|
|
|
asm { sei }
|
2020-03-29 19:00:25 +00:00
|
|
|
*((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()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq()
|
2018-08-05 22:37:40 +00:00
|
|
|
asm { cli }
|
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main
|
|
|
|
return
|
|
|
|
to:@return
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
interrupt(KERNEL_MIN)(void()) irq()
|
2018-08-05 22:37:40 +00:00
|
|
|
irq: scope:[irq] from
|
2020-05-02 09:38:51 +00:00
|
|
|
*((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE
|
|
|
|
*((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK
|
2020-03-29 19:00:25 +00:00
|
|
|
*((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER
|
2018-08-05 22:37:40 +00:00
|
|
|
to:irq::@return
|
|
|
|
irq::@return: scope:[irq] from irq
|
|
|
|
return
|
|
|
|
to:@return
|
2020-04-25 18:10:49 +00:00
|
|
|
@1: scope:[] from @begin
|
2018-08-05 22:37:40 +00:00
|
|
|
call main
|
2020-04-25 18:10:49 +00:00
|
|
|
to:@2
|
|
|
|
@2: scope:[] from @1
|
2018-08-05 22:37:40 +00:00
|
|
|
to:@end
|
2020-04-25 18:10:49 +00:00
|
|
|
@end: scope:[] from @2
|
2018-08-05 22:37:40 +00:00
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
2020-04-25 18:10:49 +00:00
|
|
|
(label) @1
|
2018-08-05 22:37:40 +00:00
|
|
|
(label) @2
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
2020-05-02 09:38:51 +00:00
|
|
|
(const nomodify byte*) BG_COLOR = (byte*)(number) $d020
|
2020-03-29 19:00:25 +00:00
|
|
|
(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*) IRQ_ENABLE = (byte*)(number) $d01a
|
|
|
|
(const nomodify byte) IRQ_RASTER = (byte) 1
|
|
|
|
(const nomodify byte*) IRQ_STATUS = (byte*)(number) $d019
|
|
|
|
(const nomodify void()**) KERNEL_IRQ = (void()**)(number) $314
|
|
|
|
(const nomodify byte*) RASTER = (byte*)(number) $d012
|
|
|
|
(const nomodify byte*) VIC_CONTROL = (byte*)(number) $d011
|
|
|
|
(const nomodify byte) WHITE = (byte) 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
|
|
|
|
|
2020-03-29 19:00:25 +00:00
|
|
|
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
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
2020-03-29 19:00:25 +00:00
|
|
|
Inlining cast *((const nomodify byte*) RASTER) ← (unumber)(number) 0
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization Pass2InlineCast
|
|
|
|
Simplifying constant pointer cast (void()**) 788
|
|
|
|
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*) 56333
|
|
|
|
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
|
2018-08-05 22:37:40 +00:00
|
|
|
Adding NOP phi() at start of @begin
|
2020-04-25 18:10:49 +00:00
|
|
|
Adding NOP phi() at start of @1
|
2018-08-05 22:37:40 +00:00
|
|
|
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
|
2020-04-25 18:10:49 +00:00
|
|
|
Culled Empty Block (label) @2
|
2018-08-05 22:37:40 +00:00
|
|
|
Adding NOP phi() at start of @begin
|
2019-03-31 15:10:41 +00:00
|
|
|
Adding NOP phi() at start of @1
|
2018-08-05 22:37:40 +00:00
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
@begin: scope:[] from
|
2018-11-11 20:51:36 +00:00
|
|
|
[0] phi()
|
2019-03-31 15:10:41 +00:00
|
|
|
to:@1
|
|
|
|
@1: 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
|
2019-03-31 15:10:41 +00:00
|
|
|
@end: scope:[] from @1
|
2018-11-11 20:51:36 +00:00
|
|
|
[3] phi()
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2019-03-31 15:10:41 +00:00
|
|
|
main: scope:[main] from @1
|
2018-08-05 22:37:40 +00:00
|
|
|
asm { sei }
|
2020-03-29 19:00:25 +00:00
|
|
|
[5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR
|
|
|
|
[6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80
|
|
|
|
[7] *((const nomodify byte*) RASTER) ← (byte) 0
|
|
|
|
[8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER
|
|
|
|
[9] *((const nomodify void()**) KERNEL_IRQ) ← &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
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
interrupt(KERNEL_MIN)(void()) irq()
|
2018-08-05 22:37:40 +00:00
|
|
|
irq: scope:[irq] from
|
2020-05-02 09:38:51 +00:00
|
|
|
[12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE
|
|
|
|
[13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK
|
2020-03-29 19:00:25 +00:00
|
|
|
[14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER
|
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
|
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
|
2019-09-08 00:29:17 +00:00
|
|
|
Target platform is c64basic / MOS6502X
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-02-17 23:12:29 +00:00
|
|
|
// A minimal working raster IRQ
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-08-05 22:37:40 +00:00
|
|
|
.pc = $801 "Basic"
|
2020-05-11 00:36:37 +00:00
|
|
|
:BasicUpstart(main)
|
2018-08-05 22:37:40 +00:00
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
2020-04-30 20:15:59 +00:00
|
|
|
.const IRQ_RASTER = 1
|
|
|
|
.const WHITE = 1
|
|
|
|
.const BLACK = 0
|
|
|
|
.const CIA_INTERRUPT_CLEAR = $7f
|
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
|
2020-05-02 09:38:51 +00:00
|
|
|
.label BG_COLOR = $d020
|
2018-08-05 22:37:40 +00:00
|
|
|
.label CIA1_INTERRUPT = $dc0d
|
2019-07-08 14:43:09 +00:00
|
|
|
// @begin
|
2019-09-29 21:13:37 +00:00
|
|
|
__bbegin:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from___bbegin:
|
|
|
|
jmp __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// @1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [2] call main
|
2018-08-05 22:37:40 +00:00
|
|
|
jsr main
|
2019-07-08 14:43:09 +00:00
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend_from___b1:
|
|
|
|
jmp __bend
|
2019-07-08 14:43:09 +00:00
|
|
|
// @end
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend:
|
2019-07-08 14:43:09 +00:00
|
|
|
// main
|
2018-08-05 22:37:40 +00:00
|
|
|
main: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// asm { sei }
|
2018-08-05 22:37:40 +00:00
|
|
|
sei
|
2020-03-29 19:00:25 +00:00
|
|
|
// [5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _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
|
2020-03-29 19:00:25 +00:00
|
|
|
// [6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
2019-02-17 23:12:29 +00:00
|
|
|
// Set raster line to $100
|
2019-03-26 22:49:44 +00:00
|
|
|
lda #$80
|
|
|
|
ora VIC_CONTROL
|
2018-08-05 22:37:40 +00:00
|
|
|
sta VIC_CONTROL
|
2020-03-29 19:00:25 +00:00
|
|
|
// [7] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #0
|
|
|
|
sta RASTER
|
2020-03-29 19:00:25 +00:00
|
|
|
// [8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _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
|
2020-03-29 19:00:25 +00:00
|
|
|
// [9] *((const nomodify void()**) KERNEL_IRQ) ← &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
|
2019-07-08 14:43:09 +00:00
|
|
|
// asm { cli }
|
2018-08-05 22:37:40 +00:00
|
|
|
cli
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] return
|
2018-08-05 22:37:40 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// irq
|
2019-02-17 23:12:29 +00:00
|
|
|
// Interrupt Routine
|
2018-08-05 22:37:40 +00:00
|
|
|
irq: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// entry interrupt(KERNEL_MIN)
|
2020-05-02 09:38:51 +00:00
|
|
|
// [12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #WHITE
|
2020-05-02 09:38:51 +00:00
|
|
|
sta BG_COLOR
|
|
|
|
// [13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #BLACK
|
2020-05-02 09:38:51 +00:00
|
|
|
sta BG_COLOR
|
2020-03-29 19:00:25 +00:00
|
|
|
// [14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _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
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// irq::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] return - exit interrupt(KERNEL_MIN)
|
2018-08-05 22:37:40 +00:00
|
|
|
jmp $ea81
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-08-05 22:37:40 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2020-03-29 19:00:25 +00:00
|
|
|
Statement [5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
|
|
Statement [6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
|
|
Statement [7] *((const nomodify byte*) RASTER) ← (byte) 0 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
|
|
Statement [8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
|
|
Statement [9] *((const nomodify void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) irq() [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
2020-05-02 09:38:51 +00:00
|
|
|
Statement [12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE [ ] ( [ ] { } ) always clobbers reg byte a
|
|
|
|
Statement [13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK [ ] ( [ ] { } ) always clobbers reg byte a
|
2020-03-29 19:00:25 +00:00
|
|
|
Statement [14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER [ ] ( [ ] { } ) always clobbers reg byte a
|
2018-08-05 22:37:40 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
|
|
Uplift Scope [main]
|
|
|
|
Uplift Scope [irq]
|
|
|
|
Uplift Scope []
|
|
|
|
|
2018-08-11 23:03:44 +00:00
|
|
|
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
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-02-17 23:12:29 +00:00
|
|
|
// A minimal working raster IRQ
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-08-05 22:37:40 +00:00
|
|
|
.pc = $801 "Basic"
|
2020-05-11 00:36:37 +00:00
|
|
|
:BasicUpstart(main)
|
2018-08-05 22:37:40 +00:00
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
2020-04-30 20:15:59 +00:00
|
|
|
.const IRQ_RASTER = 1
|
|
|
|
.const WHITE = 1
|
|
|
|
.const BLACK = 0
|
|
|
|
.const CIA_INTERRUPT_CLEAR = $7f
|
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
|
2020-05-02 09:38:51 +00:00
|
|
|
.label BG_COLOR = $d020
|
2018-08-05 22:37:40 +00:00
|
|
|
.label CIA1_INTERRUPT = $dc0d
|
2019-07-08 14:43:09 +00:00
|
|
|
// @begin
|
2019-09-29 21:13:37 +00:00
|
|
|
__bbegin:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from___bbegin:
|
|
|
|
jmp __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// @1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [2] call main
|
2018-08-05 22:37:40 +00:00
|
|
|
jsr main
|
2019-07-08 14:43:09 +00:00
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend_from___b1:
|
|
|
|
jmp __bend
|
2019-07-08 14:43:09 +00:00
|
|
|
// @end
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend:
|
2019-07-08 14:43:09 +00:00
|
|
|
// main
|
2018-08-05 22:37:40 +00:00
|
|
|
main: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// asm { sei }
|
2018-08-05 22:37:40 +00:00
|
|
|
sei
|
2020-03-29 19:00:25 +00:00
|
|
|
// [5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _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
|
2020-03-29 19:00:25 +00:00
|
|
|
// [6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
2019-02-17 23:12:29 +00:00
|
|
|
// Set raster line to $100
|
2019-03-26 22:49:44 +00:00
|
|
|
lda #$80
|
|
|
|
ora VIC_CONTROL
|
2018-08-05 22:37:40 +00:00
|
|
|
sta VIC_CONTROL
|
2020-03-29 19:00:25 +00:00
|
|
|
// [7] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #0
|
|
|
|
sta RASTER
|
2020-03-29 19:00:25 +00:00
|
|
|
// [8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _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
|
2020-03-29 19:00:25 +00:00
|
|
|
// [9] *((const nomodify void()**) KERNEL_IRQ) ← &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
|
2019-07-08 14:43:09 +00:00
|
|
|
// asm { cli }
|
2018-08-05 22:37:40 +00:00
|
|
|
cli
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] return
|
2018-08-05 22:37:40 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// irq
|
2019-02-17 23:12:29 +00:00
|
|
|
// Interrupt Routine
|
2018-08-05 22:37:40 +00:00
|
|
|
irq: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// entry interrupt(KERNEL_MIN)
|
2020-05-02 09:38:51 +00:00
|
|
|
// [12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #WHITE
|
2020-05-02 09:38:51 +00:00
|
|
|
sta BG_COLOR
|
|
|
|
// [13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #BLACK
|
2020-05-02 09:38:51 +00:00
|
|
|
sta BG_COLOR
|
2020-03-29 19:00:25 +00:00
|
|
|
// [14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _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
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// irq::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] return - exit interrupt(KERNEL_MIN)
|
2018-08-05 22:37:40 +00:00
|
|
|
jmp $ea81
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-08-05 22:37:40 +00:00
|
|
|
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction jmp __b1
|
|
|
|
Removing instruction jmp __bend
|
|
|
|
Removing instruction jmp __breturn
|
|
|
|
Removing instruction jmp __breturn
|
2018-08-05 22:37:40 +00:00
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __b1_from___bbegin:
|
2020-03-03 07:58:31 +00:00
|
|
|
Removing instruction __b1:
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __bend_from___b1:
|
2018-08-05 22:37:40 +00:00
|
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
2020-05-11 00:36:37 +00:00
|
|
|
Removing instruction __bbegin:
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __bend:
|
|
|
|
Removing instruction __breturn:
|
|
|
|
Removing instruction __breturn:
|
2018-08-05 22:37:40 +00:00
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
2018-12-25 16:04:50 +00:00
|
|
|
Removing instruction jsr main
|
|
|
|
Succesful ASM optimization Pass5SkipBegin
|
2018-08-05 22:37:40 +00:00
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
2019-03-31 15:10:41 +00:00
|
|
|
(label) @1
|
2018-08-05 22:37:40 +00:00
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
2020-05-02 09:38:51 +00:00
|
|
|
(const nomodify byte*) BG_COLOR = (byte*) 53280
|
2020-03-29 19:00:25 +00:00
|
|
|
(const nomodify byte) BLACK = (byte) 0
|
|
|
|
(const nomodify byte*) CIA1_INTERRUPT = (byte*) 56333
|
|
|
|
(const nomodify byte) CIA_INTERRUPT_CLEAR = (byte) $7f
|
|
|
|
(const nomodify byte*) IRQ_ENABLE = (byte*) 53274
|
|
|
|
(const nomodify byte) IRQ_RASTER = (byte) 1
|
|
|
|
(const nomodify byte*) IRQ_STATUS = (byte*) 53273
|
|
|
|
(const nomodify void()**) KERNEL_IRQ = (void()**) 788
|
|
|
|
(const nomodify byte*) RASTER = (byte*) 53266
|
|
|
|
(const nomodify byte*) VIC_CONTROL = (byte*) 53265
|
|
|
|
(const nomodify byte) WHITE = (byte) 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
|
2018-12-25 16:04:50 +00:00
|
|
|
Score: 71
|
2018-08-05 22:37:40 +00:00
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-02-17 23:12:29 +00:00
|
|
|
// A minimal working raster IRQ
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-08-05 22:37:40 +00:00
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(main)
|
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
2020-04-30 20:15:59 +00:00
|
|
|
.const IRQ_RASTER = 1
|
|
|
|
.const WHITE = 1
|
|
|
|
.const BLACK = 0
|
|
|
|
.const CIA_INTERRUPT_CLEAR = $7f
|
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
|
2020-05-02 09:38:51 +00:00
|
|
|
.label BG_COLOR = $d020
|
2018-08-05 22:37:40 +00:00
|
|
|
.label CIA1_INTERRUPT = $dc0d
|
2019-07-08 14:43:09 +00:00
|
|
|
// @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
|
2018-08-05 22:37:40 +00:00
|
|
|
main: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// asm
|
|
|
|
// asm { sei }
|
2018-08-05 22:37:40 +00:00
|
|
|
sei
|
2019-07-08 14:43:09 +00:00
|
|
|
// *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
|
2020-03-29 19:00:25 +00:00
|
|
|
// [5] *((const nomodify byte*) CIA1_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _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
|
2019-07-08 14:43:09 +00:00
|
|
|
// *VIC_CONTROL |=$80
|
2020-03-29 19:00:25 +00:00
|
|
|
// [6] *((const nomodify byte*) VIC_CONTROL) ← *((const nomodify byte*) VIC_CONTROL) | (byte) $80 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
2019-02-17 23:12:29 +00:00
|
|
|
// Set raster line to $100
|
2019-03-26 22:49:44 +00:00
|
|
|
lda #$80
|
|
|
|
ora VIC_CONTROL
|
2018-08-05 22:37:40 +00:00
|
|
|
sta VIC_CONTROL
|
2019-07-08 14:43:09 +00:00
|
|
|
// *RASTER = $00
|
2020-03-29 19:00:25 +00:00
|
|
|
// [7] *((const nomodify byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #0
|
|
|
|
sta RASTER
|
2019-07-08 14:43:09 +00:00
|
|
|
// *IRQ_ENABLE = IRQ_RASTER
|
2020-03-29 19:00:25 +00:00
|
|
|
// [8] *((const nomodify byte*) IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _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
|
2019-07-08 14:43:09 +00:00
|
|
|
// *KERNEL_IRQ = &irq
|
2020-03-29 19:00:25 +00:00
|
|
|
// [9] *((const nomodify void()**) KERNEL_IRQ) ← &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
|
2019-07-08 14:43:09 +00:00
|
|
|
// asm
|
|
|
|
// asm { cli }
|
2018-08-05 22:37:40 +00:00
|
|
|
cli
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
|
|
|
// }
|
|
|
|
// [11] return
|
2018-08-05 22:37:40 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// irq
|
2019-02-17 23:12:29 +00:00
|
|
|
// Interrupt Routine
|
2018-08-05 22:37:40 +00:00
|
|
|
irq: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// entry interrupt(KERNEL_MIN)
|
2020-05-02 09:38:51 +00:00
|
|
|
// *BG_COLOR = WHITE
|
|
|
|
// [12] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) WHITE -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #WHITE
|
2020-05-02 09:38:51 +00:00
|
|
|
sta BG_COLOR
|
|
|
|
// *BG_COLOR = BLACK
|
|
|
|
// [13] *((const nomodify byte*) BG_COLOR) ← (const nomodify byte) BLACK -- _deref_pbuc1=vbuc2
|
2018-08-05 22:37:40 +00:00
|
|
|
lda #BLACK
|
2020-05-02 09:38:51 +00:00
|
|
|
sta BG_COLOR
|
2019-07-08 14:43:09 +00:00
|
|
|
// *IRQ_STATUS = IRQ_RASTER
|
2020-03-29 19:00:25 +00:00
|
|
|
// [14] *((const nomodify byte*) IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _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
|
2019-07-08 14:43:09 +00:00
|
|
|
// irq::@return
|
|
|
|
// }
|
|
|
|
// [15] return - exit interrupt(KERNEL_MIN)
|
2018-08-05 22:37:40 +00:00
|
|
|
jmp $ea81
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-08-05 22:37:40 +00:00
|
|
|
|