Getting Started
Learn how to install and use the RAM language
Installation
RAM is available as an npm package. You can install it globally using npm, yarn, or pnpm.
Using npm
Using yarn
Using pnpm
After installation, you should have access to the ram command in your terminal.
Verifying Installation
To verify that RAM is installed correctly, run:
You should see the version number of the installed RAM CLI.
Your First RAM Program
Let's create a simple RAM program that adds two numbers. Create a file named add.ram with the following content:
Understanding the Program
This program performs the following operations:
LOAD 1: Loads the value stored at memory address 1 into the accumulatorADD 2: Adds the value stored at memory address 2 to the accumulatorSTORE 3: Stores the result (now in the accumulator) to memory address 3HALT: Stops the program execution
Running the Program
To run the program, use the ram run command:
By default, the memory locations are initialized to 0. To provide input values, you can use the --memory flag:
This sets memory address 1 to 5 and memory address 2 to 7. After running the program, memory address 3 should contain 12 (the sum of 5 and 7).
Next Steps
Now that you've written and run your first RAM program, you can:
- Learn more about the RAM language syntax
- Explore the available instructions
- Check out more complex examples
The RAM language is designed to be simple yet powerful. As you become more familiar with it, you'll be able to write increasingly complex programs to solve a variety of computational problems.