more lang hoohah
Haldean Brown
4 years ago
0 | 0 |
Primitives:
|
1 | 1 |
- boolean
|
2 | 2 |
- int
|
3 | |
signed 32-bit integer
|
|
3 |
signed 28-bit integer
|
4 | 4 |
- Q vectors
|
5 | 5 |
dimension k (fixed at compile time), represents robot state
|
6 | 6 |
- R vectors
|
|
116 | 116 |
|
117 | 117 |
Control flow:
|
118 | 118 |
|
119 | |
mark ( -- )
|
120 | |
adds a mark in the instruction flow
|
121 | |
unmark ( -- )
|
122 | |
drop the most recent mark
|
123 | |
jumpif (bool -- )
|
124 | |
if true, goes to the most recent mark and maintains the mark.
|
125 | |
otherwise, unmarks and continues
|
|
119 |
{ ( -- )
|
|
120 |
opens a block; instructions inside the block are not executed
|
|
121 |
} ( -- block )
|
|
122 |
closes a block, creating a block that can be passed to something else
|
|
123 |
if ( block bool -- )
|
|
124 |
if bool is true, runs block. otherwise, just pops both off the stack
|
|
125 |
and does nothing
|
|
126 |
loop ( block bool -- )
|
|
127 |
if bool is true, runs the block. repeats running block until bool is no
|
|
128 |
longer true
|
|
129 |
|
|
130 |
A do-while loop that calls 'func' on the top value 10 times then looks like:
|
|
131 |
|
|
132 |
10
|
|
133 |
{
|
|
134 |
swap # ( x i -- i x )
|
|
135 |
func swap # ( i x -- f(x) i )
|
|
136 |
1 - dup 0 neq # ( f(x) i -- f(x) i-- (i-- == 0) )
|
|
137 |
}
|
|
138 |
true loop
|
126 | 139 |
|
127 | 140 |
All measurements done in whole microns to avoid floating point
|
|
0 |
#pragma once
|
|
1 |
|
|
2 |
const uint32_t meka_tag_bool = 0x00000000
|
|
3 |
const uint32_t meka_tag_int = 0x00000001
|
|
4 |
const uint32_t meka_tag_qvec = 0x00000002
|
|
5 |
const uint32_t meka_tag_rvec = 0x00000003
|
|
6 |
const uint32_t meka_tag_reg = 0x00000004
|
|
7 |
const uint32_t meka_tag_sig = 0x00000005
|
|
8 |
const uint32_t meka_tag_chan = 0x00000006
|
|
9 |
const uint32_t meka_tag_cset = 0x00000007
|
|
10 |
const uint32_t meka_tag_mask = 0xFFFFFFF8
|
|
11 |
|
|
12 |
typedef uint32_t meka_value;
|
|
13 |
|
|
14 |
#define meka_unpack(v) ((v) >> 3)
|
|
15 |
#define meka_pack(t, v) (((v) << 3) | meka_tag_ # v)
|