CMOC 0.1.35

CMOC is a 6809-generating cross-compiler for a subset of the C language. It produces assembler code for the Motorola 6809 processor in the Intel HEX format, for the Color Computer .BIN format and for the Vectrex game console. It runs under GNU/Linux and probably also other Unix-like environments.

Tags compiler c developers
License GNU GPLv3
State beta

Recent Releases

0.1.3514 Jan 2017 20:19 minor bugfix: 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 minor bugfix: 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 minor bugfix: 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 minor bugfix: 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 minor bugfix: 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 minor bugfix: Fixed a bug with the optimization of a division of a signed value by 10.
0.1.2907 Aug 2016 19:37 minor feature: 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 minor bugfix: 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 minor bugfix: 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 minor bugfix: 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 minor feature: Fixed an optimizer bug that affected ternary expressions (a ? b : c). Clarified the public domain status of header files cmoc.h,, and vectrex.h. Resolved compilation issues for gcc 6.1.0.
0.1.2422 Apr 2016 03:12 minor feature: 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 minor feature: 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 minor feature: Fixed an optimizer bug that affected increments on a struct field in some situations.
0.1.2103 Apr 2016 15:53 minor feature: 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 minor feature: 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 minor feature: 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 minor feature: Added support for the Vectrex video game console.
0.1.1708 Nov 2015 18:30 minor bugfix: 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 minor bugfix: 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 minor feature: Embryonic support for OS-9. Portability fixes.
0.1.1405 Sep 2015 04:41 minor feature: 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 minor feature: 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 minor feature: 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 minor feature: 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 minor feature: 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 minor feature: 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 minor bugfix: 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 minor bugfix: 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 major feature: 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 major feature: First announcement on FreshCode.