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 executiongoto LABEL— transfers execution to a labelX := W— assignment
Labels are defined as name_of_label:, where the name is a C-like identifier.
Assignment
In X := W:
Xis an expression which is not a literal integerWis an expression
/ 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
5or-100 - a directly addressed memory cell:
[integer] - an indirectly addressed memory cell:
[[integer]] - address-of identifier (read-only unary operator):
&IDENTIFIERreturns the address of the named memory cell - a special program counter register:
program_counter(case-sensitive, 1-based instruction index)
Expressions can also be combined with operators:
Y &IDENTIFIER Y + Z Y - Z Y * Z Y / Z Y % Z Y & Z Y | Z Y ^ Z Y << Z Y >> Z
Manual entry: program_counter
program_counteris a special register available in expressions and assignments.- Its value is the current instruction index, starting from
1. - Writing to it jumps execution to the given instruction (for example
program_counter := 10). - The assigned value must be at least
1.
Přehled
Program je posloupnost příkazů vykonávaných po jednom v pořadí, v jakém jsou zapsány, pokud není určeno jinak.
Na úplném konci programu je implicitní instrukce halt.
Vše, co je zapsáno za #, se ignoruje.
Příkaz
Příkaz je:
- jednoduchý příkaz, nebo
- podmíněný příkaz zapsaný jako
if A ?? B then Inst
Zde A a B jsou výrazy, Inst je jednoduchý příkaz a ?? je jeden z:
= <> < > <= >=
Jednoduchý příkaz
halt— zastaví vykonávánígoto LABEL— přenese vykonávání na návěštíX := W— přiřazení
Návěští se definuje jako name_of_label:, kde jméno je identifikátor ve stylu C.
Přiřazení
V X := W:
Xje výraz, který není celočíselný literálWje výraz
/ je celočíselné dělení se zaokrouhlením k nule. V Y / Z musí být Z nenulové. V Y % Z musí být Z kladné.
Výraz
Výraz je:
- celočíselný literál jako
5nebo-100 - přímo adresovaná paměťová buňka:
[integer] - nepřímo adresovaná paměťová buňka:
[[integer]] - adresa identifikátoru (read-only unární operátor):
&IDENTIFIERvrací adresu pojmenované paměťové buňky - speciální registr programového čítače:
program_counter(rozlišuje velikost písmen, 1-based index instrukce)
Výrazy lze také kombinovat operátory:
Y &IDENTIFIER Y + Z Y - Z Y * Z Y / Z Y % Z Y & Z Y | Z Y ^ Z Y << Z Y >> Z
Manuální položka: program_counter
program_counterje speciální registr dostupný ve výrazech i přiřazení.- Jeho hodnota je index právě vykonávané instrukce od
1. - Zápis do něj přesune vykonávání na danou instrukci (např.
program_counter := 10). - Přiřazená hodnota musí být alespoň
1.