diff --git a/src/main/kc/stdlib/limits.kc b/src/main/kc/stdlib/limits.kc new file mode 100644 index 000000000..adb41c1b6 --- /dev/null +++ b/src/main/kc/stdlib/limits.kc @@ -0,0 +1,34 @@ +// Defines constants with the limits of fundamental integral types for the specific system and compiler implementation used. + +//TODO: Convert all limits to macros + +// Number of bits in a char object (byte) +const char CHAR_BIT = 8; +// Minimum value of char type +const char CHAR_MIN = 0; +// Maximum value of char type +const char CHAR_MAX = 255; +// Minimum value of signed char type +const signed char SCHAR_MIN = -128; +// Maximum value of signed char type +const signed char SCHAR_MAX = 127; +// Maximum value of unsigned char type +const unsigned char UCHAR_MAX = 255; +// Minimum value of unsigned short type +const unsigned short USHRT_MAX = 65535; +// Minimum value signed short type +const short SHRT_MIN = -32768; +// Maximum value of signed short type +const short SHRT_MAX = 32767; +// Minimum value of unsigned int type +const unsigned int UINT_MAX = 65535; +// Minimum value signed int type +const int INT_MIN = -32768; +// Maximum value of signed int type +const int INT_MAX = 32767; +// Maximum value of unsigned long type +const unsigned long ULONG_MAX = 4194304; +// Minimum value of signed long type +const long LONG_MIN = -2097152; +// Maximum value of signed long type +const long LONG_MAX = 2097151; diff --git a/src/main/kc/stdlib/stdint.kc b/src/main/kc/stdlib/stdint.kc index ed2be59a1..cec1d6b9a 100644 --- a/src/main/kc/stdlib/stdint.kc +++ b/src/main/kc/stdlib/stdint.kc @@ -1,3 +1,4 @@ +// C standard library stdint.h // Defines a set of integral type aliases with specific width requirements, along with macros specifying their limits and macro functions to create values of these types. // Unsigned integer type with a width of exactly 8 bits diff --git a/src/main/kc/stdlib/stdlib.kc b/src/main/kc/stdlib/stdlib.kc index ec4a07429..9e69afc3d 100644 --- a/src/main/kc/stdlib/stdlib.kc +++ b/src/main/kc/stdlib/stdlib.kc @@ -1,3 +1,4 @@ +// C standard library stdlib.h // Implementation of functions found int C stdlib.h / stdlib.c import "string" diff --git a/src/main/kc/stdlib/string.kc b/src/main/kc/stdlib/string.kc index e8a6131e3..f27d81acf 100644 --- a/src/main/kc/stdlib/string.kc +++ b/src/main/kc/stdlib/string.kc @@ -1,4 +1,5 @@ -// Standard C strings.h - functions to manipulate C strings and arrays. +// C standard library string.h +// Functions to manipulate C strings and arrays. typedef word size_t ; diff --git a/src/main/kc/stdlib/time.kc b/src/main/kc/stdlib/time.kc index b2b4c44b5..72ce08e69 100644 --- a/src/main/kc/stdlib/time.kc +++ b/src/main/kc/stdlib/time.kc @@ -1,4 +1,5 @@ -// Implementation of library functions found in C standard library time.h +// C standard library time.h +// Functions to get and manipulate date and time information. import "c64" @@ -34,4 +35,3 @@ void clock_start(void) { *CIA2_TIMER_B_CONTROL = CIA_TIMER_CONTROL_START | CIA_TIMER_CONTROL_CONTINUOUS | CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A; *CIA2_TIMER_A_CONTROL = CIA_TIMER_CONTROL_START | CIA_TIMER_CONTROL_CONTINUOUS | CIA_TIMER_CONTROL_A_COUNT_CYCLES; } -