-
Notifications
You must be signed in to change notification settings - Fork 0
1 Instructions
Lia has very few and simple built-in instructions. The aim of the language is to have its resources defined mainly at compile-time, not by the compiler.
say "Hello!"
say "Hello " "World!" "\n"
The say instruction expects a sequence of strings that be printed in the output. This accept escape sequences like:
| Escape | Character | ASCII |
|---|---|---|
| \\ | \ | 92 - 0x5c |
| \n | New line | 10 - 0x0a |
| \r | Carriage return | 13 - 0x0d |
| \b | Backspace | 8 - 0x08 |
| \t | Horizontal tab. | 9 - 0x09 |
| \a | Bell | 7 - 0x07 |
| \v | Vertical tab. | 11 - 0x0b |
| \f | Form feed | 12 - 0x0c |
| \e | Escape | 27 - 0x1b |
| \0 | Null | 0 - 0x00 |
ases "A+a"
Same as say, this instruction expects a sequence of strings. But the string will be written in the output Ases' code.
func 1
The func instruction expects a number between 0 and 9, that a "function" number of the Ases language. The func 1 instruction is the same as ases "1".
load rd
Reads from the memory pointed by dp register and writes it in the register.
store rd
store 25
store 'x'
Writes the register or immediate value in the memory pointed by dp register.
push rd
push 25
push 'x'
Pushes the value in the stack.
pop rd
Popes the value from the stack and writes it in the register.
ifz instruction
ifnz instruction
ifz
instruction
instruction
...
endif
The ifz runs the code if the value of the register ss is zero, and ifnz runs the code if it not is zero.
You can use this instruction to execute one instruction conditionally or a block of instructions using endif to denote the end of the block.
proc example
instruction
instruction
...
endproc
You can declare a new procedure with proc instruction, the endproc is used to denotes the end of the procedure's block.
The instruction call can be used to execute a procedure.
call example
You can declare procedures in any part of the code, all the procedures are processed before the rest of the code. It means you can use a procedure before your declaration.
Note: At end of the procedures has a implicit
ret 0instruction.
ret
ret 25
ret 'x'
ret rd
You can use ret instruction to returns from inside a procedure. If you specified an immediate value or register, the ss register is defined to this value. You can use it for example to combine with the ifz|ifnz instruction.