RAM Manual

Syntax based on lecture NTIN060

← Back

Overview

A program is a sequence of statements executed one at a time in the order they are written, unless specified otherwise.

There is an implicit halt instruction at the very end.

Everything written after # is ignored.

Statement

A statement is:

  • a simple statement, or
  • a conditional statement written as if A ?? B then Inst

Here A and B are expressions, Inst is a simple statement, and ?? is one of:

=
<>
<
>
<=
>=

Simple statement

  • halt — stops execution
  • goto LABEL — transfers execution to a label
  • X := W — assignment

Labels are defined as name_of_label:, where the name is a C-like identifier.

Assignment

In X := W:

  • X is an expression which is not a literal integer
  • W is one of the following
Y
Y + Z
Y - Z
Y * Z
Y / Z
Y % Z
Y & Z
Y | Z
Y ^ Z
Y << Z
Y >> Z

/ is integer division rounded toward zero. In Y / Z, Z must be non-zero. In Y % Z, Z must be positive.

Expression

An expression is:

  • a literal integer such as 5 or -100
  • a directly addressed memory cell: [integer]
  • an indirectly addressed memory cell: [[integer]]