Home
  Contact
  Short Vita
  Research
  Teaching
  LSDIS Lab
  Links

UGAVAC Computer Description

Table of Contents

1. Short Description of the UGAVAC Computer

2. UGAVAC Assembly Language

2.1. Comments

2.2. Labels

2.3. Instructions

2.3.1. Basic Instruction Set

2.3.2. Floating Point Instructions

2.3.3. Input / Output Library

Examples

Micro-Pascal Code patterns


1. Short Description of the UGAVAC Virtual Computer

The UGAVAC (UGA Virtual Automatic Computer) is composed of the following:

  1. 65536 (= 64K) words of word-addressable memory partition for data, called Stack,
  2. 65536 (= 64K) words of word-addressable memory partition for program, called Code,
  3. three special purpose registers:
    PC -Program Counter register
    SP -Stack Pointer register
    FP -Frame Pointer register
  4. ALU, capable of performing various stack operations
  5. I/O unit, capable of reading/printing.

The memory partition (Code) contains a program (the byte code of a program written in UGAVAC Assembly Language). The memory partition (Stack) is used for storing data and other necessary information.

2. UGAVAC Assembly Language

Each line of an UGAVAC Assembly Language program must contain either a comment, a label definition, or an instruction.

2.1. Comments

A comment begins with a number sign (#) in the first column and extends until the end of line. Comments are ignored. Also, any characters following a properly formatted instruction (to the end of the line) are treated as a comment.

2.2. Labels

A label is an identifier (letter|"$")(letter|digit)*. Only the first ten (10) characters are used to distinguish among labels. A label starting in the first column of a line is regarded as the definition of that label. There must be exactly one definition of every referenced label in an UGAVAC Assembly Language program. The label 'main' is reserved and indicates the main entry point. Note, that a label in the UGAVAC Assembly Language may begin with a $ (dollar) character. For example, $12 is a legal label.

There are six predefined labels (which are entry points to the standrad IO library routines): $ReadInt, $WriteInt, $WriteStri, $WriteLn, $ReadReal, and $WriteReal. These routines are defined in the pre-loaded UGAVAC library Iolib.u.The library is explained below.

2.3. Instructions

An instruction is composed of an instruction name (mnemonic), optionally followed by one or two operands. The mnemonic and operands (if they are present) are separated by space(s) and/or tab(s). An instruction must begin in a column higher than 1, otherwise the mnemonic is treated as a label definition. A short description of the available UGAVAC Assembly instructions is given below:

In what follows:

CI represents an integer constant ([+|-]digit+),
CR represents a floating point constant, ([+|-]digit+"."digit+),
CS represents a string constant (sequence of chars within single quotes "'"),
L represents a label; &L represents the label's address,
O represents a memory offset (used in addressing),
N is an integer constant.

Basic Instruction Set

Opcode Name Arg Action

0 pushcI CI SP := SP + 1; Stack[SP] := CI;
1 pushI O SP := SP + 1; Stack[SP] := Stack[FP+O];
2 popI O Stack[FP+O] := Stack[SP]; SP := SP - 1;
3 pushgI N, O SP := SP + 1; Stack[SP] := Stack[base(N)+O];
4 popgI N, O Stack[base(N)+O] := Stack[SP]; SP := SP - 1;
5 fetchI Stack[SP] := Stack[Stack[SP]];
6 popiI Stack[Stack[SP-1]] := Stack[SP]; SP := SP - 2;
7 pusha O SP := SP + 1; Stack[SP] := FP+O;
8 pushga N, O SP := SP + 1; Stack[SP] := base(N)+O;
33 pushs CS SP := SP + 1; Stack[SP] := &CS;
39 storeI Stack[Stack[SP-1]] := Stack[SP]; Stack[SP-1] := Stack[SP]; SP := SP - 1;

9 addI Stack[SP-1] := Stack[SP-1] + Stack[SP]; SP := SP - 1;
10 subI Stack[SP-1] := Stack[SP-1] - Stack[SP]; SP := SP - 1;
11 mulI Stack[SP-1] := Stack[SP-1] * Stack[SP]; SP := SP - 1;
12 divI Stack[SP-1] := Stack[SP-1] div Stack[SP]; SP := SP - 1;
13 negI Stack[SP] := - Stack[SP]

16 eqI Stack[SP-1] := ord(Stack[SP-1] = Stack[SP]); SP := SP - 1;
17 neI Stack[SP-1] := ord(Stack[SP-1] < > Stack[SP]); SP := SP - 1;
18 ltI Stack[SP-1] := ord(Stack[SP-1] < Stack[SP]); SP := SP - 1;
19 leI Stack[SP-1] := ord(Stack[SP-1] <= Stack[SP]); SP := SP - 1;
20 gtI Stack[SP-1] := ord(Stack[SP-1] > Stack[SP]); SP := SP - 1;
21 geI Stack[SP-1] := ord(Stack[SP-1] >= Stack[SP]); SP := SP - 1;

22 jumpz L if Stack[SP] = 0 then PC := &L; SP := SP - 1;
23 jumpnz L if Stack[SP] < > 0 then PC := &L; SP := SP - 1;
24 jump L PC := &L;

25 enter N Stack[SP+1] := base(N); Stack[SP+2] := FP; SP := SP + 3;
26 alloc N SP := SP + N;

36 setrvI Stack[FP] := Stack[SP]; SP := SP - 1;
27 return SP := FP - 1; PC := Stack[FP+2]; FP := Stack[FP+1];
35 returnf SP := FP; PC := Stack[FP+2]; FP := Stack[FP+1];
28 call L, N FP := SP - (N+2); Stack[FP+2] := PC; PC := &L;

14 int Stack[SP] := trunc(Stack[SP]);
15 intb Stack[SP-1] := trunc(Stack[SP-1]);
142 flt Stack[SP] := float(Stack[SP]);
143 fltb Stack[SP-1] := float(Stack[SP-1])

The function base(N) returns the address of the activation record N static levels down.

2.3.2. Floating Point Instructions

Floating point instructions are obtained by replacing the last letter 'I' with 'R'. For example, 'pushR' corresponds to 'pushI'. Opcodes of the floating point instructions are always greater by 128 than the opcodes of the corresponding integer instructions. For example, the opcode of 'pushR' is 129 (pushI opcode, 1, plus 128). The only additional instructions are 'int' (convert to integer representation), 'intb' (convert to integer below SP), 'flt' (convert to floating point representation), and 'ftlb' (convert to float below SP).

2.3.3. Input/Output Library

The input/output library, called iolib.u, is loaded before the execution of any UGAVAC program begins. The library supports basic I/O operations, such as reading and writing of fixed point numbers, floating point numbers, and strings. The I/O library provides six I/O routines: $ReadInt, $ReadReal, $WriteInt, $WriteReal, $WriteStri, and $WriteLn. $ReadInt and $ReadReal accept a single argument passed by reference (of integer and real type, respectively). $WriteInt and $WriteReal accept a single argument passed by value (of integer and real type, respectively). $WriteStri accepts a string argument (passed by value). $WriteLn accepts no parameters. Calling sequences are described below:

$ReadInt -- reading integers

enter 0
<push address of an integer variable>
call $ReadInt, 1

$WriteInt -- writing integers

enter 0
<push value of an integer expression>
call $WriteInt, 1

$WriteStri -- writing strings

enter 0
<push string constant>
call $WriteStri, 1

$WriteLn -- writing newlines:

enter 0
call $WriteLn, 0

$ReadReal -- reading floats:

enter 0
<push address of a real variable>
call $ReadReal, 1

$WriteReal -- writing floats

enter 0
<push value of a real expression>
call $WriteReal, 1

Examples of UGAVAC programs are also available.

UGAVAC intermediate code generation should be handled according to the Micro-Pascal code patterns.

For instructions on how to invoke the UGAVAC interpreter view its manual page.