C++ and Forth source code.
All code is distributed under the terms of the MIT License which means that you can use and modify it for any purpose.
The code has only been tested on 32bit little-endian targets but has been designed to be word size and endian agnostic; please let me know if it doesn't work on your system.
C++ source is commented using Doxygen style comments and is formatted with tab stops every four characters.
If you have any comments, please feel free to contact me.
All C++ code below requires this header file which provides type definitions and helper macros which aren't part of standard C++.
Extensible classes for producing formated C strings.
This also contains implementation of the C standard library functions:
Classes for constructing and manipluating a bit-vector (array of bits).
This code is targeted at CPUs without hardware support for division or floating point. It has been optimised for ARM CPUs but should be suitable for other RISC architectures.
32 bit fixed-point maths implementation, including multiplication, division, square-root, trigonometric and logarithm functions.
Routines for handling 3 dimensional points, vectors and matrices. This uses the Fixed-Point Maths routines above.
An implementation of ITU-T (formerly CCITT) Recommendation G711 "Pulse Code Modulation (PCM) of Voice Frequencies"
An implementation of ITU-T (formerly CCITT) Recommendation G726 "40, 32, 24, 16 kbit/s Adaptive Differential Pulse Code Modulation (ADPCM)"
This code optionally contains two deliberate bugs in the
which were added so the code passes the G726 test sequences. It seems that
the standard implementation in G191 also contains these bugs.
Also requires source for G711
An implementation of the IMA ADPCM audio coding algorithm.
Simple class for using serial ports.
Y-Modem (and X-Modem) file transfer protocol. The receive and transmit code is separated into two classes which reduces memory size when only one of these functions is required. The code uses the Serial Port routines above.
Below is source for a command-line program for Y-Modem file transfer. This acts as a test program for the Y-Modem implementation and is a useful utility in its own right. It also supports receiving a 'log' after transmitting files; this can be used when sending a file to a development board and receiving instrumentation output which comes back on same port.
ANS Forth virtual machine written in C++. This is a token threaded implementation which contains the ANS Core words plus a few extra words from other wordsets. It doesn't make use of any C library functions, and so should compile to stand-alone code suitable for embedding in other programs.
Forth source code is also available to implement additional ANS wordsets...
Test code for all implemented wordsets...
ARM Assembler and Disassembler written in Forth. These support all ARM architectures up to and including Version 6.
The assembler syntax closely follows standard ARM format and includes support for labels.
IMPORTmacros which were used to manage symbol visability when making Windows style DLLs.
select()rather than hand rolled polling and sleeping.
XT_DO_QUITwas jumping one token to far, which would produce unpredicable results if
StdForthIo, to use standard Posix functions rather than Microsoft's
ForthVM::Acceptto accept alternative keys for backspace (0x08 and 0x7F) and input end (0x0a and 0x0d).
THROWhandling into new member function
ForthVM::UncaughtException. This improves the code generated by GCC.
offsetofto work on GGC 4, also added global placement new operator.
FIX_UNROLL_DIV_LOOPmacros in maths/fix.cpp)
uint8_t, and made use of
sizeof(CELL)was greater than
C"(forth/core-ext.f) which manifested when the size of a
CHARwas not one address unit.
L:word in the ARM Assembler.
Vector3::Normalso that it copes with vectors of any magnitude.