From bd1c4bcd13eb635c85143bde17c5c6fedb7e7b65 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 9 Aug 2020 23:01:57 +0200 Subject: [PATCH] Working on MEGA65 platform target. #507 --- .../examples/mega65/32bit-addressing-mega65.c | 5 +- .../mega65/32bit-addressing-mega65.asm | 12 +++-- .../mega65/32bit-addressing-mega65.cfg | 2 +- .../mega65/32bit-addressing-mega65.log | 50 ++++++++++--------- .../mega65/32bit-addressing-mega65.sym | 1 + 5 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/test/kc/examples/mega65/32bit-addressing-mega65.c b/src/test/kc/examples/mega65/32bit-addressing-mega65.c index f3f851a93..63f75067f 100644 --- a/src/test/kc/examples/mega65/32bit-addressing-mega65.c +++ b/src/test/kc/examples/mega65/32bit-addressing-mega65.c @@ -4,9 +4,12 @@ // Absolute 32-bit address to use for storing/loading data volatile __zp unsigned long ADDR32; +// The address of the coloir RAM in MEGA65 main memory +const unsigned long MEGA65_MEM_COLOR_RAM = 0xff80000; + void main() { // Modify Color Ram using 32-bit addressing - ADDR32 = 0xff80000; + ADDR32 = MEGA65_MEM_COLOR_RAM; asm { ldz #0 !: diff --git a/src/test/ref/examples/mega65/32bit-addressing-mega65.asm b/src/test/ref/examples/mega65/32bit-addressing-mega65.asm index 09aec8756..fbc1d1679 100644 --- a/src/test/ref/examples/mega65/32bit-addressing-mega65.asm +++ b/src/test/ref/examples/mega65/32bit-addressing-mega65.asm @@ -10,6 +10,8 @@ .byte $15, $20, $14, $00, $9e, $20 // 20 SYS .text toIntString(__start) // NNNN .byte $00, $00, $00 // + // The address of the coloir RAM in MEGA65 main memory + .const MEGA65_MEM_COLOR_RAM = $ff80000 // Absolute 32-bit address to use for storing/loading data .label ADDR32 = 2 .segment Code @@ -26,15 +28,15 @@ __start: { rts } main: { - // ADDR32 = 0xff80000 + // ADDR32 = MEGA65_MEM_COLOR_RAM // Modify Color Ram using 32-bit addressing - lda #<$ff80000 + lda #$ff80000 + lda #>MEGA65_MEM_COLOR_RAM sta.z ADDR32+1 - lda #<$ff80000>>$10 + lda #>$10 sta.z ADDR32+2 - lda #>$ff80000>>$10 + lda #>MEGA65_MEM_COLOR_RAM>>$10 sta.z ADDR32+3 // asm ldz #0 diff --git a/src/test/ref/examples/mega65/32bit-addressing-mega65.cfg b/src/test/ref/examples/mega65/32bit-addressing-mega65.cfg index bdb81ad8a..ff51dd0b3 100644 --- a/src/test/ref/examples/mega65/32bit-addressing-mega65.cfg +++ b/src/test/ref/examples/mega65/32bit-addressing-mega65.cfg @@ -16,7 +16,7 @@ __start::@return: scope:[__start] from __start::@1 (void()) main() main: scope:[main] from __start::@1 - [5] (volatile dword) ADDR32 ← (dword) $ff80000 + [5] (volatile dword) ADDR32 ← (const nomodify dword) MEGA65_MEM_COLOR_RAM asm { ldz#0 !: tza sta((ADDR32)),z inz cpz#80 bne!- } [7] (volatile dword) ADDR32 ← (word) $800 asm { lda#'*' ldz#79 !: sta((ADDR32)),z dez bpl!- } diff --git a/src/test/ref/examples/mega65/32bit-addressing-mega65.log b/src/test/ref/examples/mega65/32bit-addressing-mega65.log index 30861c723..c3982c3b4 100644 --- a/src/test/ref/examples/mega65/32bit-addressing-mega65.log +++ b/src/test/ref/examples/mega65/32bit-addressing-mega65.log @@ -4,7 +4,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from __start::@1 - (volatile dword) ADDR32 ← (number) $ff80000 + (volatile dword) ADDR32 ← (const nomodify dword) MEGA65_MEM_COLOR_RAM asm { ldz#0 !: tza sta((ADDR32)),z inz cpz#80 bne!- } (volatile dword) ADDR32 ← (number) $800 asm { lda#'*' ldz#79 !: sta((ADDR32)),z dez bpl!- } @@ -30,6 +30,7 @@ __start::@return: scope:[__start] from __start::@2 SYMBOL TABLE SSA (volatile dword) ADDR32 loadstore +(const nomodify dword) MEGA65_MEM_COLOR_RAM = (dword) $ff80000 (void()) __start() (label) __start::@1 (label) __start::@2 @@ -38,16 +39,12 @@ SYMBOL TABLE SSA (void()) main() (label) main::@return -Adding number conversion cast (unumber) $ff80000 in (volatile dword) ADDR32 ← (number) $ff80000 Adding number conversion cast (unumber) $800 in (volatile dword) ADDR32 ← (number) $800 Successful SSA optimization PassNAddNumberTypeConversions -Inlining cast (volatile dword) ADDR32 ← (unumber)(number) $ff80000 Inlining cast (volatile dword) ADDR32 ← (unumber)(number) $800 Successful SSA optimization Pass2InlineCast -Simplifying constant integer cast $ff80000 Simplifying constant integer cast $800 Successful SSA optimization PassNCastSimplification -Finalized unsigned number type (dword) $ff80000 Finalized unsigned number type (word) $800 Successful SSA optimization PassNFinalizeNumberTypeConversions Adding NOP phi() at start of __start @@ -81,7 +78,7 @@ __start::@return: scope:[__start] from __start::@1 (void()) main() main: scope:[main] from __start::@1 - [5] (volatile dword) ADDR32 ← (dword) $ff80000 + [5] (volatile dword) ADDR32 ← (const nomodify dword) MEGA65_MEM_COLOR_RAM asm { ldz#0 !: tza sta((ADDR32)),z inz cpz#80 bne!- } [7] (volatile dword) ADDR32 ← (word) $800 asm { lda#'*' ldz#79 !: sta((ADDR32)),z dez bpl!- } @@ -119,6 +116,8 @@ Target platform is mega65 / MEGA45GS02 .text toIntString(__start) // NNNN .byte $00, $00, $00 // // Global Constants & labels + // The address of the coloir RAM in MEGA65 main memory + .const MEGA65_MEM_COLOR_RAM = $ff80000 // Absolute 32-bit address to use for storing/loading data .label ADDR32 = 2 .segment Code @@ -151,15 +150,15 @@ __start: { } // main main: { - // [5] (volatile dword) ADDR32 ← (dword) $ff80000 -- vduz1=vduc1 + // [5] (volatile dword) ADDR32 ← (const nomodify dword) MEGA65_MEM_COLOR_RAM -- vduz1=vduc1 // Modify Color Ram using 32-bit addressing - lda #<$ff80000 + lda #$ff80000 + lda #>MEGA65_MEM_COLOR_RAM sta.z ADDR32+1 - lda #<$ff80000>>$10 + lda #>$10 sta.z ADDR32+2 - lda #>$ff80000>>$10 + lda #>MEGA65_MEM_COLOR_RAM>>$10 sta.z ADDR32+3 // asm { ldz#0 !: tza sta((ADDR32)),z inz cpz#80 bne!- } ldz #0 @@ -196,7 +195,7 @@ main: { REGISTER UPLIFT POTENTIAL REGISTERS Statement [1] (volatile dword) ADDR32 ← (dword) 0 [ ] ( [ ] { } ) always clobbers reg byte a -Statement [5] (volatile dword) ADDR32 ← (dword) $ff80000 [ ADDR32 ] ( main:3 [ ADDR32 ] { } ) always clobbers reg byte a +Statement [5] (volatile dword) ADDR32 ← (const nomodify dword) MEGA65_MEM_COLOR_RAM [ ADDR32 ] ( main:3 [ ADDR32 ] { } ) always clobbers reg byte a Statement asm { ldz#0 !: tza sta((ADDR32)),z inz cpz#80 bne!- } always clobbers reg byte a reg byte z Statement [7] (volatile dword) ADDR32 ← (word) $800 [ ADDR32 ] ( main:3 [ ADDR32 ] { } ) always clobbers reg byte a Statement asm { lda#'*' ldz#79 !: sta((ADDR32)),z dez bpl!- } always clobbers reg byte a reg byte z @@ -227,6 +226,8 @@ ASSEMBLER BEFORE OPTIMIZATION .text toIntString(__start) // NNNN .byte $00, $00, $00 // // Global Constants & labels + // The address of the coloir RAM in MEGA65 main memory + .const MEGA65_MEM_COLOR_RAM = $ff80000 // Absolute 32-bit address to use for storing/loading data .label ADDR32 = 2 .segment Code @@ -259,15 +260,15 @@ __start: { } // main main: { - // [5] (volatile dword) ADDR32 ← (dword) $ff80000 -- vduz1=vduc1 + // [5] (volatile dword) ADDR32 ← (const nomodify dword) MEGA65_MEM_COLOR_RAM -- vduz1=vduc1 // Modify Color Ram using 32-bit addressing - lda #<$ff80000 + lda #$ff80000 + lda #>MEGA65_MEM_COLOR_RAM sta.z ADDR32+1 - lda #<$ff80000>>$10 + lda #>$10 sta.z ADDR32+2 - lda #>$ff80000>>$10 + lda #>MEGA65_MEM_COLOR_RAM>>$10 sta.z ADDR32+3 // asm { ldz#0 !: tza sta((ADDR32)),z inz cpz#80 bne!- } ldz #0 @@ -320,6 +321,7 @@ Succesful ASM optimization Pass5UnusedLabelElimination FINAL SYMBOL TABLE (volatile dword) ADDR32 loadstore zp[4]:2 12.0 +(const nomodify dword) MEGA65_MEM_COLOR_RAM = (dword) $ff80000 (void()) __start() (label) __start::@1 (label) __start::@return @@ -348,6 +350,8 @@ Score: 107 .text toIntString(__start) // NNNN .byte $00, $00, $00 // // Global Constants & labels + // The address of the coloir RAM in MEGA65 main memory + .const MEGA65_MEM_COLOR_RAM = $ff80000 // Absolute 32-bit address to use for storing/loading data .label ADDR32 = 2 .segment Code @@ -373,16 +377,16 @@ __start: { } // main main: { - // ADDR32 = 0xff80000 - // [5] (volatile dword) ADDR32 ← (dword) $ff80000 -- vduz1=vduc1 + // ADDR32 = MEGA65_MEM_COLOR_RAM + // [5] (volatile dword) ADDR32 ← (const nomodify dword) MEGA65_MEM_COLOR_RAM -- vduz1=vduc1 // Modify Color Ram using 32-bit addressing - lda #<$ff80000 + lda #$ff80000 + lda #>MEGA65_MEM_COLOR_RAM sta.z ADDR32+1 - lda #<$ff80000>>$10 + lda #>$10 sta.z ADDR32+2 - lda #>$ff80000>>$10 + lda #>MEGA65_MEM_COLOR_RAM>>$10 sta.z ADDR32+3 // asm // asm { ldz#0 !: tza sta((ADDR32)),z inz cpz#80 bne!- } diff --git a/src/test/ref/examples/mega65/32bit-addressing-mega65.sym b/src/test/ref/examples/mega65/32bit-addressing-mega65.sym index 3a127b12a..1ca281be9 100644 --- a/src/test/ref/examples/mega65/32bit-addressing-mega65.sym +++ b/src/test/ref/examples/mega65/32bit-addressing-mega65.sym @@ -1,4 +1,5 @@ (volatile dword) ADDR32 loadstore zp[4]:2 12.0 +(const nomodify dword) MEGA65_MEM_COLOR_RAM = (dword) $ff80000 (void()) __start() (label) __start::@1 (label) __start::@return