Syntax
Overview of the RAM language syntax
Program Structure
A RAM program consists of a sequence of lines, each containing one of the following:
- An instruction (optionally preceded by a label)
- A label definition
- A comment
- A module declaration or import statement
Example
Comments
Comments in RAM start with a # character and continue until the end of the line:
Labels
Labels are identifiers that mark specific positions in the code. They can be used as targets for jump instructions:
Labels must be followed by an instruction and can only contain alphanumeric characters and underscores.
Instructions
Instructions are the basic building blocks of RAM programs. Each instruction consists of an opcode and, optionally, an operand:
See the Instructions page for a complete list of available instructions.
Operands
Operands specify the data that instructions operate on. RAM supports several addressing modes:
See the Operands page for more details on addressing modes.
Modules
RAM supports a module system similar to Rust's, allowing you to organize your code into separate files:
See the Modules page for more information on the module system.
Whitespace and Formatting
RAM is not sensitive to whitespace, except for separating tokens. You can use spaces and tabs for indentation according to your preference.
Case Sensitivity
RAM is case-sensitive. For example, LOAD and load are considered different instructions.
Line Continuation
RAM does not support line continuation. Each instruction must be on a single line.