diff --git a/src/main/kc/stdlib/stdlib.kc b/src/main/kc/stdlib/stdlib.kc index 312d71dfa..aa0f89565 100644 --- a/src/main/kc/stdlib/stdlib.kc +++ b/src/main/kc/stdlib/stdlib.kc @@ -52,7 +52,7 @@ unsigned int* bsearch16u(unsigned int key, unsigned int* items, char num) { } // The different supported radix -enum RADIX { BINARY, OCTAL, DECIMAL, HEXADECIMAL }; +enum RADIX { BINARY=2, OCTAL=8, DECIMAL=10, HEXADECIMAL=16 }; // Awaits fix https://gitlab.com/camelot/kickc/issues/230 // Information about a radix @@ -80,10 +80,6 @@ unsigned int[] RADIX_HEXADECIMAL_VALUES = { 0x1000, 0x100, 0x10 }; // Information about the hexadecimal radix // struct RadixInfo RADIXINFO_HEXADECIMAL = { 4, RADIX_HEXADECIMAL_VALUES }; -// Awaits fix https://gitlab.com/camelot/kickc/issues/223 -// Information about each radix. Can be retrieved using RADIXINFOS[radix] -// struct RadixInfo[] RADIXINFOS = { RADIXINFO_OCTAL, RADIXINFO_OCTAL, RADIXINFO_DECIMAL, RADIXINFO_HEXADECIMAL }; - // The digits used for numbers char[] DIGITS = "0123456789abcdef"z; @@ -114,8 +110,9 @@ void utoa(unsigned int value, char* buffer, enum RADIX radix){ digit_values = RADIX_BINARY_VALUES; } else { // Unknown radix - *buffer++ = 'n'; - *buffer++ = 'a'; + *buffer++ = 'e'; + *buffer++ = 'r'; + *buffer++ = 'r'; *buffer = 0; return; } diff --git a/src/test/ref/complex/clearscreen/clearscreen.log b/src/test/ref/complex/clearscreen/clearscreen.log index 724c44278..1f4b7b70b 100644 --- a/src/test/ref/complex/clearscreen/clearscreen.log +++ b/src/test/ref/complex/clearscreen/clearscreen.log @@ -1395,10 +1395,10 @@ SYMBOL TABLE SSA (word) ProcessingSprite::vy (word) ProcessingSprite::x (word) ProcessingSprite::y -(const byte) RADIX::BINARY = (byte) 0 -(const byte) RADIX::DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL = (byte) 1 +(const byte) RADIX::BINARY = (number) 2 +(const byte) RADIX::DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL = (number) 8 (byte*) RASTER (byte*) RASTER#0 (byte) RASTER_IRQ_MIDDLE @@ -10633,10 +10633,10 @@ FINAL SYMBOL TABLE (word) ProcessingSprite::vy (word) ProcessingSprite::x (word) ProcessingSprite::y -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (byte*) RASTER (const byte*) RASTER#0 RASTER = (byte*) 53266 (byte) RASTER_IRQ_MIDDLE diff --git a/src/test/ref/complex/clearscreen/clearscreen.sym b/src/test/ref/complex/clearscreen/clearscreen.sym index da702ab4c..64abbcc5a 100644 --- a/src/test/ref/complex/clearscreen/clearscreen.sym +++ b/src/test/ref/complex/clearscreen/clearscreen.sym @@ -78,10 +78,10 @@ (word) ProcessingSprite::vy (word) ProcessingSprite::x (word) ProcessingSprite::y -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (byte*) RASTER (const byte*) RASTER#0 RASTER = (byte*) 53266 (byte) RASTER_IRQ_MIDDLE diff --git a/src/test/ref/malloc-0.log b/src/test/ref/malloc-0.log index 508cf8158..3be11b733 100644 --- a/src/test/ref/malloc-0.log +++ b/src/test/ref/malloc-0.log @@ -89,10 +89,10 @@ SYMBOL TABLE SSA (byte*) BYTES#3 (byte*) HEAP_TOP (byte*) HEAP_TOP#0 -(const byte) RADIX::BINARY = (byte) 0 -(const byte) RADIX::DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL = (byte) 1 +(const byte) RADIX::BINARY = (number) 2 +(const byte) RADIX::DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL = (number) 8 (byte*) heap_head (byte*) heap_head#0 (byte*) heap_head#1 @@ -484,10 +484,10 @@ FINAL SYMBOL TABLE (const byte*) BYTES#0 BYTES = (byte*)(const void*) malloc::return#0 (byte*) HEAP_TOP (const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960 -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (byte*) heap_head (void()) main() (label) main::@1 diff --git a/src/test/ref/malloc-0.sym b/src/test/ref/malloc-0.sym index 494bab24c..83f102972 100644 --- a/src/test/ref/malloc-0.sym +++ b/src/test/ref/malloc-0.sym @@ -6,10 +6,10 @@ (const byte*) BYTES#0 BYTES = (byte*)(const void*) malloc::return#0 (byte*) HEAP_TOP (const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960 -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (byte*) heap_head (void()) main() (label) main::@1 diff --git a/src/test/ref/malloc-1.log b/src/test/ref/malloc-1.log index 332d45e18..9acfd056c 100644 --- a/src/test/ref/malloc-1.log +++ b/src/test/ref/malloc-1.log @@ -87,10 +87,10 @@ SYMBOL TABLE SSA (label) @end (byte*) HEAP_TOP (byte*) HEAP_TOP#0 -(const byte) RADIX::BINARY = (byte) 0 -(const byte) RADIX::DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL = (byte) 1 +(const byte) RADIX::BINARY = (number) 2 +(const byte) RADIX::DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL = (number) 8 (const byte) SIZEOF_WORD = (byte) 2 (word*) WORDS (word*) WORDS#0 @@ -546,10 +546,10 @@ FINAL SYMBOL TABLE (label) @end (byte*) HEAP_TOP (const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960 -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2 (word*) WORDS (const word*) WORDS#0 WORDS = (word*)(const void*) malloc::return#0 diff --git a/src/test/ref/malloc-1.sym b/src/test/ref/malloc-1.sym index f35bfbef8..23dee1278 100644 --- a/src/test/ref/malloc-1.sym +++ b/src/test/ref/malloc-1.sym @@ -4,10 +4,10 @@ (label) @end (byte*) HEAP_TOP (const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960 -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2 (word*) WORDS (const word*) WORDS#0 WORDS = (word*)(const void*) malloc::return#0 diff --git a/src/test/ref/memory-heap.log b/src/test/ref/memory-heap.log index 10f6eaa5d..9e754a50a 100644 --- a/src/test/ref/memory-heap.log +++ b/src/test/ref/memory-heap.log @@ -125,10 +125,10 @@ SYMBOL TABLE SSA (label) @end (byte*) HEAP_TOP (byte*) HEAP_TOP#0 -(const byte) RADIX::BINARY = (byte) 0 -(const byte) RADIX::DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL = (byte) 1 +(const byte) RADIX::BINARY = (number) 2 +(const byte) RADIX::DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL = (number) 8 (void()) free((void*) free::ptr) (label) free::@return (void*) free::ptr @@ -849,10 +849,10 @@ FINAL SYMBOL TABLE (label) @end (byte*) HEAP_TOP (const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960 -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (void()) free((void*) free::ptr) (label) free::@return (void*) free::ptr diff --git a/src/test/ref/memory-heap.sym b/src/test/ref/memory-heap.sym index 85e021c2b..ca37ec26c 100644 --- a/src/test/ref/memory-heap.sym +++ b/src/test/ref/memory-heap.sym @@ -3,10 +3,10 @@ (label) @end (byte*) HEAP_TOP (const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960 -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (void()) free((void*) free::ptr) (label) free::@return (void*) free::ptr diff --git a/src/test/ref/plasma-center.log b/src/test/ref/plasma-center.log index 55f3aeff9..7d96a9549 100644 --- a/src/test/ref/plasma-center.log +++ b/src/test/ref/plasma-center.log @@ -1480,10 +1480,10 @@ SYMBOL TABLE SSA (byte) NUM_SQUARES#7 (byte) NUM_SQUARES#8 (byte) NUM_SQUARES#9 -(const byte) RADIX::BINARY = (byte) 0 -(const byte) RADIX::DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL = (byte) 1 +(const byte) RADIX::BINARY = (number) 2 +(const byte) RADIX::DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL = (number) 8 (byte*) SCREEN1 (byte*) SCREEN1#0 (byte*) SCREEN2 @@ -9741,10 +9741,10 @@ FINAL SYMBOL TABLE (const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960 (byte) NUM_SQUARES (const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30 -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (byte*) SCREEN1 (const byte*) SCREEN1#0 SCREEN1 = (byte*) 10240 (byte*) SCREEN2 diff --git a/src/test/ref/plasma-center.sym b/src/test/ref/plasma-center.sym index 204e17429..75d4a21c8 100644 --- a/src/test/ref/plasma-center.sym +++ b/src/test/ref/plasma-center.sym @@ -22,10 +22,10 @@ (const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960 (byte) NUM_SQUARES (const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30 -(const byte) RADIX::BINARY BINARY = (byte) 0 -(const byte) RADIX::DECIMAL DECIMAL = (byte) 2 -(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (byte) 3 -(const byte) RADIX::OCTAL OCTAL = (byte) 1 +(const byte) RADIX::BINARY BINARY = (number) 2 +(const byte) RADIX::DECIMAL DECIMAL = (number) $a +(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10 +(const byte) RADIX::OCTAL OCTAL = (number) 8 (byte*) SCREEN1 (const byte*) SCREEN1#0 SCREEN1 = (byte*) 10240 (byte*) SCREEN2