Chirp is designed as a simple high-level language to program the Cricket robot. The target of Chirp compiler is the Cricket bytecode, which include
arithmetic, control flow, and robot control (such as motor control, sensor
control, etc) operations. The Chirp language abstracts the control bytecode
into the System related interface functions. To compile Chirp program, one needs
to translate user program into Cricket bytecode sequence, and the calls to System
functions into the specialized robot control bytecode.
Cricket bytecode is the the target of Chirp compiler. The compiler will translate Chirp program into sequence of Cricket bytecode which can then be run on the Cricket robot.
The Cricket bytecode page lists the bytecode and descriptions.
You can access the simulator from the Chirp Simulator
page.
Chirp has a simple binary format and is defined as following:
| Byte offset | Description |
| 0x00-0x03 | Magic number "CHRP", or 0x43485250 |
| 0x04-0x05 | ROM address of code segment, unsigned 16-bit number in big-endian format: (0x04)<<8+(0x05) |
| 0x06-0x07 | ROM address of starting code, unsigned 16-bit number in big-endian format |
| 0x08-0x09 | length of code segment, should satisfy invariant: code_length +10 = file_length |
| 0x0a to end | Chirp bytecode, length specified by the length field |
To generate the starting code, a call main function bytecode is generated as:
main's address (16 bit) or with 0x8000, and 0.
For example, the Hello, world equivalent of Chirp is to make the Cricket beep
once, which is the following beep.ch program:
void main()
{
System.Sound.beep();
}
And the ASCII dump of the corresponding compiled beep.ch.bin file is:
67 72 82 80
0 0
0 3
0 6
0 12 7
-128 0 0
Or more "cryptic" bytecode form: 67 72 82 80 0 0 0 3 0 6 0 12 7 -128 0 0