ANSI C to Fcode

home
features
demos
platforms
specs
contact

 
 
 

Features and Benefits

ccfcode is an ANSI C compiler that generates standard Open Firmware Fcode suitable for tokenizing. It is written entirely in C++ and contains a tightly integrated C preprocessor for both completeness and high performance.

This compiler allows Fcode device drivers to be developed without an intimate knowledge of Forth internals. It also removes the one big Forth headache of checking for the correct number of stack parameters.
 

 

Download demos

Demo versions of ccfcode are available that run under several operating systems including MacOS-X, MacOS, Solaris, Linux, and Windows NT. If your system is not listed on the download page, please contact us  and we will build one.
Download demo software
The demo code also includes a sample graphics driver.
 

 

Supported Platforms

A variety of  platforms are already supported or currently under development, as are some sample device drivers. Please contact us for anything not in the current list:
  • Systems
    • Macintosh including OS-X
    • Solaris
    • FreeBSD (and NetBSD and OpenBSD)
    • Linux
    • Windows NT
  • Sample device drivers
    • simple frame buffers

 

Specifications

  • ANSI C and other compiler features
    • __FUNC__ predefined macro for current function name (Gnu, others)
    • strips // comments (BCPL, C++)
    • ignore #include files which are wrapped with any #if* directive and then #included again (Gnu, others)
    • strings may begin with "\p" or "\P" for Pascal strings (MPW, Think C)
    • optional comma at end of enum list (Plan 9, Gnu, others)
    • unnamed unions (Plan 9, C++)
    • unnamed structs (Plan 9)
    • auto-cast struct pointer into substruct pointer (Plan 9)
    • structure displays (Plan 9, NCEG proposal)
    • initialisation indexes for arrays (Plan 9, partial NCEG proposal)
    • old-style K&R function definitions (common extension)
    • bitfields may be of any integral type (C++, common extension)
    • "inline" and "__inline__" keywords (C++, gcc)
    • comma before "..." is optional in parameter declarations (C++)
  • Limitations due to Forth/Fcode
    • no floating-point support
    • case statements *must* end with a break - no fall-throughs are supported
    • break and continue inside loops are not supported
    • gotos and labels are not supported
    • ANSI wide-character strings are not supported
    • alloca() is not supported
    • classes are not supported (C++ style but suitable for embedded apps)
    • the standard C library is not supported (stdio, etc.)
    • <stdarg.h> is not supported
  •  Special Forth/Fcode features
    • asm("Forth code") embeds arbitrary Forth in the output
    • void func() { ... } does not generate any stack frame push/pop code if func has no parameters and no local variables
    • volatile uses r{bwl}{!@} instead of {cwl}{!@} for read/write of vars
    • use Pascal-style strings "\pstr" to create a Forth str+len combo on stack
      • otherwise C string's length is not on the Forth stack
      • Pascal-style strings are not null-terminated, but C strings are
      • these are typically only useful to call certain Forth words
      • Pascal strings are of type "unsigned char*" and not "char*"
    • bitfields work but should be avoided since the generated code is horrible
    • structs and arrays are initialized/copied by placing each element on the Forth stack one-by-one rather than as a C packed chunk-o-memory
      •  this should not ordinarily affect any C or Forth code
      •  access to a struct field or array object is reasonably efficient
    • if a function named "main" exists, a call to it (with no arguments) is inserted just before the end of the Fcode, and thus main() will be automatically invoked when the Fcode image is loaded
    • inline functions are only partially supported to call existing Forth words
      •  no stack parameters are copied/allocated/etc
      •  the function body must only be a single "asm" statement

 
 
CodeGen, Inc.
PO Box 3357
Oakland, CA 94609
1-510-652-0151
info@codegen.com