0.1.8230 Apr 2023 00:04
Added new header , which provides C functions setjmp() and longjmp().
Added optimization option -fomit-frame-pointer to tell the compiler to not keep the frame pointer in a register for functions that do not need one. This can shorten the program. This option is not on by default. It does not act on functions that use inline assembly. It should be used with caution because it has not seen much use as of this release.
Added warning option -Wfor-condition-sizes, which warns if a for() loop's condition compares values of different sizes. For example: unsigned n = 256; for (unsigned char i = 0; i n; ++i) ...
CMOC is now compiled without debugging information by default. To compile CMOC with it, pass --enable-debug to the configure script.
0.1.8104 Feb 2023 04:53
Fixed compilation problems when building CMOC on Cygwin.
Fixed bugs in memcmp(), memicmp(), strcmp(), stricmp() for OS-9.
Added sqrt32() to CMOC's standard library.
Optimizations and minor fixes.
0.1.8016 Sep 2022 20:46
Fixed a bug with the code generated when += or -= were used on pointers to multi-byte types other than int.
Fixed a bug where an OS-9 executable that used f in a printf() call would crash.
Options --raw and --srec are now usable with --dragon. Previously, they caused a fatal error.
0.1.7925 Aug 2022 00:18
Floating-point arithmetic using the float type is now supported when targeting the DragonDOS environment.
Added option --add-os9-stack-space, which allows specifying a number of bytes to add to the stack space normally allocated by OS-9.
The compiler now issues a warning when passing a struct or union to printf() or sprintf().
0.1.7806 Jul 2022 01:41
Added more optimizations. The branch shortening optimization is slightly more aggressive. Assembly errors about short branches being out of range should be reported.
Added support for compilers that need an explicit option (e.g., -std=c++11) to recognize the C++11 features used by the CMOC source code.
Fixed a K R prototype bug where a prototype without any parameters would forbid calls with parameters.
0.1.7724 Apr 2022 02:05
Added functions sinf, cosf, tanf, atanf, logf, expf, sqrtf, fabsf, floorf, truncf and roundf to . These functions only work on the CoCo and only if Extended Color Basic is present.
Emit an error instead of crashing when a floating-point value cannot be represented on the targeted platform.
0.1.7605 Mar 2022 23:08
Local static variables are now supported.
0.1.7520 Feb 2022 01:36
Added support for the FLEX operating system (--flex).
Fixed a bug that rejected "long int/signed/unsigned".
Fixed a bug with the switch() statement where a large sparse array of switch values would generate a huge assembly language sequence.
readDECBFile() now returns an error code and has a different signature.
0.1.7415 Jan 2022 02:06
K R C function definitions are now accepted, experimentally.
Minor fixes to compile without warnings with gcc 11.2.0.
No warning is issued anymore for a missing return statement if the last statement in the function body is an asm statement, because the return value will typically be stored directly in B or D by that inline assembly code.
Minor optimizations added.
0.1.7302 Jan 2022 22:49
Added readDECBFile() to . This function reads a Disk Basic floppy file into memory.
Added to CMOC's standard library. It provides a function that reads or writes a CoCo floppy sector.
Added memset16(), which fills a memory region with a 16-bit word.
Minor optimizations added.
0.1.7220 Nov 2021 04:53
Fixed a code generation bug with an array whose initializer has fewer values that the length of the array.
Fixed a code generation bug with casting a long to a pointer.
Fixed a bug where some writable arrays would be put in the read-only section.
New -Wno-uncalled-static option to disable the warning on a static function that is not called.
Added C functions memmove(), memichr() and vsprintf() to CMOC's library.
When the --no-relocate option is specified and optimizations are enabled, program-counter-relative addressing is typically replaced with absolute addressing (e.g., LEAX foo,PCR is replaced with LDX #foo).
0.1.7105 Jun 2021 17:23
Added support for the Thomson MO and TO computers (--thommo, --thomto).
Added C functions vprintf(), strncmp(), memchr(), isspace(), isdigit(), isalpha() and isalnum() to CMOC's library.
New -Wno-printf option to disable the warning normally issued when the format argument of printf() or sprintf() is not a string literal.
Fixed a bug with initializers for a struct that contains a matrix of characters.
Other bug fixes.
0.1.7008 Mar 2021 00:27
Added the --void-target command-line option, which targets a generic platform whose I/O system is not known to CMOC. This target may be useful to users of 6809-based single-board computers or other unsupported platforms.
Added the --raw command-line option, which forces the compiler to generate an executable in "raw" format, as defined by LWTOOLS' linker (i.e., --format=raw is passed to lwlink). (This option is not supported when targeting OS-9.)
0.1.6924 Jan 2021 20:52
Fixed a bug with code emitted from array initializers containing string literals for a character matrix, e.g., char a 2 6 = ... .
Fixed a bug where an error message would have the wrong number when the error happens after an inline assembly block that contains an #if directive that generates a preprocessor line number directive (of the form '# ').
Passing a pointer argument to a function parameter of integral type now gives a warning.
0.1.6821 Dec 2020 03:06
Fixed a bug that prevented a numerical cast to a pointer, e.g., NULL, from being used as an initializer.
Fixed a bug that prevented initializing a struct local variable from a const struct.
Fixed a bug that affected += and -= when applied to a function pointer variable.
Optimized copied shifting of an unsigned long by 8, 16 or 24 bits, left or right.
Added an optimization to avoid EOR or OR with 0 and ANDing a byte with 255.
Optimized conditional expressions (c ? x : y).
0.1.6707 Jun 2020 15:01
Fixed an issue with the unsigned long shifting optimization introduced in version 0.1.66.
0.1.6606 Jun 2020 15:19
New -Wlocal-var-hiding command line switch makes the compiler issue a warning when a local variable declaration hides another one of the same name.
Fixed a bug where a global variable initializer of the form array N was rejected as being non constant.
Added some optimizations.
0.1.6525 Apr 2020 02:42
Added stricmp() and memicmp() (for ASCII case-insensitive comparisons) to the CMOC library.
Fixed a crash that happened on =, = and =, or some casts, when used inside an if() statement.
Fixed an internal error that happened on some array references whose left side is an addition operation.
0.1.6406 Apr 2020 01:52
Fixed a bug with enumerated names that depended on a sizeof expression and with array declarations that depended on such enumerated names.
0.1.6321 Mar 2020 16:06
Fixed a 16-bit by 8-bit multiplication code generation bug to make sure that a 16-bit multiplication is done in those cases.
0.1.6202 Mar 2020 02:54
Fixed global variable initialization so that non-constant initializer expressions are rejected as in Standard C.
Added the --intdir=D command-line option, which can be used to have the intermediate files generated in directory D.
Added strstr() to CMOC's library.
0.1.6121 Oct 2019 23:50
New command-line option -Wgives-byte tells CMOC to warn about binary operations on bytes yielding a byte. For example, (char) a * (char) b yields a byte under CMOC, while it yields an int under Standard C.
Fixed a bug with comparisons between an int and a long.
0.1.6025 Aug 2019 20:52
C functions qsort() and bsearch() have been added to the standard library.
Fixed under-reported const-correctness errors about assigning, incrementing or decrementing members of structs.
A struct whose initializer allows it to be defined with static values is now defined this way instead of using initialization code.
sizeof(void) now returns 1 (as with GCC) instead of 0. This fixes a bug where applying + or += to a void pointer failed to advance the pointer.
0.1.5904 Jun 2019 02:39
A library is now allowed to provide "constructor" and "destructor" code sections that contain code to be run before and after main() respectively.
Changed the interface of the OS-9 stack check routine (_stkcheck) so that it does not trash the D register.
Various minor bug fixes.
0.1.5830 Mar 2019 17:02
The main() return value, and the exit() argument, are now guaranteed to be returned in D upon exiting the program, when compiled for CoCo Basic or for the Dragon.
Floating point and long constants are now only emitted when they are used by emitted code. This resolves double emissions that could happen with an array of constants of those types.
16-bit multiplications by 10 are now optimized by the use of a specialized utility routine.
Several minor bug fixes.
0.1.5701 Jan 2019 22:28
Reimplemented rand() as an Xorshift random number generator to reduce the predictability of each of the 15 bits returned.
Fixed comparisons involving a signed byte and an unsigned 8-bit constant.
Modified optimization "storeLoad" so that a load of an absolute address is assumed to deal with a volatile memory location, like an I/O port.
0.1.5625 Nov 2018 19:49
CMOC now directly supports the generation of Dragon executables, when the --dragon option is passed. CMOC's standard library is expected to work on the Dragon. The float and double types are not supported. The library is not supported.
Fixed bad code generation in the case of a subtraction of a pointer from an array name.
Fixed a bug that prevented a program from subtracting a value of type T from a value of type const T *.
0.1.5514 Oct 2018 17:37
Fixed a bug that gave an error when returning a non-const pointer from a function that returns a const pointer (e.g., const char *f(char *p) return p; ).
Fixed a bug where C errors would still be reported when --deps-only was specified.
0.1.5404 Oct 2018 19:41
The compiler now tolerates the use of NULL (e.g., (void *) 0) in contexts that expect a non-void pointer, e.g., int *p = NULL;
Additional optimizations of unsigned byte multiplications.
Added new function setPmodeGraphicsAddressEx(), which allows the caller to change the screen buffer address for pcls() without changing the currently displayed screen.
0.1.5321 Sep 2018 02:07
Fixed an OS-9 extern array problem by fixing the way the compiler determines if a variable can go to the read-only section or not.
Added functions pmode(), screen(), rgb() and cmp() to the library that ships with CMOC. Function pcls() now takes only one argument.
Fixed the output format for Vectrex so that the resulting file is the loadable binary, with the proper header.
0.1.5221 Jul 2018 19:39
Binary literals (e.g., 0b101010 for 42).
Bit fields are now accepted by the compiler, but each field is allocated as a full char, int or long.
The manual now documents how to include an arbitrary binary file in the executable. (See the section "Merging a binary file with the executable".)
Several minor bug fixes. (See the NEWS file for details.)
0.1.5101 Apr 2018 03:55
Fixed a bug that prevented defining a const long or real global with an initializer.
Fixed the determination of which globals go in the rodata section, in order to allow const arrays of function pointers.
Added command-line option --no-relocate to tell the compiler to assume that the program will only be loaded at the addresses specified by --org and --data. Not compatible with OS-9. Default for Vectrex.
disk.h: Fixed the documentation of close(). Fixed the interface of getFileLength() and computeFileLength() so that they can return the file length in bytes.
0.1.5021 Mar 2018 01:12
The const keyword is now supported. Warnings are issued for statements that are not const-correct. The header now defines _CMOC_CONST_ to be const, which allows a user to redefine it to an empty string in order to use the compiler library without const-correct function prototypes. The warnings can be silenced by giving the command-line option "-Wno-const". Global arrays of const integers are automatically put in the rodata section, which should make the #pragma const_data directive obsolete.
0.1.4927 Feb 2018 02:59
Returning a char or int from a function that must return a long is now allowed. The returned value is automatically promoted to a long.
Arrays of longs, floats or doubles whose initializer is composed entirely of numerical literals are now initialized statically.
Fixed a bug that made sizeof() return the wrong value for an array that was declared both with and without the extern keyword.
0.1.4816 Feb 2018 22:26
Fixed a low-level optimization that was incompatible with some signed long divisions.
Fixed a bug that gave a false error ("has no initializer") when declaring an external global variable in a const_data section.
The compiler now automatically defines _CMOC_VERSION_, which represents a 32-bit number of the form XXYYZZZ when the version is X.Y.Z. Version 0.1.48 defines _CMOC_VERSION_ as 1048.
Vectrex is now supported in linker mode. It is not supported in monolith mode anymore.
More experimental support for OS-9.
0.1.4703 Feb 2018 23:55
Fixed the rand() function to improve its distribution.
New keyword __norts__ to keep the compiler from emitting an RTS at the end of a function's body.
New -nodefaultlibs command-line option excludes the compiler provided libraries.
The uninitialized global variables are now zeroed out at the start of execution, on all platforms.
More experimental support for OS-9.
0.1.4617 Jan 2018 02:27
Function pointers are now type-safe. Arrays of function pointers are now supported. Returning a long, float, double or struct through a function pointer call is now supported.
Comma expressions are now supported.
Several new low-level optimization phases.
More experimental support for OS-9.
0.1.4527 Nov 2017 01:18
Fixed a bug with a declaration initializer that used a signed byte conditional expression.
Fixed a clang-related compilation error (re: SwitchStmt.h) and compilation warning (re: yyinput()).
0.1.4419 Nov 2017 20:40
The switch() statement now uses a jump table in most situations where this takes less memory than a series of compare and branch instructions. The command line now accepts options --switch=ifelse and --switch=jump to force the compiler to always use one mode or the other.
Fixed a bug on Mac OS X where the cpp preprocessor failed to generate its result in its standard output because the -D options were passed to it after the C filename. The options are now all passed before the filename.
Added --deps-only and --deps command-line options that create a makefile dependency file for the C file being compiled. See the "Generating Prerequisites Automatically" section of the manual. Not available in monolith mode.
0.1.4303 Nov 2017 00:57
Linking and modular compilation are now supported.
0.1.4221 Oct 2017 05:04
Fixed a bug with adding a signed short integer to a long integer.
Fixed an array initialization bug that happened on ARM platforms.
Fixed a relocatability problem with code that compares a float with an unsigned integer.
Replaced short branches in the floating-point library with long branches, to prevent assembly errors.
0.1.4109 Oct 2017 15:21
32-bit arithmetic using the long type is now supported.
0.1.4013 Aug 2017 01:24
Floating-point arithmetic using the float type is now supported when targeting the Color Basic environment. (The FuncPlot demo has been rewritten using floats. See below.)
Structs and unions can now be returned by value and passed by value to a function.
Fixed a bug where casting a negative 1-byte constant to char would yield a positive number.
Added readJoystickPositions() and readJoystickButtons() functions to .
0.1.3902 Jul 2017 22:59
Fixed a bug where a typedef for a function pointer type was registered as a typedef for the return type only.
Fixed a typedef bug that caused a syntax error when declaring a variable of a named struct defined by the typedef, e.g., typedef struct X int n; Y; struct X foo;.
Fixed a bug that prevented declaring a variable of an empty struct.
Referring to an undeclared C variable or enumerator in the argument of an inline assembly instruction (e.g., asm std :foo ) is now reported as an error by the compiler instead of by the assembler.
Referring to a global variable before its declaration is now reported as an error.
0.1.3823 Jun 2017 17:09
Fixed a compiler crash that happened in somes cases where an enumerator was defined from other enumerators, or from an unknown enumerator name.
Fixed a bug where void return values were not ignored as they should have been (e.g., if (voidFunction() == 0) ).
Added -o FILE command-line option to specify an output filename other than the default, which is to replace the .c extension of the source file with .bin.
0.1.3703 Jun 2017 01:21
Fixed a bug in the optimizer that made the compiler crash when compiling most unit tests, on some platforms (typically Mac OS X, sometimes on PC with Clang).
Fixed an erroneous -O2 optimization related to register value prediction (re: ASMText::removeAndOrMulAddSub()).
A portability bug was fixed in WordConstantExpr.cpp by avoiding a conversion of a negative floating point value to an integer type.
0.1.3613 May 2017 05:16
Fixed a portability problem with the Raspberry Pi.
The level 2 optimizer (-O2) is now significantly faster.
The standard library now has a subdww() function to subtract a 16-bit unsigned word from a 32-bit unsigned word, cmpdww() to compare a 32-bit unsigned word to a 16-bit unsigned word, and divdww() to divide a 32-bit unsigned integer by a 16-bit unsigned integer.
0.1.3514 Jan 2017 20:19
Fixed a crash that happened when trying to use the array reference operator ( ) on a void pointer. Such an expression now gives an "invalid use of void expression" error message.
Fixed bugs related to the interactions between array initializers, array typedefs and string literals.
Some optimizations that were suspended with version 0.1.34 have been restored after fixes to the optimizer.
0.1.3427 Dec 2016 00:24
Fixed a bug that over-optimized operations involving a byte-sized constant cast to a word.
Fixed a bug that over-optimized loads of the X register.
Fixed an inline assembly problem in vectrex/bios.h. This only affects compilations that target the Vectrex console (--vectrex).
Casting a variable name to void does not emit an instruction anymore.
0.1.3324 Oct 2016 01:16
Fixed bugs with array typedefs.
Fixed a bug where a top-level function-local variable was allowed to be defined with the same name as a function parameter.
Fixed a bug with an optimization of boolean expressions evaluated for their numerical value.
Fixed a potential bug with va_arg() (stdarg.h) by avoiding the use of the Y register, to comply with the CMOC register convention.
0.1.3218 Sep 2016 02:08
Fixed bugs with the /=, =, = operators.
The compiler now checks that operators that require an l-value are actually applied on one. For example, (n 1) is illegal and is now reported as such.
0.1.3113 Sep 2016 01:14
Inline assembly: When an asm block refers to a C variable whose name is that of a register, such a reference must now be preceded by a colon character, which acts as an escape character.
Added atoi() and atoui() to the standard library.
Fixed a bug with the return statement that omitted the sign extension when returning a signed character from a function returning signed int.
Fixed a bug where wrong code was emitted for the multiplication of two members of a struct, where one of the members was the first of the struct.
Fixed a bug where sizeof() on a string literal returned 2 instead of the length of the string plus one. A string literal is now typed as an array of characters instead of a pointer to a character.
Fixed a bug where printf() and putstr() failed to translate some ' n' characters into a carriage return under Color Basic. In the case of printf(), it was when the ' n' appeared in the argument of a s placeholder.
0.1.3022 Aug 2016 00:38
Fixed a bug with the optimization of a division of a signed value by 10.
0.1.2907 Aug 2016 19:37
Enumerations are now supported.
Relational operators on byte operands do not promote to int anymore, for efficiency reasons. This is consistent with CMOC's treatment of other binary operators.
0.1.2801 Jul 2016 20:37
Typed function pointer declarations are now supported.
A function that takes no arguments can now be declared with a argument list containing only the void keyword.
Referring to an undefined struct is now allowed except when declaring a variable of that type.
Anonymous structs are now supported.
Assigning a struct value to another and initializing a struct from another are now supported.
A typedef can now be used for an array type.
0.1.2716 Jun 2016 03:27
Fixed a crash that happened when using a struct value in a context that requires an r-value, e.g., a struct as an if() condition.
Fixed a bug where a conditional instruction, in an asm block, that targeted a C function was not emitted correctly, which caused the assembler to declare an error.
Fixed an optimizer bug.
The configure script now checks that POSIX.1 function strcasecmp() is available.
0.1.2620 May 2016 01:28
Fixed another optimizer bug that affected ternary expressions (a ? b : c).
Fixed the writecocofile tool so that the directory entries it creates are compatible with EDTASM.
Fixed a bug in the -d option of the writecocofile command that made it list lost granules as being free. The lost granules (which are allocated in the FAT but not used by any directory entry) are now listed.
0.1.2501 May 2016 17:45
Fixed an optimizer bug that affected ternary expressions (a ? b : c).
Clarified the public domain status of header files cmoc.h, stdlib.inc, stdlib-data.inc and vectrex.h.
Resolved compilation issues for gcc 6.1.0.
0.1.2422 Apr 2016 03:12
Fixed a bug where a program using the right shift operator with a non-constant number of bits to shift would not compile unless the program also used the left shift operator with a non-constant number of bits to shift. (The compilation would fail with an error message involving shiftLeft_end.)
Fixed a bug affecting shifting byte expressions by a non-constant number of bits.
Fixed a bug in inline assembly statements when a BRA or LBRA instruction would be used to jump to a C function (the program would not compile).
0.1.2318 Apr 2016 01:29
A function pointer is now considered to be of type void * instead of char *.
Fixed a bug where a switch() inside another switch(), or inside a for/while/do-while would cause the break and continue statements after the end of the inner switch to branch to the end of the inner switch, when it should have branched to the end of the outer switch/for/while/do-while.
Fixed a bug with the signed right shift operator ( ): when the left side is negative and the operator shifts more bits than the left side holds, the result is now -1 ( FFFF), instead of zero.
0.1.2208 Apr 2016 00:08
Fixed an optimizer bug that affected increments on a struct field in some situations.
0.1.2103 Apr 2016 15:53
More low-level optimizations contributed by Jamie Cho.
New "#pragma limit X" directive (forces a failure if the end of the program exceeds address X).
References to C functions are now supported in inline assembly.
Fixed a bug in printf() with zero-padding on hex values when the output callback was redirected.
0.1.2008 Mar 2016 01:56
Several peephole optimizations have been added. Fixed a bug where the compiler crashed when sizeof() was used on an unknown variable name and this sizeof() was used twice in a binary expression. CMOC now automatically displays the program start and end addresses when the --verbose option is passed. New command-line option --limit=X forces a failure if the end of the program exceeds address X.
0.1.1912 Jan 2016 01:11
Fixed a bug where a function-local function prototype crashed the compiler. Such prototypes now give an error message. Function prototypes must be declared at global scope.
Fixed a bug where the wrong line number was given in the error message when a character variable was initialized with a function address.
Fixed a bug where the compiler would crash when taking the sizeof() an unknown struct name.
0.1.1819 Dec 2015 20:58
Added support for the Vectrex video game console.
0.1.1708 Nov 2015 18:30
Fixed a bug where declaring a character array in a const_data section (see the manual) with a string literal as the initializer was rejected despite the literal being a valid array to initialize with.
Fixed a bug where comparing an unsigned character to a signed character would give the wrong result because the comparison was not allowed to promote its operands to int as it is supposed to do.
Fixed a bug that prevented the use of non trivial constant initializers in a const_data section (e.g., int n = -42 instead of int n = 42). This fix applies to array initializers also.
0.1.1612 Oct 2015 16:55
Fixed a bug where multiplying a negative byte constant with a signed byte variable would generate an invalid load instruction.
0.1.1514 Sep 2015 01:05
Embryonic support for OS-9. Portability fixes.
0.1.1405 Sep 2015 04:41
Fixed a binary operator optimization where 0xffb0 + byteVar would be generated as an 8-bit add.
Fixed a bug that prevented taking the sizeof() a row of a 2-dimensional array, e.g., sizeof(a 0 ).
Fixed a false compilation error that would prevent initializing a void pointer variable with a void pointer expression.
0.1.1209 Aug 2015 17:45
Added support for unions.
Fixed a crash on a string literal used as an array initializer.
Fixed an assembly-level optimizer bug that would make an if() execute the else clause unconditionally in the presence of inline assembly.
0.1.1108 Aug 2015 21:21
Removed a divergence from C: the signedness of an additive of multiplicative operation is now the signedness of the left operand.
Added an assembly-level peephole optimizer.
Improved the optimization of some boolean expressions, multiplications, divisions and modulos.
0.1.1025 Jul 2015 15:20
Fixed a compiler crash on initializing a character array with a string literal.
New --emit-uncalled option forces the compiler to emit assembly code even for functions that are not called by C code.
A struct can now declare more than one member per semi-colon: struct S int a, b; char *c, *d; .
Assembly-only functions are now allowed to refer to global variables.
0.1.913 Jul 2015 00:23
Restructured the standard library so that only the needed portions are included in the final assembly program. A program that calls no standard library function can save up to about 1900 bytes.
Functions that are defined but not called are not emitted in the final assembly program.
0.1.805 Jul 2015 17:46
Integer constants are now of type int or unsigned int.
A comparison of two expressions will only use a signed branch instruction if the two operands are signed expressions.
New function modifier keyword 'asm' tells the compiler that the function must not have a stack frame and will only contain inline assembly language.
More small optimizations and bug fixes.
0.1.727 Jun 2015 17:47
Fixed a bug where initializing a pointer from an incompatible array type would potentially crash the compiler.
Fixed a bug where inline assembler that would use indirect addressing of a C variable (e.g., "jsr someVariable ") would not assemble.
Added a script (install-coco-boot-loader) that writes the contents of a CoCo DECB .bin file to track 34 of a DECB disk image.
0.1.621 Jun 2015 23:00
Fixed a bug where all compilations would fail with the message "syntax error: #".
Added missing file src/support/legacy.h.
Added a sprintf() function.
0.1.519 Jun 2015 02:14
Fixed bad code generation for an expression that adds a constant to an array that was received as a function argument.
Added the --check-stack option to have CMOC insert run-time checks for stack overflows.
Added the --check-null option to insert run-time checks for null pointers. (Version 0.1.4.)
0.1.311 Jun 2015 02:47
First announcement on FreshCode.