Types
The following are the list of types understood by the JALv2 compiler.
Type | Description | Range |
BIT1 | 1 bit boolean value | 0..1 |
SBIT1 | 1 bit signed value | -1..0 |
BYTE1 | 8 bit unsigned value | 0..255 |
SBYTE1 | 8 bit signed value | -128..127 |
WORD | 16 bit unsigned value | 0..65,535 |
SWORD | 16 bit signed value | -32,768..32,767 |
DWORD | 32 bit unsigned value | 0..4,294,967,295 |
SDWORD | 32 bit signed value | -2,147,483,648..2,147,483,647 |
FLOAT1 | floating point value | +/-10^-44..10^38 |
1base types
The larger types, [S]WORD, [S]DWORD are simply derived from the base types using the width specifier. For example, WORD is equivalent to BYTE*2, the later can be used interchangeably with the former.
Floating point arithmetic is *very* expensive in terms of both code and data and should best be avoided. It is nominally based upon IEEE 754, though does not raise exceptions nor handle overflow or special numbers (+/-Infinity, +/-NaN, -0, etc). A floating point value is represented in 4 BYTEs.
A note needs to be made concerning the BIT type. In the original JAL language, the BIT type acted more like a Boolean -- if assigned 0, the value stored would be zero, if assigned any non-zero value, the value stored would be one. This convention is still used in JALv2.
However, JALv2 also understands BIT types more like C bitfields. If, instead of BIT one uses the type BIT*1, the value assigned would be masked appropriately (in other words BIT*1 y = z translates internally to BIT*1 y = (z & 0x0001).
Even though the predefined larger types use standard widths (2 and 4), there is no such requirement imposed by the language. If you need a three byte value, use BYTE*3. The only upper limit is the requirement that any value fit within one data bank.
Finally, BIT and BYTE are distinct, so defining a value of BIT*24 is not the same as defining a value of BYTE*3!