Operands
Understanding operands and addressing modes in RAM
Addressing Modes
Direct Addressing
Direct addressing refers to a memory location directly. The operand specifies the address to access:
Indirect Addressing
Indirect addressing uses the value at a memory location as the address to access. This is indicated by an asterisk (*) before the operand:
For example, if memory address 5 contains the value 10, then LOAD *5 will load the value from memory address 10.
Immediate Addressing
Immediate addressing uses the operand value directly, rather than treating it as an address. This is indicated by an equals sign (=) before the operand:
Register Addressing
Register addressing refers to a specific register. This is indicated by the letter 'R' followed by the register number:
The accumulator is register R0, so LOAD R0 is equivalent to loading the accumulator's value into itself.
Array Access
RAM supports array-like access with the syntax base[index]:
This is equivalent to LOAD 8 in this case.
You can combine array access with other addressing modes:
Label References
Labels can be used as operands in jump instructions:
Expressions
Some RAM implementations support simple expressions as operands:
However, this feature may not be available in all implementations.
Examples
Here are some examples of different addressing modes in action:
The behavior of operands may vary slightly between different RAM implementations. Always refer to the documentation for your specific implementation for the most accurate information.