JAL manual - quick reference

previous up next
basics
not case sensitive, free format, but put a space between each token
-- coments start with -- and continue up to the end of the line
include jlib -- include the standard library

types
bit       : 1 bit
byte      : 8 bit, modulo-256
universal : only during compilation, at least 32 bits signed

literals
bit       : true/high/on, false/low/off
universal : decimal, based (0b..., 0d..., 0h..., 0x...)
byte      : "A"
a universal expression in a byte context is coerced to byte

constants
const bit  light   = low, blank = high  -- bit constants
const byte pattern = 0b_0101_0101       -- byte constant
const ips          = clock / 2_500_000  -- universal constant

variables
var bit           done      =  false
var volatile byte status    at 3
var volatile bit  status_c  at status : 3
var               i2c_out   is pin_a3_direction

expressions
prefix 
   bit->bit         : ! 
   byte->byte       : + -
infix
   bit,bit->bit     : & | ^ 
   byte,byte->bit   : > < >= <= == !=
   byte,byte->byte  : & | ^ + - * / %
a universal can be used when a byte is required
for each byte,byte->byte there is also a universal,universal->universal

statements
var byte a -- a declaration is a statement!
a = 15
if a > 5 then ... end if
if a > 0 then ... else ... end if
if a == 1 then ... elsif a == 2 then ... else ... end if
while ! done loop ... end loop
for 5 loop ... end loop
forever loop ... end loop
delay_1S( 5 )
asm clrwdt
assembler ... end assembler

procedures and function declarations
procedure wait is for 100 loop asm nop end loop end procedure
procedure put( byte in x ) is ... end procedure
function get return byte is ... return x ... end function

pseudo-variables
procedure x'put( byte in x ) is ... end procedure
function  x'get return byte is ... end function

previous up next