Commit | Line | Data |
---|---|---|
92a92075 AT |
1 | # Overview # |
2 | ||
3 | This folder contains a library of useful functions written in VVhitespace. | |
4 | Standard include guards are used with `cpp` to include the stdlib in user | |
5 | programs. For an example, see `examples/hello-stdlib`. | |
6 | ||
32c440bf AT |
7 | # Reservations # |
8 | ||
92a92075 AT |
9 | Since all labels share a global namespace, the standard library makes the |
10 | following reservations: | |
11 | ||
32c440bf AT |
12 | ## Label ## |
13 | ||
14 | 00000000 0xxxxxxx - reserved for stdlib function entry points | |
15 | 00000000 1xxxxxxx - unassigned | |
16 | 0xxxxxxx xxxxxxxx - reserved for private use by stdlib | |
17 | 1xxxxxxx xxxxxxxx - available for use in user programs | |
18 | ||
bb21580a | 19 | ## Heap and Pointers ## |
32c440bf | 20 | |
bb21580a | 21 | The first 16 heap addresses (`0-15`) are reserved when using the stdlib. |
6cb31a3e AT |
22 | Within that reservation, heap[0] is used by `random` and the block |
23 | heap[2]-heap[15] by the stack rotation subroutines which time-share these | |
24 | pseudo-registers between the various stdlib subroutines. | |
bb21580a AT |
25 | |
26 | By convention, functions which return a pointer will use the address `0` to | |
27 | represent a `NULL` pointer. | |
32c440bf AT |
28 | |
29 | # Entry Points # | |
30 | ||
31 | The following labels are entry points to stdlib functions. Read the | |
32 | header comment for each function to learn the call and return stack. | |
33 | ||
3625ff3a | 34 | 000xxx - reserved |
23d17247 AT |
35 | 001xxx - core functions |
36 | 1000 ----- printf (stdio.pvvs) | |
37 | 1001 ----- print number from stack (stdio.pvvs) | |
38 | 1010 ----- stackrotate (stack.pvvs) | |
a67867ae | 39 | 1011 ----- stackrotatereverse (stack.pvvs) |
f0499c77 | 40 | 1100 ----- deepdup (stack.pvvs) |
3625ff3a | 41 | 010xxx - math functions |
2612f47f | 42 | 10000 ----- random (math.pvvs) |
3625ff3a | 43 | 10001 ----- absolute value (math.pvvs) |
3695b659 AT |
44 | 011xxx - heap functions |
45 | 11000 ----- memset (heap.pvvs) | |
3d75b928 | 46 | 11001 ----- memcpy (heap.pvvs) |
d63de3fa | 47 | 11010 ----- memrand (heap.pvvs) |
87d27426 | 48 | 11011 ----- memcmp (heap.pvvs) |
fd04fb41 | 49 | 11100 ----- memsrch (heap.pvvs) |
bb21580a AT |
50 | 11101 ----- <empty> |
51 | 11110 ----- slurp (heap.pvvs) | |
52 | 11111 ----- spew (heap.pvvs) | |
ae1f85a1 AT |
53 | 100xxx - string functions |
54 | 100000 ----- strlen (string.pvvs) | |
0c56152e AT |
55 | 101xxx - logic functions |
56 | 101000 ----- not (logic.pvvs) | |
57 | 101001 ----- and (logic.pvvs) | |
58 | 101010 ----- or (logic.pvvs) | |
59 | 101011 ----- xor (logic.pvvs) | |
60 | 101100 ----- rshift (logic.pvvs) | |
61 | 101101 ----- lshift (logic.pvvs) | |
1a56830d AT |
62 | 110xxx - conversion functions |
63 | 111xxx - debug functions | |
64 | 111000 ----- dump heap (debug.pvvs) | |
ae1f85a1 | 65 | 111001 ----- dump stack (debug.pvvs) |
9f7f68e5 AT |
66 | 111010 ----- print sign (debug.pvvs) |
67 | 111011 ----- print magnitude (debug.pvvs) | |
68 | 111100 ----- print string (debug.pvvs) | |
3625ff3a | 69 | 1xxxxxx - reserved for less common entry points |
e0d5136c AT |
70 | 1000000 ----- lowbitand (logic.pvvs) |
71 | 1000001 ----- isnegative (math.pvvs) | |
ae1f85a1 AT |
72 | 1000010 ----- print sign of number (stdio.pvvs) |
73 | 1000011 ----- print magnitude of number (stdio.pvvs) | |
b8b65c17 AT |
74 | 1000100 ----- print string from stack (stdio.pvvs) |
75 | 1000101 ----- print string from heap (stdio.pvvs) | |
32c440bf AT |
76 | |
77 | # Misc # | |
78 | ||
79 | By convention, each public stdlib label will have 8 bits of | |
80 | private label space associated with it, formed as follows: | |
81 | ||
82 | 00001000 xxxxxxxx - for use by 1000 | |
83 | 00001001 xxxxxxxx - for use by 1001 | |
92a92075 | 84 | ...etc |