EXAPUNKS Compiler with language extensions to generate assembly for conditionals and loop control structures.
EXA Language Reference
Language reference for EXAPUNKS assembly.
Operands
R
- RegisterR/N
- Register or numberL
- Label
Registers
X
- General purpose storage registerT
- General purpose storage register. The value is set to 0 or 1 from the result ofTEST
instructions and is used byTJMP
andFJMP
.F
- File cursor. Used to read and write to the held file.M
- Used to transmit data to other EXAs.
Instructions
COPY R/N R
- Copy value to registerADDI R/N R/N R
- Add 2 values. Same syntax forSUBI
,MULI
,DIVI
, andMODI
.SWIZ R/N R/N R
MARK L
- Create labelJUMP L
- Jump to labelTJMP L
- Jump to label ifT
is non-zero.LJMP L
- Jump to label ifT
is 0TEST R/N = R/N
- Compare values using=
,<
, and>
operatorsREPL L
- Create copy of EXA and jump to label in the copyHALT
- Terminate current EXAKILL
- Terminate another EXA in same nodeLINK R/N
- Move to nodeHOST R
- Copy host name to registerMODE
- Toggle communication mode between Local and GlobalVOID M
- Discard value from registerTEST MRD
- SetT
to 1 if can read message from another EXA, otherwise, set it to 0MAKE
- Create new fileGRAB R/N
- Grab fileFILE R
- Copy file IDSEEK R/N
- Move file cursorVOID F
- Discard value from fileDROP
- Drop fileWIPE
- Delete fileTEST EOF
- SetT
to 1 if end of file is reached, otherwise, set it to 0NOTE
- Comment (line comments start with;
)NOOP
- Do nothingRAND R/N R/N R
- Generate random number between first and second operand (inclusive)
EXA Compiler Language Extensions
Additional language features supported by this EXA Compiler.
R/N = R/N
- Assign first operand to second. Sugar forCOPY
instruction.- Ex.
X = 10
- Ex.
R/N = R/N + R/N
- Add 2 values and assign them to the first operand. Same syntax for+
,-
,*
,/
,%
, andSWIZ
.- Ex.
X = M + 1
- Ex.
X = 6789 SWIZ 4321
- Ex.
R/N = RAND R/N R/N
- Assign random number to register.- Ex.
X = RAND 1 10
- Ex.
R/N += R/N
- Short assignment for one value. Same syntax for+=
,-=
,/=
,*=
, and%=
.- Ex.
X += M
- Ex.
TEST != R/N
- Inverse ofTEST = R/N
. Same syntax for>=
and<=
.TEST NOT EOF
- Inverse ofTEST EOF
. Same syntax forMRD
.IF/ELSE IF/ELSE
- Condition usesTEST
syntax. Body must end withEND
.- Ex.
IF X > 10 ... ELSE IF X > 5 ... ELSE ... END
- Ex.
WHILE
- While loop condition usesTEST
syntax. Checks condition before executing body. Omit condition for infinite loop. Body must end withLOOP
.- Ex:
WHILE ... LOOP
- Ex:
WHILE X < 10 ... LOOP
- Ex:
DO
- Do while loop condition goes at the end and is checked after executing the body. Omit condition for infinite loop. Body must end withLOOP
followed by the condition.- Ex:
DO ... LOOP
- Ex:
DO ... LOOP WHILE X < 10
- Ex:
BREAK
- Break current loopBREAK IFFALSE
- Break current loop ifT
is 0. Also supportsBREAK IFTRUE
.CONTINUE
- Continue current loopCONTINUE IFFALSE
- Continue current loop ifT
is 0. Also supportsCONTINUE IFTRUE
.IF ISTRUE
- Execute body ifT
is non-zero. Same syntax forISFALSE
.- Ex.
IF ISTRUE ... END
- Ex.
WHILE ISTRUE
- Execute body ifT
is non-zero. Same syntax forISFALSE
. This also works for do while loops.- Ex.
WHILE ISTRUE ... LOOP
- Ex.
DO ... WHILE ISTRUE
- Ex.