-
Notifications
You must be signed in to change notification settings - Fork 1
Wasmbeat Language Reference
stellartux edited this page Oct 31, 2024
·
1 revision
This is the reference for websynth's wasmbeat language. It is an easy way to enter bytebeat expressions that run on top of the Wasm virtual machine.
Like the WebAssembly Text format, wasmbeat can be written as reverse Polish notation or as S-expressions. (& t (>> t 8))
is syntax sugar for t t 8 >> &
.
Name | Arity | Functionality |
---|---|---|
t |
0 | The current tick |
tt |
0 | The current tempo-synced tick |
+ |
2 | Addition |
- |
2 | Subtraction |
* |
2 | Multiplication |
/ |
2 | Quotient of division |
% |
2 | Remainder of division |
~ |
1 | Bitwise not |
<< |
2 | Bitshift left |
>> |
2 | Signed bitshift right |
>>> |
2 | Unsigned bitshift right |
& |
2 | Bitwise and |
| |
2 | Bitwise inclusive or |
^ |
2 | Bitwise exclusive or |
= |
2 | Equality test |
> |
2 | Greater than test |
< |
2 | Less than test |
drop |
1 | Drop the top value from the stack |
When wasmbeat was first implemented, WebAssembly was at its MVP stage, and did not allow functions to return multiple values. As such, swap
and dup
could not be implemented on top of the bare Wasm stack. Since then, Wasm has added support for returning multiple values, so I plan to implement these at some point.
Name | Arity | Functionality |
---|---|---|
swap |
2 | Swap the top two values on the stack |
dup |
1 | Duplicate the top value of the stack |