Repository navigation
Programming
Imprint is a stack based language, instructions operate on the stack and add/remove one or more items from the stack.
Each stack item (and program memory item) may represent either an integer (signed) a vector or a colour between 0x000000 and 0xffffff (RGB)
Lines can be labelled with label-name: and referenced with label-name. At compile time, the memory address
LET foo initial-value will allocate program memory and leave foo usable as the address pointing to that memory so that you can use it with PushFrom/PopTo etc. (or Jump if you're getting advanced...)
LET foo[n] initial-value1 initial-value2 ... initial-value-n as above but allocates n pieces of contiguous data, foo points to the first of them. IMPORTANT NOTE - due to a bug in the compiler, subsequent references will not take account of the extra space these arrays take up! So you can only really use one of these, and it must be the last declared LET until this bug is fixed
CONST FOO value declares a compile time constant that you can use anywhere in the program you would use a normal datum
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| NoOp | Does nothing - padding | ||
| Push | datum | Pushes one piece of data onto the stack, e.g. Push 10, Push 0xff55ff or Push (10,-10)
|
|
| Pop | datum | Removes one item from the top of the stack | |
| PushFrom | address | memory contents | Pops a single memory address, and pushes the contents of that memory address onto the stack |
| PopTo | address, datum | Pops a memory address from the stack and then pops the next item from the stack into that location in memory | |
| PeekTo | address | As above but doesn't remove the item from the stack | |
| Clone | datum | datum, datum | Peeks the top item in the stack and pushes another copy onto the top of the stack |
| Swap | a, b | b, a | Swaps the top two items on the stack |
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| Jump | address | Specifies the next instruction to be executed (usually referenced by way of a label:) |
|
| JumpNe | address, a, b | Jumps to address if a is not equal to b | |
| JumpEq | address, a, b | Jumps to address if a is equal to b | |
| JumpLt | address, a, b | Jumps to address if a is less than b | |
| JumpGt | address, a, b | Jumps to address if a is greater than b | |
| JumpZero | address, a | Jumps to address if a is equal to zero |
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| Or | a, b | result | Performs a bitwise or operation |
| And | a, b | result | Performs a bitwise and operation |
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| Add | a, b | result | a + b = result |
| Sub | a, b | result | a - b = result |
| Random | max-range | result | Generates a random integer between 0 (inclusive) and max-range (exclusive) |
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| VecAdd | v1, v2 | result | v1 + v2 = result |
| VecSub | v1, v2 | result | v1 - v2 = result |
| VecComp | x, y | v | Composes an x and y component integer into the vector (x, y) |
| VecDecomp | v | x, y | Decomposes a vector (x, y) into its constituent integers x and y |
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| GetId | int | Gives the running bot's id | |
| GetPos | vec | Gives the running bot's position | |
| GetColour | colour | Gives the running bot's colour | |
| SetColour | colour | Sets the running bot's colour |
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| MoveTo | vec | If the given location vector is passable, path finds to that location and begins moving towards it |
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| ShootAt | vec | Shoots at the given vector position if it is within range of guns (guns require ten ticks cooldown before subsequent firings so this command may not be executed immediately) |
| Instruction | Pops | Pushes | Description |
|---|---|---|---|
| MessageSetChannel | int | Just call this and set to 12 if you want to use messaging. Will be more useful later | |
| MessageRead | addr, length | success | Reads the next message in the buffer if it exists. If there are no messages in the buffer success=0, if there is a message success=1. Will read length pieces of data into program memory starting at addr. Beware the complete lack of overflow protection... |
| MessageSend | addr, length | Reads the program memory ranging from addr for length pieces of data, will broadcast that as a message on the channel currently set by MessageSetChannel |