1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-07 22:37:23 +00:00

Fixed ATASCII newline encoding. Closes #526

This commit is contained in:
jespergravgaard 2020-09-29 02:05:57 +02:00
parent 62e61d0ec3
commit 5831e8ac26
7 changed files with 229 additions and 1 deletions

View File

@ -14,7 +14,7 @@ public enum StringEncoding {
SCREENCODE_MIXED("screencode_mixed", "screencode_mixed", "sm", CharToPetsciiConverter.charToScreenCode_mixed),
SCREENCODE_UPPER("screencode_upper", "screencode_upper", "su", CharToPetsciiConverter.charToScreenCode_upper),
ASCII("ascii", "ascii", "as", CharToPetsciiConverter.charToAscii),
ATASCII("atascii", "ascii", "at", CharToAtasciiConverter.charToAtascii),
ATASCII("atascii", null, "at", CharToAtasciiConverter.charToAtascii),
SCREENCODE_ATARI("screencode_atari", null, "sa", CharToAtasciiConverter.charToScreenCodeAtari)
;

View File

@ -1395,6 +1395,11 @@ public class TestPrograms {
compileAndCompare("examples/nmisamples/nmisamples.c");
}
@Test
public void testEncodingAtascii() throws IOException, URISyntaxException {
compileAndCompare("encoding-atascii.c");
}
@Test
public void testEncodingLiteralChar() throws IOException, URISyntaxException {
compileAndCompare("encoding-literal-char.c");

View File

@ -0,0 +1,10 @@
// Tests ATASCII encoding
#pragma encoding(atascii)
char TEXT[] = "hello, world!\n";
char * SCREEN = 0x0400;
void main() {
SCREEN[0] = TEXT[13];
}

View File

@ -0,0 +1,15 @@
// Tests ATASCII encoding
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label SCREEN = $400
main: {
// SCREEN[0] = TEXT[13]
lda TEXT+$d
sta SCREEN
// }
rts
}
.encoding "ascii"
TEXT: .text @"hello, world!\$9b"
.byte 0

View File

@ -0,0 +1,8 @@
(void()) main()
main: scope:[main] from
[0] *((const byte*) SCREEN) ← *((const byte*) TEXT+(byte) $d)
to:main::@return
main::@return: scope:[main] from main
[1] return
to:@return

View File

@ -0,0 +1,184 @@
Inlined call call __init
CONTROL FLOW GRAPH SSA
(void()) main()
main: scope:[main] from __start::@1
*((const byte*) SCREEN + (number) 0) ← *((const byte*) TEXT + (number) $d)
to:main::@return
main::@return: scope:[main] from main
return
to:@return
(void()) __start()
__start: scope:[__start] from
to:__start::__init1
__start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
__start::@return: scope:[__start] from __start::@2
return
to:@return
SYMBOL TABLE SSA
(const byte*) SCREEN = (byte*)(number) $400
(const byte*) TEXT[] = (byte*) "hello, world!
"at
(void()) __start()
(label) __start::@1
(label) __start::@2
(label) __start::@return
(label) __start::__init1
(void()) main()
(label) main::@return
Adding number conversion cast (unumber) $d in *((const byte*) SCREEN + (number) 0) ← *((const byte*) TEXT + (number) $d)
Adding number conversion cast (unumber) 0 in *((const byte*) SCREEN + (number) 0) ← *((const byte*) TEXT + (unumber)(number) $d)
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $d
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $d
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero SCREEN in [0] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) TEXT + (byte) $d)
Successful SSA optimization PassNSimplifyExpressionWithZero
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Consolidated array index constant in *(TEXT+$d)
Successful SSA optimization Pass2ConstantAdditionElimination
CALL GRAPH
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
FINAL CONTROL FLOW GRAPH
(void()) main()
main: scope:[main] from
[0] *((const byte*) SCREEN) ← *((const byte*) TEXT+(byte) $d)
to:main::@return
main::@return: scope:[main] from main
[1] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Tests ATASCII encoding
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// main
main: {
// [0] *((const byte*) SCREEN) ← *((const byte*) TEXT+(byte) $d) -- _deref_pbuc1=_deref_pbuc2
lda TEXT+$d
sta SCREEN
jmp __breturn
// main::@return
__breturn:
// [1] return
rts
}
// File Data
.encoding "ascii"
TEXT: .text @"hello, world!\$9b"
.byte 0
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *((const byte*) SCREEN) ← *((const byte*) TEXT+(byte) $d) [ ] ( [ ] { } ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [main]
Uplift Scope []
Uplifting [main] best 17 combination
Uplifting [] best 17 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Tests ATASCII encoding
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// main
main: {
// [0] *((const byte*) SCREEN) ← *((const byte*) TEXT+(byte) $d) -- _deref_pbuc1=_deref_pbuc2
lda TEXT+$d
sta SCREEN
jmp __breturn
// main::@return
__breturn:
// [1] return
rts
}
// File Data
.encoding "ascii"
TEXT: .text @"hello, world!\$9b"
.byte 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(const byte*) SCREEN = (byte*) 1024
(const byte*) TEXT[] = (byte*) "hello, world!
"at
(void()) main()
(label) main::@return
FINAL ASSEMBLER
Score: 14
// File Comments
// Tests ATASCII encoding
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// main
main: {
// SCREEN[0] = TEXT[13]
// [0] *((const byte*) SCREEN) ← *((const byte*) TEXT+(byte) $d) -- _deref_pbuc1=_deref_pbuc2
lda TEXT+$d
sta SCREEN
// main::@return
// }
// [1] return
rts
}
// File Data
.encoding "ascii"
TEXT: .text @"hello, world!\$9b"
.byte 0

View File

@ -0,0 +1,6 @@
(const byte*) SCREEN = (byte*) 1024
(const byte*) TEXT[] = (byte*) "hello, world!
"at
(void()) main()
(label) main::@return