TVI Programs

TVI programs are broken into data and code sections. A program can contain an arbitrary number of code and data sections but must contain at least one code section. Data sections are optional. Comments and blank lines are ignored.

Comments

Single line comments are started with a semi-colon.  C-style multi-line comments are also supported.

; This is a comment
/*
* This is also a comment.
*/

TIP: Have your compiler generate comments when generating the TVI code for while loops and if statements.  It can make the code much easier to understand when debugging is required.

Code Sections

Code sections contain program statements and procedure declarations
 Procedures must be contained within a single code section (which implies they can not contain data sections).  Each code section is introduced with the keyword CODE and multiple code sections will be combined into a single list of instructions by the interpreter.  Execution starts at the first instruction in the list and terminates when the end of the list is encountered or the exit opcode is encountered.  Caution:  program execution will flow into procedure blocks unless an explicit exit statement is encountered.  The main program must also be in the first CODE section encountered

Most instruction take three operands and the destination operand is always the last operand in the instruction.  The general form of instructions is:

opcode operand1, operand2, destination

and can be read as

destination := operand1 opcode operand2

A statement in a code section can also be labeled if it is to be the destination of a
goto statement or branching statement.  A

(Continued on next page)

Back to top

To contact us:

© Copyright 1999 Vassar College
Poughkeepsie, New York

Web pages  by
Keith Suderman Consulting