Pravda assembler (pasm) is a text representation of Pravda VM bytecode.
Let's consider one simple program written in pasm:
/* My program */ jump @main @ok: push "good" jump @end @main: push 2 mul push 8 gt jumpi @ok push "bad" @end:
It pops item from the stack and multiplies it by 2. If it is less than 8 it pushes "good" to the stack, else it pushes "bad".
pasm operations are easy to understand. There're several things that differ from low-level bytecode:
- You can define labels:
- Jump to defined labels
jump @my_label. Jump with condition
jumi @my_labeland jump to functions with preserved call-stack
- Push primitive to the stack:
push <primitive>. Or put item to the heap:
new <data>(in this case reference to data will be pushed to the stack).
- Write comments:
/* a comment */.
- Work with structs:
struct_get <primitive>. This will produce
STRUCT_GET_STATICopcodes which take key for struct field from bytecode. You can write
<primitive>literal. In this case
STRUCT_GETopcodes are used and key is taken from stack.
- Use regular orphan opcodes.
- Add meta information via
meta <meta>, see
<meta>definition for details.
See also string