Syntax

NCL programs are plain text composed of instructions and operands.

A simple instruction consists of a verb followed by zero or more whitespace-separated operands:

MOVE $000 42

Instructions normally occupy one program line, though multiple instructions may share a line when separated by semicolons:

MOVE $000 10; INC $000; D.TXT "Hello!"

Before execution begins, NCL performs a pre-pass over the complete program. This resolves source-level features such as comments, literals, string escapes, constants, labels, and relative line references into the form used during execution.

Constants, labels, and relative line references are described in Symbols.

Comments

Comments begin with -- and continue to the end of the line:

-- This entire line is a comment.

MOVE $000 42 -- Store 42.

Comments are removed during the program pre-pass.

Program Lines

NCL programs execute one program line at a time.

Normally, a line contains a single instruction:

MOVE $000 10
INC $000
D.TXT "Hello!"

Multiple instructions may be placed on the same line by separating them with semicolons:

MOVE $000 10; INC $000; INC $000

These coalesced instructions execute sequentially from left to right while remaining part of the same program line.

This distinction is important for control flow. Labels, relative line references, and the program counter refer to complete program lines, not individual coalesced instructions.

Writing to the program counter (pc) immediately ends the current line. Any remaining coalesced instructions are skipped.

MOVE $000 10; JUMP :next; MOVE $000 20

If the JUMP executes, MOVE $000 20 does not.

A conditional branch only ends the line when the branch is taken:

MOVE $000 10; BEQ :done $000 20; MOVE $001 42

Because the comparison is false, the branch does not write to pc and execution continues with MOVE $001 42.

If a line completes without writing to pc, execution continues with the following program line.

Operands

Instructions interpret their operands according to the operation being performed.

Instruction documentation uses several common operand types:

Type Description
Memory reference A location that may be read or written.
Integer value A value interpreted as a 32-bit signed integer.
String value A value interpreted as a string.
Floating-point value A value interpreted as an IEEE 754 binary32 number.
Vector value A value interpreted as a three-component vector.
Rotation value A value interpreted as a four-component rotation.
Branch target A program line used for control flow.

Memory does not assign a type to a stored value. The instruction determines how that value is interpreted.

For example:

S.MOVE $000 "0xFF"
MOVE $001 $000

S.MOVE treats its source as a string, so $000 receives:

0xFF

MOVE treats its source as an integer, so $001 receives:

255

The same principle applies to floating-point, vector, and rotation operations. These values are stored in ordinary memory and interpreted by the instruction that consumes them.

Memory references and addressing are described in Memory & Stack.

Integer Literals

Integer literals may be written in decimal:

0
42
-42

Binary literals use the 0b prefix:

0b0
0b101010
0B11111111
-0b1010

Octal literals use the 0o prefix:

0o0
0o52
0O377
-0o12

Hexadecimal literals use the 0x prefix:

0xFF
0xff
0X1000
-0x2A

Binary, octal, and hexadecimal literals are converted to decimal during the program pre-pass.

For example, these instructions are equivalent at execution:

MOVE $000 255
MOVE $000 0b11111111
MOVE $000 0o377
MOVE $000 0xFF

Each passes the decimal value 255 to MOVE.

The prefixes are part of NCL source syntax. They indicate how the digits that follow should be interpreted:

Prefix Base Digits
0b 2 0–1
0o 8 0–7
0x 16 0–9, A–F

Prefix letters and hexadecimal digits are case-insensitive.

Floating-Point Literals

Floating-point literals begin with f:

f0
f1
f1.0
f.5
f-1
f-1.5
f-.5

The f prefix identifies the operand as a floating-point literal. A decimal point is not required:

F.MOVE $000 f42

Floating-point literals are converted to their string representation during the program pre-pass. The f prefix is source syntax and is not stored as part of the value.

For example:

F.MUL $000 f3.14159 f2

passes ordinary textual values to the Floating-Point Coprocessor for interpretation.

Floating-point representation and operations are described in Floating Point.

Vector Literals

Vector literals contain three floating-point components enclosed in angle brackets:

<1, 2, 3>
<0.5, -1, 4>
<0, 0, 0>

A vector literal represents a single operand despite containing whitespace and multiple components.

Vector literals are converted to their string representation during the program pre-pass. The resulting value is stored and passed like any other string-backed value.

