next up previous contents
Next: High-level opcodes Up: The new language Previous: Side effects   Contents

Introduction to the VM langauge

Since this is the first example code of the language, I think it deserves an explanation.

First of all, all routines are contained within an entry and an end opcode. The entry opcode tells the virtual machine about the name of the routine, and the end opcode quite intuitively ends the current routine.

The first opcode within a routine must be a decl opcode. It declares the types of the variables we use in this routine. The variables are referred to as registers. The virtual machine can operate with any number of registers, but for efficiency reasons the variables (registers) are numbered $r_{0\ldots n}$ instead of being described with more intuitive names.

Of course, the TAL language should use named variables. It will then be up to the TAL translator to store these variables into numbered registers.

The decl opcode takes one or more arguments. The arguments are the type names from Table 3.2.1. First argument describes the type of register 0 (r0), second argument describes register 1, and so forth.

Note that the dimensions are not specified in the decl opcode. The dimension of a register can change dynamically at run-time.

Most opcodes take two arguments. The move opcode will copy the contents of the second argument into the first argument. So, the code for the first multiplication:

  move r0, r1
  mult r0, r2[999:-1:0]
actually copies r1 into r0, then multiplies the contents of r0 and the reversed r2, and stores this result in r0. It is equivalent to $\mathtt{r0} \gets
\mathtt{r1}_{0\ldots999} \cdot \mathtt{r2}_{999\ldots0}$

A mult opcode that took three arguments, a destination register and two source registers, would have spared us for the move operation. This would probably be a good idea to implement in the system.


next up previous contents
Next: High-level opcodes Up: The new language Previous: Side effects   Contents

1999-08-09