mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-26 12:49:21 +00:00
Working on MEGA65 platform target. #507
This commit is contained in:
parent
ed86691c25
commit
2724fb053a
@ -202,6 +202,12 @@ public class TestPrograms {
|
||||
compileAndCompare("examples/mega65/hello-mega65.c");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMega65Vic4() throws IOException, URISyntaxException {
|
||||
compileAndCompare("examples/mega65/test-vic4.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAtariXlRasterbars() throws IOException, URISyntaxException {
|
||||
compileAndCompare("examples/atarixl/rasterbars.c");
|
||||
|
57
src/test/kc/examples/mega65/test-vic4.c
Normal file
57
src/test/kc/examples/mega65/test-vic4.c
Normal file
@ -0,0 +1,57 @@
|
||||
// Hello World for MEGA 65 - putting chars directly to the screen
|
||||
#pragma target(mega65)
|
||||
#pragma emulator("/Users/jespergravgaard/c64/mega65/xemu-hmw/build/bin/xmega65.native -prg")
|
||||
#include <mega65.h>
|
||||
|
||||
char * const SCREEN = 0x0800;
|
||||
char * const COLORS = 0xd800;
|
||||
|
||||
char * const TBDRPOS = 0xd048;
|
||||
char * const TBDRPOS_HI = 0xd049;
|
||||
|
||||
void main() {
|
||||
|
||||
// Map memory to BANK 0 : 0x00XXXX - giving access to I/O
|
||||
asm {
|
||||
sei
|
||||
lda #0
|
||||
tax
|
||||
tay
|
||||
taz
|
||||
map
|
||||
eom
|
||||
}
|
||||
|
||||
// Enable the VIC 4
|
||||
*IO_KEY = 0x47;
|
||||
*IO_KEY = 0x53;
|
||||
|
||||
// Enable 2K Color RAM
|
||||
*IO_BANK |= CRAM2K;
|
||||
|
||||
// Fill the screen with '*'
|
||||
for( char *sc = SCREEN; sc<SCREEN+2000; sc++)
|
||||
*sc = '*';
|
||||
// Fill the color memory
|
||||
for( char *col = COLORS; col<COLORS+2000; col++)
|
||||
*col = <col;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// Set Border-color
|
||||
VICII->BORDER_COLOR = 0xff;
|
||||
VICII->BG_COLOR = 0x0b;
|
||||
for(;;) {
|
||||
while(VICII->RASTER!=0xfe) ;
|
||||
while(VICII->RASTER!=0xff) ;
|
||||
(*TBDRPOS)++;
|
||||
}
|
||||
*/
|
||||
|
||||
// Loop forever
|
||||
//for(;;) {
|
||||
// VICII->BORDER_COLOR = VICII->RASTER;
|
||||
//}
|
||||
|
||||
}
|
95
src/test/ref/examples/mega65/test-vic4.asm
Normal file
95
src/test/ref/examples/mega65/test-vic4.asm
Normal file
@ -0,0 +1,95 @@
|
||||
// Hello World for MEGA 65 - putting chars directly to the screen
|
||||
.cpu _45gs02
|
||||
.file [name="test-vic4.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$2001]
|
||||
.segmentdef Code [start=$2017]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
.byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0
|
||||
.byte $15, $20, $14, $00, $9e, $20 // 20 SYS
|
||||
.text toIntString(main) // NNNN
|
||||
.byte $00, $00, $00 //
|
||||
// Map 2nd KB of colour RAM $DC00-$DFFF (hiding CIA's)
|
||||
.const CRAM2K = 1
|
||||
// I/O Personality selection
|
||||
.label IO_KEY = $d02f
|
||||
// C65 Banking Register
|
||||
.label IO_BANK = $d030
|
||||
.label SCREEN = $800
|
||||
.label COLORS = $d800
|
||||
.segment Code
|
||||
main: {
|
||||
.label sc = 2
|
||||
.label col = 4
|
||||
// asm
|
||||
// Map memory to BANK 0 : 0x00XXXX - giving access to I/O
|
||||
sei
|
||||
lda #0
|
||||
tax
|
||||
tay
|
||||
taz
|
||||
map
|
||||
eom
|
||||
// *IO_KEY = 0x47
|
||||
// Enable the VIC 4
|
||||
lda #$47
|
||||
sta IO_KEY
|
||||
// *IO_KEY = 0x53
|
||||
lda #$53
|
||||
sta IO_KEY
|
||||
// *IO_BANK |= CRAM2K
|
||||
// Enable 2K Color RAM
|
||||
lda #CRAM2K
|
||||
ora IO_BANK
|
||||
sta IO_BANK
|
||||
lda #<SCREEN
|
||||
sta.z sc
|
||||
lda #>SCREEN
|
||||
sta.z sc+1
|
||||
// Fill the screen with '*'
|
||||
__b1:
|
||||
// for( char *sc = SCREEN; sc<SCREEN+2000; sc++)
|
||||
lda.z sc+1
|
||||
cmp #>SCREEN+$7d0
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z sc
|
||||
cmp #<SCREEN+$7d0
|
||||
bcc __b2
|
||||
!:
|
||||
lda #<COLORS
|
||||
sta.z col
|
||||
lda #>COLORS
|
||||
sta.z col+1
|
||||
// Fill the color memory
|
||||
__b3:
|
||||
// for( char *col = COLORS; col<COLORS+2000; col++)
|
||||
lda.z col+1
|
||||
cmp #>COLORS+$7d0
|
||||
bcc __b4
|
||||
bne !+
|
||||
lda.z col
|
||||
cmp #<COLORS+$7d0
|
||||
bcc __b4
|
||||
!:
|
||||
// }
|
||||
rts
|
||||
__b4:
|
||||
// <col
|
||||
lda.z col
|
||||
// *col = <col
|
||||
ldy #0
|
||||
sta (col),y
|
||||
// for( char *col = COLORS; col<COLORS+2000; col++)
|
||||
inw.z col
|
||||
jmp __b3
|
||||
__b2:
|
||||
// *sc = '*'
|
||||
lda #'*'
|
||||
ldy #0
|
||||
sta (sc),y
|
||||
// for( char *sc = SCREEN; sc<SCREEN+2000; sc++)
|
||||
inw.z sc
|
||||
jmp __b1
|
||||
}
|
28
src/test/ref/examples/mega65/test-vic4.cfg
Normal file
28
src/test/ref/examples/mega65/test-vic4.cfg
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from
|
||||
asm { sei lda#0 tax tay taz map eom }
|
||||
[1] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $47
|
||||
[2] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $53
|
||||
[3] *((const nomodify to_volatile byte*) IO_BANK) ← *((const nomodify to_volatile byte*) IO_BANK) | (const nomodify byte) CRAM2K
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[4] (byte*) main::sc#2 ← phi( main/(const nomodify byte*) SCREEN main::@2/(byte*) main::sc#1 )
|
||||
[5] if((byte*) main::sc#2<(const nomodify byte*) SCREEN+(word) $7d0) goto main::@2
|
||||
to:main::@3
|
||||
main::@3: scope:[main] from main::@1 main::@4
|
||||
[6] (byte*) main::col#2 ← phi( main::@1/(const nomodify byte*) COLORS main::@4/(byte*) main::col#1 )
|
||||
[7] if((byte*) main::col#2<(const nomodify byte*) COLORS+(word) $7d0) goto main::@4
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@3
|
||||
[8] return
|
||||
to:@return
|
||||
main::@4: scope:[main] from main::@3
|
||||
[9] (byte~) main::$2 ← < (byte*) main::col#2
|
||||
[10] *((byte*) main::col#2) ← (byte~) main::$2
|
||||
[11] (byte*) main::col#1 ← ++ (byte*) main::col#2
|
||||
to:main::@3
|
||||
main::@2: scope:[main] from main::@1
|
||||
[12] *((byte*) main::sc#2) ← (byte) '*'
|
||||
[13] (byte*) main::sc#1 ← ++ (byte*) main::sc#2
|
||||
to:main::@1
|
879
src/test/ref/examples/mega65/test-vic4.log
Normal file
879
src/test/ref/examples/mega65/test-vic4.log
Normal file
@ -0,0 +1,879 @@
|
||||
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from __start
|
||||
asm { sei lda#0 tax tay taz map eom }
|
||||
*((const nomodify to_volatile byte*) IO_KEY) ← (number) $47
|
||||
*((const nomodify to_volatile byte*) IO_KEY) ← (number) $53
|
||||
*((const nomodify to_volatile byte*) IO_BANK) ← *((const nomodify to_volatile byte*) IO_BANK) | (const nomodify byte) CRAM2K
|
||||
(byte*) main::sc#0 ← (const nomodify byte*) SCREEN
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
(byte*) main::sc#2 ← phi( main/(byte*) main::sc#0 main::@2/(byte*) main::sc#1 )
|
||||
(bool~) main::$0 ← (byte*) main::sc#2 < (const nomodify byte*) SCREEN+(number) $7d0
|
||||
if((bool~) main::$0) goto main::@2
|
||||
to:main::@3
|
||||
main::@2: scope:[main] from main::@1
|
||||
(byte*) main::sc#3 ← phi( main::@1/(byte*) main::sc#2 )
|
||||
*((byte*) main::sc#3) ← (byte) '*'
|
||||
(byte*) main::sc#1 ← ++ (byte*) main::sc#3
|
||||
to:main::@1
|
||||
main::@3: scope:[main] from main::@1
|
||||
(byte*) main::col#0 ← (const nomodify byte*) COLORS
|
||||
to:main::@4
|
||||
main::@4: scope:[main] from main::@3 main::@5
|
||||
(byte*) main::col#2 ← phi( main::@3/(byte*) main::col#0 main::@5/(byte*) main::col#1 )
|
||||
(bool~) main::$1 ← (byte*) main::col#2 < (const nomodify byte*) COLORS+(number) $7d0
|
||||
if((bool~) main::$1) goto main::@5
|
||||
to:main::@return
|
||||
main::@5: scope:[main] from main::@4
|
||||
(byte*) main::col#3 ← phi( main::@4/(byte*) main::col#2 )
|
||||
(byte~) main::$2 ← < (byte*) main::col#3
|
||||
*((byte*) main::col#3) ← (byte~) main::$2
|
||||
(byte*) main::col#1 ← ++ (byte*) main::col#3
|
||||
to:main::@4
|
||||
main::@return: scope:[main] from main::@4
|
||||
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*) COLORS = (byte*)(number) $d800
|
||||
(const nomodify byte) CRAM2K = (byte) 1
|
||||
(const nomodify to_volatile byte*) IO_BANK = (byte*)(number) $d030
|
||||
(const nomodify to_volatile byte*) IO_KEY = (byte*)(number) $d02f
|
||||
(byte) MOS6526_CIA::INTERRUPT
|
||||
(byte) MOS6526_CIA::PORT_A
|
||||
(byte) MOS6526_CIA::PORT_A_DDR
|
||||
(byte) MOS6526_CIA::PORT_B
|
||||
(byte) MOS6526_CIA::PORT_B_DDR
|
||||
(byte) MOS6526_CIA::SERIAL_DATA
|
||||
(word) MOS6526_CIA::TIMER_A
|
||||
(byte) MOS6526_CIA::TIMER_A_CONTROL
|
||||
(word) MOS6526_CIA::TIMER_B
|
||||
(byte) MOS6526_CIA::TIMER_B_CONTROL
|
||||
(byte) MOS6526_CIA::TOD_10THS
|
||||
(byte) MOS6526_CIA::TOD_HOURS
|
||||
(byte) MOS6526_CIA::TOD_MIN
|
||||
(byte) MOS6526_CIA::TOD_SEC
|
||||
(byte) MOS6569_VICII::BG_COLOR
|
||||
(byte) MOS6569_VICII::BG_COLOR1
|
||||
(byte) MOS6569_VICII::BG_COLOR2
|
||||
(byte) MOS6569_VICII::BG_COLOR3
|
||||
(byte) MOS6569_VICII::BORDER_COLOR
|
||||
(byte) MOS6569_VICII::CONTROL1
|
||||
(byte) MOS6569_VICII::CONTROL2
|
||||
(byte) MOS6569_VICII::IRQ_ENABLE
|
||||
(byte) MOS6569_VICII::IRQ_STATUS
|
||||
(byte) MOS6569_VICII::LIGHTPEN_X
|
||||
(byte) MOS6569_VICII::LIGHTPEN_Y
|
||||
(byte) MOS6569_VICII::MEMORY
|
||||
(byte) MOS6569_VICII::RASTER
|
||||
(byte) MOS6569_VICII::SPRITE0_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE0_X
|
||||
(byte) MOS6569_VICII::SPRITE0_Y
|
||||
(byte) MOS6569_VICII::SPRITE1_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE1_X
|
||||
(byte) MOS6569_VICII::SPRITE1_Y
|
||||
(byte) MOS6569_VICII::SPRITE2_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE2_X
|
||||
(byte) MOS6569_VICII::SPRITE2_Y
|
||||
(byte) MOS6569_VICII::SPRITE3_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE3_X
|
||||
(byte) MOS6569_VICII::SPRITE3_Y
|
||||
(byte) MOS6569_VICII::SPRITE4_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE4_X
|
||||
(byte) MOS6569_VICII::SPRITE4_Y
|
||||
(byte) MOS6569_VICII::SPRITE5_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE5_X
|
||||
(byte) MOS6569_VICII::SPRITE5_Y
|
||||
(byte) MOS6569_VICII::SPRITE6_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE6_X
|
||||
(byte) MOS6569_VICII::SPRITE6_Y
|
||||
(byte) MOS6569_VICII::SPRITE7_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE7_X
|
||||
(byte) MOS6569_VICII::SPRITE7_Y
|
||||
(byte) MOS6569_VICII::SPRITES_BG_COLLISION
|
||||
(byte) MOS6569_VICII::SPRITES_COLLISION
|
||||
(byte) MOS6569_VICII::SPRITES_ENABLE
|
||||
(byte) MOS6569_VICII::SPRITES_EXPAND_X
|
||||
(byte) MOS6569_VICII::SPRITES_EXPAND_Y
|
||||
(byte) MOS6569_VICII::SPRITES_MC
|
||||
(byte) MOS6569_VICII::SPRITES_MCOLOR1
|
||||
(byte) MOS6569_VICII::SPRITES_MCOLOR2
|
||||
(byte) MOS6569_VICII::SPRITES_PRIORITY
|
||||
(byte) MOS6569_VICII::SPRITES_XMSB
|
||||
(byte) MOS6581_SID::CH1_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH1_CONTROL
|
||||
(word) MOS6581_SID::CH1_FREQ
|
||||
(word) MOS6581_SID::CH1_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::CH2_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH2_CONTROL
|
||||
(word) MOS6581_SID::CH2_FREQ
|
||||
(word) MOS6581_SID::CH2_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::CH3_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH3_CONTROL
|
||||
(byte) MOS6581_SID::CH3_ENV
|
||||
(word) MOS6581_SID::CH3_FREQ
|
||||
(byte) MOS6581_SID::CH3_OSC
|
||||
(word) MOS6581_SID::CH3_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::FILTER_CUTOFF_HIGH
|
||||
(byte) MOS6581_SID::FILTER_CUTOFF_LOW
|
||||
(byte) MOS6581_SID::FILTER_SETUP
|
||||
(byte) MOS6581_SID::POT_X
|
||||
(byte) MOS6581_SID::POT_Y
|
||||
(byte) MOS6581_SID::VOLUME_FILTER_MODE
|
||||
(const nomodify byte*) SCREEN = (byte*)(number) $800
|
||||
(void()) __start()
|
||||
(label) __start::@1
|
||||
(label) __start::@return
|
||||
(void()) main()
|
||||
(bool~) main::$0
|
||||
(bool~) main::$1
|
||||
(byte~) main::$2
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@4
|
||||
(label) main::@5
|
||||
(label) main::@return
|
||||
(byte*) main::col
|
||||
(byte*) main::col#0
|
||||
(byte*) main::col#1
|
||||
(byte*) main::col#2
|
||||
(byte*) main::col#3
|
||||
(byte*) main::sc
|
||||
(byte*) main::sc#0
|
||||
(byte*) main::sc#1
|
||||
(byte*) main::sc#2
|
||||
(byte*) main::sc#3
|
||||
|
||||
Adding number conversion cast (unumber) $47 in *((const nomodify to_volatile byte*) IO_KEY) ← (number) $47
|
||||
Adding number conversion cast (unumber) $53 in *((const nomodify to_volatile byte*) IO_KEY) ← (number) $53
|
||||
Adding number conversion cast (unumber) $7d0 in (bool~) main::$0 ← (byte*) main::sc#2 < (const nomodify byte*) SCREEN+(number) $7d0
|
||||
Adding number conversion cast (unumber) $7d0 in (bool~) main::$1 ← (byte*) main::col#2 < (const nomodify byte*) COLORS+(number) $7d0
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Inlining cast *((const nomodify to_volatile byte*) IO_KEY) ← (unumber)(number) $47
|
||||
Inlining cast *((const nomodify to_volatile byte*) IO_KEY) ← (unumber)(number) $53
|
||||
Successful SSA optimization Pass2InlineCast
|
||||
Simplifying constant pointer cast (byte*) 53295
|
||||
Simplifying constant pointer cast (byte*) 53296
|
||||
Simplifying constant pointer cast (byte*) 2048
|
||||
Simplifying constant pointer cast (byte*) 55296
|
||||
Simplifying constant integer cast $47
|
||||
Simplifying constant integer cast $53
|
||||
Simplifying constant integer cast $7d0
|
||||
Simplifying constant integer cast $7d0
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Finalized unsigned number type (byte) $47
|
||||
Finalized unsigned number type (byte) $53
|
||||
Finalized unsigned number type (word) $7d0
|
||||
Finalized unsigned number type (word) $7d0
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Alias main::sc#2 = main::sc#3
|
||||
Alias main::col#2 = main::col#3
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Simple Condition (bool~) main::$0 [7] if((byte*) main::sc#2<(const nomodify byte*) SCREEN+(word) $7d0) goto main::@2
|
||||
Simple Condition (bool~) main::$1 [13] if((byte*) main::col#2<(const nomodify byte*) COLORS+(word) $7d0) goto main::@5
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const byte*) main::sc#0 = SCREEN
|
||||
Constant (const byte*) main::col#0 = COLORS
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
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
|
||||
Inlining constant with var siblings (const byte*) main::sc#0
|
||||
Inlining constant with var siblings (const byte*) main::col#0
|
||||
Constant inlined main::col#0 = (const nomodify byte*) COLORS
|
||||
Constant inlined main::sc#0 = (const nomodify byte*) SCREEN
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Adding NOP phi() at start of main::@3
|
||||
CALL GRAPH
|
||||
|
||||
Created 2 initial phi equivalence classes
|
||||
Coalesced [13] main::col#4 ← main::col#1
|
||||
Coalesced [16] main::sc#4 ← main::sc#1
|
||||
Coalesced down to 2 phi equivalence classes
|
||||
Culled Empty Block (label) main::@3
|
||||
Renumbering block main::@4 to main::@3
|
||||
Renumbering block main::@5 to main::@4
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from
|
||||
asm { sei lda#0 tax tay taz map eom }
|
||||
[1] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $47
|
||||
[2] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $53
|
||||
[3] *((const nomodify to_volatile byte*) IO_BANK) ← *((const nomodify to_volatile byte*) IO_BANK) | (const nomodify byte) CRAM2K
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[4] (byte*) main::sc#2 ← phi( main/(const nomodify byte*) SCREEN main::@2/(byte*) main::sc#1 )
|
||||
[5] if((byte*) main::sc#2<(const nomodify byte*) SCREEN+(word) $7d0) goto main::@2
|
||||
to:main::@3
|
||||
main::@3: scope:[main] from main::@1 main::@4
|
||||
[6] (byte*) main::col#2 ← phi( main::@1/(const nomodify byte*) COLORS main::@4/(byte*) main::col#1 )
|
||||
[7] if((byte*) main::col#2<(const nomodify byte*) COLORS+(word) $7d0) goto main::@4
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@3
|
||||
[8] return
|
||||
to:@return
|
||||
main::@4: scope:[main] from main::@3
|
||||
[9] (byte~) main::$2 ← < (byte*) main::col#2
|
||||
[10] *((byte*) main::col#2) ← (byte~) main::$2
|
||||
[11] (byte*) main::col#1 ← ++ (byte*) main::col#2
|
||||
to:main::@3
|
||||
main::@2: scope:[main] from main::@1
|
||||
[12] *((byte*) main::sc#2) ← (byte) '*'
|
||||
[13] (byte*) main::sc#1 ← ++ (byte*) main::sc#2
|
||||
to:main::@1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(byte) MOS6526_CIA::INTERRUPT
|
||||
(byte) MOS6526_CIA::PORT_A
|
||||
(byte) MOS6526_CIA::PORT_A_DDR
|
||||
(byte) MOS6526_CIA::PORT_B
|
||||
(byte) MOS6526_CIA::PORT_B_DDR
|
||||
(byte) MOS6526_CIA::SERIAL_DATA
|
||||
(word) MOS6526_CIA::TIMER_A
|
||||
(byte) MOS6526_CIA::TIMER_A_CONTROL
|
||||
(word) MOS6526_CIA::TIMER_B
|
||||
(byte) MOS6526_CIA::TIMER_B_CONTROL
|
||||
(byte) MOS6526_CIA::TOD_10THS
|
||||
(byte) MOS6526_CIA::TOD_HOURS
|
||||
(byte) MOS6526_CIA::TOD_MIN
|
||||
(byte) MOS6526_CIA::TOD_SEC
|
||||
(byte) MOS6569_VICII::BG_COLOR
|
||||
(byte) MOS6569_VICII::BG_COLOR1
|
||||
(byte) MOS6569_VICII::BG_COLOR2
|
||||
(byte) MOS6569_VICII::BG_COLOR3
|
||||
(byte) MOS6569_VICII::BORDER_COLOR
|
||||
(byte) MOS6569_VICII::CONTROL1
|
||||
(byte) MOS6569_VICII::CONTROL2
|
||||
(byte) MOS6569_VICII::IRQ_ENABLE
|
||||
(byte) MOS6569_VICII::IRQ_STATUS
|
||||
(byte) MOS6569_VICII::LIGHTPEN_X
|
||||
(byte) MOS6569_VICII::LIGHTPEN_Y
|
||||
(byte) MOS6569_VICII::MEMORY
|
||||
(byte) MOS6569_VICII::RASTER
|
||||
(byte) MOS6569_VICII::SPRITE0_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE0_X
|
||||
(byte) MOS6569_VICII::SPRITE0_Y
|
||||
(byte) MOS6569_VICII::SPRITE1_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE1_X
|
||||
(byte) MOS6569_VICII::SPRITE1_Y
|
||||
(byte) MOS6569_VICII::SPRITE2_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE2_X
|
||||
(byte) MOS6569_VICII::SPRITE2_Y
|
||||
(byte) MOS6569_VICII::SPRITE3_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE3_X
|
||||
(byte) MOS6569_VICII::SPRITE3_Y
|
||||
(byte) MOS6569_VICII::SPRITE4_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE4_X
|
||||
(byte) MOS6569_VICII::SPRITE4_Y
|
||||
(byte) MOS6569_VICII::SPRITE5_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE5_X
|
||||
(byte) MOS6569_VICII::SPRITE5_Y
|
||||
(byte) MOS6569_VICII::SPRITE6_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE6_X
|
||||
(byte) MOS6569_VICII::SPRITE6_Y
|
||||
(byte) MOS6569_VICII::SPRITE7_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE7_X
|
||||
(byte) MOS6569_VICII::SPRITE7_Y
|
||||
(byte) MOS6569_VICII::SPRITES_BG_COLLISION
|
||||
(byte) MOS6569_VICII::SPRITES_COLLISION
|
||||
(byte) MOS6569_VICII::SPRITES_ENABLE
|
||||
(byte) MOS6569_VICII::SPRITES_EXPAND_X
|
||||
(byte) MOS6569_VICII::SPRITES_EXPAND_Y
|
||||
(byte) MOS6569_VICII::SPRITES_MC
|
||||
(byte) MOS6569_VICII::SPRITES_MCOLOR1
|
||||
(byte) MOS6569_VICII::SPRITES_MCOLOR2
|
||||
(byte) MOS6569_VICII::SPRITES_PRIORITY
|
||||
(byte) MOS6569_VICII::SPRITES_XMSB
|
||||
(byte) MOS6581_SID::CH1_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH1_CONTROL
|
||||
(word) MOS6581_SID::CH1_FREQ
|
||||
(word) MOS6581_SID::CH1_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::CH2_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH2_CONTROL
|
||||
(word) MOS6581_SID::CH2_FREQ
|
||||
(word) MOS6581_SID::CH2_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::CH3_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH3_CONTROL
|
||||
(byte) MOS6581_SID::CH3_ENV
|
||||
(word) MOS6581_SID::CH3_FREQ
|
||||
(byte) MOS6581_SID::CH3_OSC
|
||||
(word) MOS6581_SID::CH3_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::FILTER_CUTOFF_HIGH
|
||||
(byte) MOS6581_SID::FILTER_CUTOFF_LOW
|
||||
(byte) MOS6581_SID::FILTER_SETUP
|
||||
(byte) MOS6581_SID::POT_X
|
||||
(byte) MOS6581_SID::POT_Y
|
||||
(byte) MOS6581_SID::VOLUME_FILTER_MODE
|
||||
(void()) main()
|
||||
(byte~) main::$2 22.0
|
||||
(byte*) main::col
|
||||
(byte*) main::col#1 22.0
|
||||
(byte*) main::col#2 13.75
|
||||
(byte*) main::sc
|
||||
(byte*) main::sc#1 22.0
|
||||
(byte*) main::sc#2 14.666666666666666
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::sc#2 main::sc#1 ]
|
||||
[ main::col#2 main::col#1 ]
|
||||
Added variable main::$2 to live range equivalence class [ main::$2 ]
|
||||
Complete equivalence classes
|
||||
[ main::sc#2 main::sc#1 ]
|
||||
[ main::col#2 main::col#1 ]
|
||||
[ main::$2 ]
|
||||
Allocated zp[2]:2 [ main::sc#2 main::sc#1 ]
|
||||
Allocated zp[2]:4 [ main::col#2 main::col#1 ]
|
||||
Allocated zp[1]:6 [ main::$2 ]
|
||||
|
||||
INITIAL ASM
|
||||
Target platform is mega65 / MEGA45GS02
|
||||
// File Comments
|
||||
// Hello World for MEGA 65 - putting chars directly to the screen
|
||||
// Upstart
|
||||
.cpu _45gs02
|
||||
.file [name="test-vic4.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$2001]
|
||||
.segmentdef Code [start=$2017]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
.byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0
|
||||
.byte $15, $20, $14, $00, $9e, $20 // 20 SYS
|
||||
.text toIntString(main) // NNNN
|
||||
.byte $00, $00, $00 //
|
||||
// Global Constants & labels
|
||||
// Map 2nd KB of colour RAM $DC00-$DFFF (hiding CIA's)
|
||||
.const CRAM2K = 1
|
||||
// I/O Personality selection
|
||||
.label IO_KEY = $d02f
|
||||
// C65 Banking Register
|
||||
.label IO_BANK = $d030
|
||||
.label SCREEN = $800
|
||||
.label COLORS = $d800
|
||||
.segment Code
|
||||
// main
|
||||
main: {
|
||||
.label __2 = 6
|
||||
.label sc = 2
|
||||
.label col = 4
|
||||
// asm { sei lda#0 tax tay taz map eom }
|
||||
// Map memory to BANK 0 : 0x00XXXX - giving access to I/O
|
||||
sei
|
||||
lda #0
|
||||
tax
|
||||
tay
|
||||
taz
|
||||
map
|
||||
eom
|
||||
// [1] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $47 -- _deref_pbuc1=vbuc2
|
||||
// Enable the VIC 4
|
||||
lda #$47
|
||||
sta IO_KEY
|
||||
// [2] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $53 -- _deref_pbuc1=vbuc2
|
||||
lda #$53
|
||||
sta IO_KEY
|
||||
// [3] *((const nomodify to_volatile byte*) IO_BANK) ← *((const nomodify to_volatile byte*) IO_BANK) | (const nomodify byte) CRAM2K -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
||||
// Enable 2K Color RAM
|
||||
lda #CRAM2K
|
||||
ora IO_BANK
|
||||
sta IO_BANK
|
||||
// [4] phi from main to main::@1 [phi:main->main::@1]
|
||||
__b1_from_main:
|
||||
// [4] phi (byte*) main::sc#2 = (const nomodify byte*) SCREEN [phi:main->main::@1#0] -- pbuz1=pbuc1
|
||||
lda #<SCREEN
|
||||
sta.z sc
|
||||
lda #>SCREEN
|
||||
sta.z sc+1
|
||||
jmp __b1
|
||||
// Fill the screen with '*'
|
||||
// main::@1
|
||||
__b1:
|
||||
// [5] if((byte*) main::sc#2<(const nomodify byte*) SCREEN+(word) $7d0) goto main::@2 -- pbuz1_lt_pbuc1_then_la1
|
||||
lda.z sc+1
|
||||
cmp #>SCREEN+$7d0
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z sc
|
||||
cmp #<SCREEN+$7d0
|
||||
bcc __b2
|
||||
!:
|
||||
// [6] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
|
||||
__b3_from___b1:
|
||||
// [6] phi (byte*) main::col#2 = (const nomodify byte*) COLORS [phi:main::@1->main::@3#0] -- pbuz1=pbuc1
|
||||
lda #<COLORS
|
||||
sta.z col
|
||||
lda #>COLORS
|
||||
sta.z col+1
|
||||
jmp __b3
|
||||
// Fill the color memory
|
||||
// main::@3
|
||||
__b3:
|
||||
// [7] if((byte*) main::col#2<(const nomodify byte*) COLORS+(word) $7d0) goto main::@4 -- pbuz1_lt_pbuc1_then_la1
|
||||
lda.z col+1
|
||||
cmp #>COLORS+$7d0
|
||||
bcc __b4
|
||||
bne !+
|
||||
lda.z col
|
||||
cmp #<COLORS+$7d0
|
||||
bcc __b4
|
||||
!:
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [8] return
|
||||
rts
|
||||
// main::@4
|
||||
__b4:
|
||||
// [9] (byte~) main::$2 ← < (byte*) main::col#2 -- vbuz1=_lo_pbuz2
|
||||
lda.z col
|
||||
sta.z __2
|
||||
// [10] *((byte*) main::col#2) ← (byte~) main::$2 -- _deref_pbuz1=vbuz2
|
||||
lda.z __2
|
||||
ldy #0
|
||||
sta (col),y
|
||||
// [11] (byte*) main::col#1 ← ++ (byte*) main::col#2 -- pbuz1=_inc_pbuz1
|
||||
inw.z col
|
||||
// [6] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
|
||||
__b3_from___b4:
|
||||
// [6] phi (byte*) main::col#2 = (byte*) main::col#1 [phi:main::@4->main::@3#0] -- register_copy
|
||||
jmp __b3
|
||||
// main::@2
|
||||
__b2:
|
||||
// [12] *((byte*) main::sc#2) ← (byte) '*' -- _deref_pbuz1=vbuc1
|
||||
lda #'*'
|
||||
ldy #0
|
||||
sta (sc),y
|
||||
// [13] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1
|
||||
inw.z sc
|
||||
// [4] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
__b1_from___b2:
|
||||
// [4] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement asm { sei lda#0 tax tay taz map eom } always clobbers reg byte a reg byte x reg byte y reg byte z
|
||||
Statement [1] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $47 [ ] ( [ ] { } ) always clobbers reg byte a
|
||||
Statement [2] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $53 [ ] ( [ ] { } ) always clobbers reg byte a
|
||||
Statement [3] *((const nomodify to_volatile byte*) IO_BANK) ← *((const nomodify to_volatile byte*) IO_BANK) | (const nomodify byte) CRAM2K [ ] ( [ ] { } ) always clobbers reg byte a
|
||||
Statement [5] if((byte*) main::sc#2<(const nomodify byte*) SCREEN+(word) $7d0) goto main::@2 [ main::sc#2 ] ( [ main::sc#2 ] { } ) always clobbers reg byte a
|
||||
Statement [7] if((byte*) main::col#2<(const nomodify byte*) COLORS+(word) $7d0) goto main::@4 [ main::col#2 ] ( [ main::col#2 ] { } ) always clobbers reg byte a
|
||||
Statement [10] *((byte*) main::col#2) ← (byte~) main::$2 [ main::col#2 ] ( [ main::col#2 ] { } ) always clobbers reg byte y
|
||||
Statement [12] *((byte*) main::sc#2) ← (byte) '*' [ main::sc#2 ] ( [ main::sc#2 ] { } ) always clobbers reg byte a reg byte y
|
||||
Potential registers zp[2]:2 [ main::sc#2 main::sc#1 ] : zp[2]:2 ,
|
||||
Potential registers zp[2]:4 [ main::col#2 main::col#1 ] : zp[2]:4 ,
|
||||
Potential registers zp[1]:6 [ main::$2 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , reg byte z ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 36.67: zp[2]:2 [ main::sc#2 main::sc#1 ] 35.75: zp[2]:4 [ main::col#2 main::col#1 ] 22: zp[1]:6 [ main::$2 ]
|
||||
Uplift Scope [MOS6526_CIA]
|
||||
Uplift Scope [MOS6569_VICII]
|
||||
Uplift Scope [MOS6581_SID]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 1050 combination zp[2]:2 [ main::sc#2 main::sc#1 ] zp[2]:4 [ main::col#2 main::col#1 ] reg byte a [ main::$2 ]
|
||||
Uplifting [MOS6526_CIA] best 1050 combination
|
||||
Uplifting [MOS6569_VICII] best 1050 combination
|
||||
Uplifting [MOS6581_SID] best 1050 combination
|
||||
Uplifting [] best 1050 combination
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
// Hello World for MEGA 65 - putting chars directly to the screen
|
||||
// Upstart
|
||||
.cpu _45gs02
|
||||
.file [name="test-vic4.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$2001]
|
||||
.segmentdef Code [start=$2017]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
.byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0
|
||||
.byte $15, $20, $14, $00, $9e, $20 // 20 SYS
|
||||
.text toIntString(main) // NNNN
|
||||
.byte $00, $00, $00 //
|
||||
// Global Constants & labels
|
||||
// Map 2nd KB of colour RAM $DC00-$DFFF (hiding CIA's)
|
||||
.const CRAM2K = 1
|
||||
// I/O Personality selection
|
||||
.label IO_KEY = $d02f
|
||||
// C65 Banking Register
|
||||
.label IO_BANK = $d030
|
||||
.label SCREEN = $800
|
||||
.label COLORS = $d800
|
||||
.segment Code
|
||||
// main
|
||||
main: {
|
||||
.label sc = 2
|
||||
.label col = 4
|
||||
// asm { sei lda#0 tax tay taz map eom }
|
||||
// Map memory to BANK 0 : 0x00XXXX - giving access to I/O
|
||||
sei
|
||||
lda #0
|
||||
tax
|
||||
tay
|
||||
taz
|
||||
map
|
||||
eom
|
||||
// [1] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $47 -- _deref_pbuc1=vbuc2
|
||||
// Enable the VIC 4
|
||||
lda #$47
|
||||
sta IO_KEY
|
||||
// [2] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $53 -- _deref_pbuc1=vbuc2
|
||||
lda #$53
|
||||
sta IO_KEY
|
||||
// [3] *((const nomodify to_volatile byte*) IO_BANK) ← *((const nomodify to_volatile byte*) IO_BANK) | (const nomodify byte) CRAM2K -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
||||
// Enable 2K Color RAM
|
||||
lda #CRAM2K
|
||||
ora IO_BANK
|
||||
sta IO_BANK
|
||||
// [4] phi from main to main::@1 [phi:main->main::@1]
|
||||
__b1_from_main:
|
||||
// [4] phi (byte*) main::sc#2 = (const nomodify byte*) SCREEN [phi:main->main::@1#0] -- pbuz1=pbuc1
|
||||
lda #<SCREEN
|
||||
sta.z sc
|
||||
lda #>SCREEN
|
||||
sta.z sc+1
|
||||
jmp __b1
|
||||
// Fill the screen with '*'
|
||||
// main::@1
|
||||
__b1:
|
||||
// [5] if((byte*) main::sc#2<(const nomodify byte*) SCREEN+(word) $7d0) goto main::@2 -- pbuz1_lt_pbuc1_then_la1
|
||||
lda.z sc+1
|
||||
cmp #>SCREEN+$7d0
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z sc
|
||||
cmp #<SCREEN+$7d0
|
||||
bcc __b2
|
||||
!:
|
||||
// [6] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
|
||||
__b3_from___b1:
|
||||
// [6] phi (byte*) main::col#2 = (const nomodify byte*) COLORS [phi:main::@1->main::@3#0] -- pbuz1=pbuc1
|
||||
lda #<COLORS
|
||||
sta.z col
|
||||
lda #>COLORS
|
||||
sta.z col+1
|
||||
jmp __b3
|
||||
// Fill the color memory
|
||||
// main::@3
|
||||
__b3:
|
||||
// [7] if((byte*) main::col#2<(const nomodify byte*) COLORS+(word) $7d0) goto main::@4 -- pbuz1_lt_pbuc1_then_la1
|
||||
lda.z col+1
|
||||
cmp #>COLORS+$7d0
|
||||
bcc __b4
|
||||
bne !+
|
||||
lda.z col
|
||||
cmp #<COLORS+$7d0
|
||||
bcc __b4
|
||||
!:
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [8] return
|
||||
rts
|
||||
// main::@4
|
||||
__b4:
|
||||
// [9] (byte~) main::$2 ← < (byte*) main::col#2 -- vbuaa=_lo_pbuz1
|
||||
lda.z col
|
||||
// [10] *((byte*) main::col#2) ← (byte~) main::$2 -- _deref_pbuz1=vbuaa
|
||||
ldy #0
|
||||
sta (col),y
|
||||
// [11] (byte*) main::col#1 ← ++ (byte*) main::col#2 -- pbuz1=_inc_pbuz1
|
||||
inw.z col
|
||||
// [6] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
|
||||
__b3_from___b4:
|
||||
// [6] phi (byte*) main::col#2 = (byte*) main::col#1 [phi:main::@4->main::@3#0] -- register_copy
|
||||
jmp __b3
|
||||
// main::@2
|
||||
__b2:
|
||||
// [12] *((byte*) main::sc#2) ← (byte) '*' -- _deref_pbuz1=vbuc1
|
||||
lda #'*'
|
||||
ldy #0
|
||||
sta (sc),y
|
||||
// [13] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1
|
||||
inw.z sc
|
||||
// [4] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
__b1_from___b2:
|
||||
// [4] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __b3
|
||||
Removing instruction jmp __breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction __b1_from_main:
|
||||
Removing instruction __b3_from___b1:
|
||||
Removing instruction __breturn:
|
||||
Removing instruction __b3_from___b4:
|
||||
Removing instruction __b1_from___b2:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(const nomodify byte*) COLORS = (byte*) 55296
|
||||
(const nomodify byte) CRAM2K = (byte) 1
|
||||
(const nomodify to_volatile byte*) IO_BANK = (byte*) 53296
|
||||
(const nomodify to_volatile byte*) IO_KEY = (byte*) 53295
|
||||
(byte) MOS6526_CIA::INTERRUPT
|
||||
(byte) MOS6526_CIA::PORT_A
|
||||
(byte) MOS6526_CIA::PORT_A_DDR
|
||||
(byte) MOS6526_CIA::PORT_B
|
||||
(byte) MOS6526_CIA::PORT_B_DDR
|
||||
(byte) MOS6526_CIA::SERIAL_DATA
|
||||
(word) MOS6526_CIA::TIMER_A
|
||||
(byte) MOS6526_CIA::TIMER_A_CONTROL
|
||||
(word) MOS6526_CIA::TIMER_B
|
||||
(byte) MOS6526_CIA::TIMER_B_CONTROL
|
||||
(byte) MOS6526_CIA::TOD_10THS
|
||||
(byte) MOS6526_CIA::TOD_HOURS
|
||||
(byte) MOS6526_CIA::TOD_MIN
|
||||
(byte) MOS6526_CIA::TOD_SEC
|
||||
(byte) MOS6569_VICII::BG_COLOR
|
||||
(byte) MOS6569_VICII::BG_COLOR1
|
||||
(byte) MOS6569_VICII::BG_COLOR2
|
||||
(byte) MOS6569_VICII::BG_COLOR3
|
||||
(byte) MOS6569_VICII::BORDER_COLOR
|
||||
(byte) MOS6569_VICII::CONTROL1
|
||||
(byte) MOS6569_VICII::CONTROL2
|
||||
(byte) MOS6569_VICII::IRQ_ENABLE
|
||||
(byte) MOS6569_VICII::IRQ_STATUS
|
||||
(byte) MOS6569_VICII::LIGHTPEN_X
|
||||
(byte) MOS6569_VICII::LIGHTPEN_Y
|
||||
(byte) MOS6569_VICII::MEMORY
|
||||
(byte) MOS6569_VICII::RASTER
|
||||
(byte) MOS6569_VICII::SPRITE0_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE0_X
|
||||
(byte) MOS6569_VICII::SPRITE0_Y
|
||||
(byte) MOS6569_VICII::SPRITE1_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE1_X
|
||||
(byte) MOS6569_VICII::SPRITE1_Y
|
||||
(byte) MOS6569_VICII::SPRITE2_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE2_X
|
||||
(byte) MOS6569_VICII::SPRITE2_Y
|
||||
(byte) MOS6569_VICII::SPRITE3_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE3_X
|
||||
(byte) MOS6569_VICII::SPRITE3_Y
|
||||
(byte) MOS6569_VICII::SPRITE4_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE4_X
|
||||
(byte) MOS6569_VICII::SPRITE4_Y
|
||||
(byte) MOS6569_VICII::SPRITE5_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE5_X
|
||||
(byte) MOS6569_VICII::SPRITE5_Y
|
||||
(byte) MOS6569_VICII::SPRITE6_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE6_X
|
||||
(byte) MOS6569_VICII::SPRITE6_Y
|
||||
(byte) MOS6569_VICII::SPRITE7_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE7_X
|
||||
(byte) MOS6569_VICII::SPRITE7_Y
|
||||
(byte) MOS6569_VICII::SPRITES_BG_COLLISION
|
||||
(byte) MOS6569_VICII::SPRITES_COLLISION
|
||||
(byte) MOS6569_VICII::SPRITES_ENABLE
|
||||
(byte) MOS6569_VICII::SPRITES_EXPAND_X
|
||||
(byte) MOS6569_VICII::SPRITES_EXPAND_Y
|
||||
(byte) MOS6569_VICII::SPRITES_MC
|
||||
(byte) MOS6569_VICII::SPRITES_MCOLOR1
|
||||
(byte) MOS6569_VICII::SPRITES_MCOLOR2
|
||||
(byte) MOS6569_VICII::SPRITES_PRIORITY
|
||||
(byte) MOS6569_VICII::SPRITES_XMSB
|
||||
(byte) MOS6581_SID::CH1_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH1_CONTROL
|
||||
(word) MOS6581_SID::CH1_FREQ
|
||||
(word) MOS6581_SID::CH1_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::CH2_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH2_CONTROL
|
||||
(word) MOS6581_SID::CH2_FREQ
|
||||
(word) MOS6581_SID::CH2_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::CH3_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH3_CONTROL
|
||||
(byte) MOS6581_SID::CH3_ENV
|
||||
(word) MOS6581_SID::CH3_FREQ
|
||||
(byte) MOS6581_SID::CH3_OSC
|
||||
(word) MOS6581_SID::CH3_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::FILTER_CUTOFF_HIGH
|
||||
(byte) MOS6581_SID::FILTER_CUTOFF_LOW
|
||||
(byte) MOS6581_SID::FILTER_SETUP
|
||||
(byte) MOS6581_SID::POT_X
|
||||
(byte) MOS6581_SID::POT_Y
|
||||
(byte) MOS6581_SID::VOLUME_FILTER_MODE
|
||||
(const nomodify byte*) SCREEN = (byte*) 2048
|
||||
(void()) main()
|
||||
(byte~) main::$2 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@4
|
||||
(label) main::@return
|
||||
(byte*) main::col
|
||||
(byte*) main::col#1 col zp[2]:4 22.0
|
||||
(byte*) main::col#2 col zp[2]:4 13.75
|
||||
(byte*) main::sc
|
||||
(byte*) main::sc#1 sc zp[2]:2 22.0
|
||||
(byte*) main::sc#2 sc zp[2]:2 14.666666666666666
|
||||
|
||||
zp[2]:2 [ main::sc#2 main::sc#1 ]
|
||||
zp[2]:4 [ main::col#2 main::col#1 ]
|
||||
reg byte a [ main::$2 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 960
|
||||
|
||||
// File Comments
|
||||
// Hello World for MEGA 65 - putting chars directly to the screen
|
||||
// Upstart
|
||||
.cpu _45gs02
|
||||
.file [name="test-vic4.prg", type="prg", segments="Program"]
|
||||
.segmentdef Program [segments="Basic, Code, Data"]
|
||||
.segmentdef Basic [start=$2001]
|
||||
.segmentdef Code [start=$2017]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segment Basic
|
||||
.byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0
|
||||
.byte $15, $20, $14, $00, $9e, $20 // 20 SYS
|
||||
.text toIntString(main) // NNNN
|
||||
.byte $00, $00, $00 //
|
||||
// Global Constants & labels
|
||||
// Map 2nd KB of colour RAM $DC00-$DFFF (hiding CIA's)
|
||||
.const CRAM2K = 1
|
||||
// I/O Personality selection
|
||||
.label IO_KEY = $d02f
|
||||
// C65 Banking Register
|
||||
.label IO_BANK = $d030
|
||||
.label SCREEN = $800
|
||||
.label COLORS = $d800
|
||||
.segment Code
|
||||
// main
|
||||
main: {
|
||||
.label sc = 2
|
||||
.label col = 4
|
||||
// asm
|
||||
// asm { sei lda#0 tax tay taz map eom }
|
||||
// Map memory to BANK 0 : 0x00XXXX - giving access to I/O
|
||||
sei
|
||||
lda #0
|
||||
tax
|
||||
tay
|
||||
taz
|
||||
map
|
||||
eom
|
||||
// *IO_KEY = 0x47
|
||||
// [1] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $47 -- _deref_pbuc1=vbuc2
|
||||
// Enable the VIC 4
|
||||
lda #$47
|
||||
sta IO_KEY
|
||||
// *IO_KEY = 0x53
|
||||
// [2] *((const nomodify to_volatile byte*) IO_KEY) ← (byte) $53 -- _deref_pbuc1=vbuc2
|
||||
lda #$53
|
||||
sta IO_KEY
|
||||
// *IO_BANK |= CRAM2K
|
||||
// [3] *((const nomodify to_volatile byte*) IO_BANK) ← *((const nomodify to_volatile byte*) IO_BANK) | (const nomodify byte) CRAM2K -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
||||
// Enable 2K Color RAM
|
||||
lda #CRAM2K
|
||||
ora IO_BANK
|
||||
sta IO_BANK
|
||||
// [4] phi from main to main::@1 [phi:main->main::@1]
|
||||
// [4] phi (byte*) main::sc#2 = (const nomodify byte*) SCREEN [phi:main->main::@1#0] -- pbuz1=pbuc1
|
||||
lda #<SCREEN
|
||||
sta.z sc
|
||||
lda #>SCREEN
|
||||
sta.z sc+1
|
||||
// Fill the screen with '*'
|
||||
// main::@1
|
||||
__b1:
|
||||
// for( char *sc = SCREEN; sc<SCREEN+2000; sc++)
|
||||
// [5] if((byte*) main::sc#2<(const nomodify byte*) SCREEN+(word) $7d0) goto main::@2 -- pbuz1_lt_pbuc1_then_la1
|
||||
lda.z sc+1
|
||||
cmp #>SCREEN+$7d0
|
||||
bcc __b2
|
||||
bne !+
|
||||
lda.z sc
|
||||
cmp #<SCREEN+$7d0
|
||||
bcc __b2
|
||||
!:
|
||||
// [6] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
|
||||
// [6] phi (byte*) main::col#2 = (const nomodify byte*) COLORS [phi:main::@1->main::@3#0] -- pbuz1=pbuc1
|
||||
lda #<COLORS
|
||||
sta.z col
|
||||
lda #>COLORS
|
||||
sta.z col+1
|
||||
// Fill the color memory
|
||||
// main::@3
|
||||
__b3:
|
||||
// for( char *col = COLORS; col<COLORS+2000; col++)
|
||||
// [7] if((byte*) main::col#2<(const nomodify byte*) COLORS+(word) $7d0) goto main::@4 -- pbuz1_lt_pbuc1_then_la1
|
||||
lda.z col+1
|
||||
cmp #>COLORS+$7d0
|
||||
bcc __b4
|
||||
bne !+
|
||||
lda.z col
|
||||
cmp #<COLORS+$7d0
|
||||
bcc __b4
|
||||
!:
|
||||
// main::@return
|
||||
// }
|
||||
// [8] return
|
||||
rts
|
||||
// main::@4
|
||||
__b4:
|
||||
// <col
|
||||
// [9] (byte~) main::$2 ← < (byte*) main::col#2 -- vbuaa=_lo_pbuz1
|
||||
lda.z col
|
||||
// *col = <col
|
||||
// [10] *((byte*) main::col#2) ← (byte~) main::$2 -- _deref_pbuz1=vbuaa
|
||||
ldy #0
|
||||
sta (col),y
|
||||
// for( char *col = COLORS; col<COLORS+2000; col++)
|
||||
// [11] (byte*) main::col#1 ← ++ (byte*) main::col#2 -- pbuz1=_inc_pbuz1
|
||||
inw.z col
|
||||
// [6] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
|
||||
// [6] phi (byte*) main::col#2 = (byte*) main::col#1 [phi:main::@4->main::@3#0] -- register_copy
|
||||
jmp __b3
|
||||
// main::@2
|
||||
__b2:
|
||||
// *sc = '*'
|
||||
// [12] *((byte*) main::sc#2) ← (byte) '*' -- _deref_pbuz1=vbuc1
|
||||
lda #'*'
|
||||
ldy #0
|
||||
sta (sc),y
|
||||
// for( char *sc = SCREEN; sc<SCREEN+2000; sc++)
|
||||
// [13] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1
|
||||
inw.z sc
|
||||
// [4] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
// [4] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
|
106
src/test/ref/examples/mega65/test-vic4.sym
Normal file
106
src/test/ref/examples/mega65/test-vic4.sym
Normal file
@ -0,0 +1,106 @@
|
||||
(const nomodify byte*) COLORS = (byte*) 55296
|
||||
(const nomodify byte) CRAM2K = (byte) 1
|
||||
(const nomodify to_volatile byte*) IO_BANK = (byte*) 53296
|
||||
(const nomodify to_volatile byte*) IO_KEY = (byte*) 53295
|
||||
(byte) MOS6526_CIA::INTERRUPT
|
||||
(byte) MOS6526_CIA::PORT_A
|
||||
(byte) MOS6526_CIA::PORT_A_DDR
|
||||
(byte) MOS6526_CIA::PORT_B
|
||||
(byte) MOS6526_CIA::PORT_B_DDR
|
||||
(byte) MOS6526_CIA::SERIAL_DATA
|
||||
(word) MOS6526_CIA::TIMER_A
|
||||
(byte) MOS6526_CIA::TIMER_A_CONTROL
|
||||
(word) MOS6526_CIA::TIMER_B
|
||||
(byte) MOS6526_CIA::TIMER_B_CONTROL
|
||||
(byte) MOS6526_CIA::TOD_10THS
|
||||
(byte) MOS6526_CIA::TOD_HOURS
|
||||
(byte) MOS6526_CIA::TOD_MIN
|
||||
(byte) MOS6526_CIA::TOD_SEC
|
||||
(byte) MOS6569_VICII::BG_COLOR
|
||||
(byte) MOS6569_VICII::BG_COLOR1
|
||||
(byte) MOS6569_VICII::BG_COLOR2
|
||||
(byte) MOS6569_VICII::BG_COLOR3
|
||||
(byte) MOS6569_VICII::BORDER_COLOR
|
||||
(byte) MOS6569_VICII::CONTROL1
|
||||
(byte) MOS6569_VICII::CONTROL2
|
||||
(byte) MOS6569_VICII::IRQ_ENABLE
|
||||
(byte) MOS6569_VICII::IRQ_STATUS
|
||||
(byte) MOS6569_VICII::LIGHTPEN_X
|
||||
(byte) MOS6569_VICII::LIGHTPEN_Y
|
||||
(byte) MOS6569_VICII::MEMORY
|
||||
(byte) MOS6569_VICII::RASTER
|
||||
(byte) MOS6569_VICII::SPRITE0_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE0_X
|
||||
(byte) MOS6569_VICII::SPRITE0_Y
|
||||
(byte) MOS6569_VICII::SPRITE1_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE1_X
|
||||
(byte) MOS6569_VICII::SPRITE1_Y
|
||||
(byte) MOS6569_VICII::SPRITE2_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE2_X
|
||||
(byte) MOS6569_VICII::SPRITE2_Y
|
||||
(byte) MOS6569_VICII::SPRITE3_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE3_X
|
||||
(byte) MOS6569_VICII::SPRITE3_Y
|
||||
(byte) MOS6569_VICII::SPRITE4_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE4_X
|
||||
(byte) MOS6569_VICII::SPRITE4_Y
|
||||
(byte) MOS6569_VICII::SPRITE5_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE5_X
|
||||
(byte) MOS6569_VICII::SPRITE5_Y
|
||||
(byte) MOS6569_VICII::SPRITE6_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE6_X
|
||||
(byte) MOS6569_VICII::SPRITE6_Y
|
||||
(byte) MOS6569_VICII::SPRITE7_COLOR
|
||||
(byte) MOS6569_VICII::SPRITE7_X
|
||||
(byte) MOS6569_VICII::SPRITE7_Y
|
||||
(byte) MOS6569_VICII::SPRITES_BG_COLLISION
|
||||
(byte) MOS6569_VICII::SPRITES_COLLISION
|
||||
(byte) MOS6569_VICII::SPRITES_ENABLE
|
||||
(byte) MOS6569_VICII::SPRITES_EXPAND_X
|
||||
(byte) MOS6569_VICII::SPRITES_EXPAND_Y
|
||||
(byte) MOS6569_VICII::SPRITES_MC
|
||||
(byte) MOS6569_VICII::SPRITES_MCOLOR1
|
||||
(byte) MOS6569_VICII::SPRITES_MCOLOR2
|
||||
(byte) MOS6569_VICII::SPRITES_PRIORITY
|
||||
(byte) MOS6569_VICII::SPRITES_XMSB
|
||||
(byte) MOS6581_SID::CH1_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH1_CONTROL
|
||||
(word) MOS6581_SID::CH1_FREQ
|
||||
(word) MOS6581_SID::CH1_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::CH2_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH2_CONTROL
|
||||
(word) MOS6581_SID::CH2_FREQ
|
||||
(word) MOS6581_SID::CH2_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::CH3_ATTACK_DECAY
|
||||
(byte) MOS6581_SID::CH3_CONTROL
|
||||
(byte) MOS6581_SID::CH3_ENV
|
||||
(word) MOS6581_SID::CH3_FREQ
|
||||
(byte) MOS6581_SID::CH3_OSC
|
||||
(word) MOS6581_SID::CH3_PULSE_WIDTH
|
||||
(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE
|
||||
(byte) MOS6581_SID::FILTER_CUTOFF_HIGH
|
||||
(byte) MOS6581_SID::FILTER_CUTOFF_LOW
|
||||
(byte) MOS6581_SID::FILTER_SETUP
|
||||
(byte) MOS6581_SID::POT_X
|
||||
(byte) MOS6581_SID::POT_Y
|
||||
(byte) MOS6581_SID::VOLUME_FILTER_MODE
|
||||
(const nomodify byte*) SCREEN = (byte*) 2048
|
||||
(void()) main()
|
||||
(byte~) main::$2 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@4
|
||||
(label) main::@return
|
||||
(byte*) main::col
|
||||
(byte*) main::col#1 col zp[2]:4 22.0
|
||||
(byte*) main::col#2 col zp[2]:4 13.75
|
||||
(byte*) main::sc
|
||||
(byte*) main::sc#1 sc zp[2]:2 22.0
|
||||
(byte*) main::sc#2 sc zp[2]:2 14.666666666666666
|
||||
|
||||
zp[2]:2 [ main::sc#2 main::sc#1 ]
|
||||
zp[2]:4 [ main::col#2 main::col#1 ]
|
||||
reg byte a [ main::$2 ]
|
Loading…
Reference in New Issue
Block a user