For example:

V.MOVE $000 <1, 2, 3>

stores the vector representation in $000.

Vector operations are described in Vectors & Rotations.

Rotation Literals

Rotation literals contain four floating-point components enclosed in angle brackets:

<0, 0, 0, 1>
<0, 0, 0.707107, 0.707107>

Like vector literals, a rotation literal represents a single operand and is converted to its string representation during the program pre-pass.

Vectors and rotations use the same source-level compound notation. The consuming instruction determines whether the value is interpreted as a vector or a rotation.

V.MOVE $000 <1, 2, 3>
V.ROT.MOVE $001 <0, 0, 0, 1>

Rotation operations are described in Vectors & Rotations.

String Literals

String literals are enclosed in double quotation marks:

"Hello, world!"
"42"
""

Strings may contain escape sequences beginning with a backslash:

"Hello\nWorld"
"She said \"Hello!\""

Escape sequences are resolved during the program pre-pass.

Named Escapes

Escape Character Codepoint Description
\" " U+0022 Double quotation mark.
\\ \ U+005C Backslash.
\a BEL U+0007 Alert.
\b BS U+0008 Backspace.
\t HT U+0009 Horizontal tab.
\n LF U+000A Line feed.
\v VT U+000B Vertical tab.
\f FF U+000C Form feed.
\r CR U+000D Carriage return.
\e ESC U+001B Escape.
\i IND U+0084 Index.
\j RI U+008D Reverse index.
\c ADV U+0091 Cursor advance.
\d DEL U+0092 Delete.

Hexadecimal Escapes

\xXX inserts a character using a two-digit hexadecimal value:

"\x41"
-- > "A"

Unicode Escapes

\uXXXX inserts a character using a four-digit Unicode codepoint:

"\u03BB"
-- > "λ"

\UXXXXXXXX accepts an eight-digit Unicode codepoint:

"\U0001F680"
-- > "🚀"

Display Style Escapes

\sXX inserts a character in the private-use range U+F100 through U+F1FF.

The two hexadecimal digits become the low byte of the codepoint:

"\s12"
-- > U+F112

Compatible displays use these characters for inline text attributes such as colour and style.

Unknown Escapes

Unknown escape sequences are permissive. The backslash is removed and the following character is retained:

"\q"
-- > "q"

Value Interpretation

Values are interpreted according to the instruction consuming them.

Memory itself is untyped. A memory cell contains a string, and different instructions may interpret that same string in different ways.

Integer Interpretation

When an instruction expects an integer, the value is converted to a 32-bit signed integer:

MOVE $000 "42"
MOVE $001 "0xFF"

results in:

$000 = "42"
$001 = "255"

Integer conversion is permissive. A numeric prefix may be followed by other text:

MOVE $000 "42 apples"
-- > $000 = "42"

A value that does not begin with a valid integer converts to 0:

MOVE $000 "apples"
-- > $000 = "0"

String Interpretation

When an instruction expects a string, the value is used as text.

Integer source values therefore appear in their decimal representation:

S.MOVE $000 42
-- > $000 = "42"

String operations otherwise preserve the textual representation of their operands.

Floating-Point Interpretation

When an instruction expects a floating-point value, the operand is interpreted as an IEEE 754 binary32 value.

S.MOVE $000 "1.5"
F.MUL $001 $000 f2
-- > $001 = "3.000000"

Floating-point conversion follows the behavior of the Floating-Point Coprocessor. See Floating Point for representation, precision, and mathematical behavior.

Vector Interpretation

When an instruction expects a vector, the operand is interpreted as a three-component floating-point vector:

S.MOVE $000 "<1, 2, 3>"
V.MAG $001 $000

The stored value does not become a distinct memory type. $000 remains an ordinary string-backed memory location.

Rotation Interpretation

When an instruction expects a rotation, the operand is interpreted as a four-component rotation:

S.MOVE $000 "<0, 0, 0, 1>"
V.ROT.APPLY $001 <1, 0, 0> $000

Vectors and rotations may therefore use the same underlying textual representation while remaining semantically distinct to the instructions that consume them.

The same memory location may consequently be interpreted as an integer, string, floating-point value, vector, or rotation. The stored value does not determine its type; the instruction determines its interpretation.