ColaVM Documentation



Instructions

Cola programs are written using stack-based instructions. Most instructions consume values from the stack (pop them) and may push a result back.

Stack Behaviour

Instructions that perform calculations remove their operands from the stack first. The most recently pushed value is always popped first.

Example:

PUSH 10 PUSH 5 SUB TOP

After SUB, the stack contains 5 because it computes 10 - 5. Both values were removed before the result was pushed back.

Writing and running a program

Following are the steps to successfully write and run a Cola program.

  1. Create a file named "program.cola".
  2. Write the desired code for the ColaVM.
    For this example, let's assume a single line: PRINT "Hello, World!"
  3. Run python assemble.py path/to/program.cola or python3 assemble.py path/to/program.cola depending on your platform.
  4. The compiled .can file (cola binary) will be created at the same directory as the source .cola file.
  5. Run ./colavm program.can to run the binary.