Vapor-M Language Specification

A Vapor-M program is largely the same as a Vapor program except one step closer to MIPS assembly language. The main difference is that instead of local variables, you use registers and stack memory.

The first is that instead of local variables you get 23 registers.

To follow MIPS calling conventions, use the registers as follows:

The second difference is the ability to store values on the stack. Each function has three stack arrays called "in", "out", and "locals". The "in" and "out" array are for passing arguments between functions. The "in" array actual refers to the "out" array of the caller. The "local" array is for function-local storage (for example: spilled registers). The sizes of these arrays are declared at the top of every function (instead of a parameter list).

Each element of each array is a 4-byte word. The indexes into the array is the word-offset (not the byte offset). Array references can be used wherever memory references can be used. So "in[1]" refers to the second element of the "in" stack array.

func Run [in 2, out 0, local 4]
  $r1 = in[1]
  local[3] = $r1
  PrintString($r1)
  $v0 = 1
  ret