These instructions define how your program behaves under certain circumstances. Following instructions are covered by this article:
There are 4 variants:
ret: just ends the program with the specific exit code:
ret 0retn: ends the program, but reads a register value for you; stands for "return-near":
mov tlr, 4
retn tlr ; ends the program with exit code 4retf: used to end a specific thread, stands for "return-far".
.start
thread threadName -> {
; do smth
retf 0
; code under retf won't be executed
}halt: does the same thing asret, but ends a procedure/function.
.start
proc printText
mov fdx, 1
mov stl, 0c1
sysenter "ios"
syscall
halt 0
endThese are used to declare a function/procedure and call it.
.start
proc myproc
; do smth
halt 0 ; return 0
end
call myproc ; calls the functionCompare register values with lvalues and jump to a specific label according to the result.
cmp tlr, 2
jz label ; if tlr == 2 jump to label| Instruction | Processed if... |
|---|---|
je/jz |
comparsion returned equal. |
jne/jnz |
comparsion returned not equal. |
jl |
comparsion returned less. |
jg |
comparsion returned greater. |
jle |
comparsion returned less or equal. |
jge |
comparsion returned greater or equal. |
The jmp instruction is used as an unconditional jump.
Allows you to have events, read more about this instruction inside the concepts docs.
Note
This instruction was added in build 25.
This instruction allows you to write more efficient loops. The syntax is:
loop register, labelRegisters that work with this instruction are imm, rax, cr2 and cr3.
Example:
.start
mov tlr, "Hello world\n"
mov rax, 4
:test4
call std::ios::write
loop rax, test4Output:
Hello world
Hello world
Hello world
Hello world