-
Notifications
You must be signed in to change notification settings - Fork 2
Kernel Functions
Cristian edited this page Oct 5, 2023
·
3 revisions
The following tables contain codes for kernel functions.
They work as normal functions, expecting parameters to be passed in reverse.
To call one of these you can use their name or hex code (call.k memory_size).
| HEX | Prototype | Description |
|---|---|---|
50 |
memory_grow(p: nat) |
Grows the memory by p pages. |
54 |
memory_shrink(p: nat) |
Shrinks the memory by p pages. |
51 |
memory_size(): nat |
Returns the memory size in bytes. |
2A |
memory_page(): nat |
Returns the page size in bytes (hardware dependent, usually 4KB). |
25 |
memory_pages(): nat |
Returns the number of allotted pages. |
C0 |
memory_copy(d: *, s: *, n: nat) |
Copies n bytes from source s to destination d. |
70 |
memory_load(d: *, s: [*], n: nat) |
Loads n bytes from code address s to destination d. |
00 |
memory_zeros(p: *, n: nat) |
Writes 0 to p, for n consecutive bytes. |
F1 |
memory_fill(b: byt, p: *, n: nat) |
Fills p with b, for n consecutive bytes. |
C2 |
memory_compare(a: *, b: *, n: nat): int |
Compares n bytes of a, b. Returns first different byte or -1 |
The usage of unowned memory will cause a bad access fault resulting in a immediate crash. If a function were to fail, it would set the flag register. You can move the flag register on the stack with the
flaginstruction which also resets it.