https://github.com/apavazza/asm-interpreter
Interactive assembly interpreter written in Rust
https://github.com/apavazza/asm-interpreter
assembly interpreter rust
Last synced: 2 months ago
JSON representation
Interactive assembly interpreter written in Rust
- Host: GitHub
- URL: https://github.com/apavazza/asm-interpreter
- Owner: apavazza
- License: gpl-3.0
- Created: 2025-04-10T14:11:25.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-19T21:27:56.000Z (about 1 year ago)
- Last Synced: 2025-06-13T00:40:50.938Z (about 1 year ago)
- Topics: assembly, interpreter, rust
- Language: Rust
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Assembly Interpreter
[](https://github.com/apavazza/asm-interpreter/actions/workflows/tests.yml)
[](https://github.com/apavazza/asm-interpreter/actions/workflows/build-and-release.yml)

[](LICENSE)
Assembly Interpreter is a simple interactive command-line tool built in Rust. It simulates basic assembly language operations for educational and testing purposes.
## Supported Instructions
- **MOV `, `**
Sets the given register to a specified value. The value can be an immediate constant prefixed with `#` (supports hexadecimal with `#0x` and decimal, e.g. `#15`) or the value from another valid register.
*Example*: `MOV r0, #15`
- **ADD `, , `**
Adds the value in the first operand register and the second operand (which may be an immediate constant or a register) and stores the result in the destination register.
*Example*: `ADD r0, r1, #5`
- **SUB `, , `**
Subtracts the second operand (immediate or register value) from the value in the first operand register and stores the result in the destination register.
*Example*: `SUB r0, r1, r2`
- **LSL `, , `**
Performs a logical left shift on the source register by the specified shift amount and stores the result in the destination register.
*Example*: `LSL r0, r1, #2`
- **LSR `, , `**
Performs a logical right shift on the source register by the specified shift amount and stores the result in the destination register.
*Example*: `LSR r0, r1, #3`
- **ASR `, , `**
Performs an arithmetic right shift on the source register by the specified amount and stores the result in the destination register.
*Example*: `ASR r0, r1, #1`
- **ROR `, , `**
Rotates the bits of the source register to the right by the specified rotate amount and stores the result in the destination register.
*Example*: `ROR r0, r1, #4`
- **RRX `, `**
Performs a rotate-right with extend (RRX) on the source register (rotates right by 1 bit using an assumed zero carry) and stores the result in the destination register.
*Example*: `RRX r0, r1`
- **PRINT ``**
Displays the current value of the specified register.
*Example*: `PRINT r0`
- **EXIT**
Terminates the program.
## Example Usage
```shell
MOV r1, #5
MOV r2, #10
ADD r3, r1, r2
SUB r4, r2, r1
LSL r5, r1, #3
LSR r6, r2, #1
ASR r7, r1, #2
ROR r8, r2, #2
RRX r9, r1
PRINT r3
PRINT r4
EXIT
```
## Additional Notes
- Registers that have not been explicitly set are assumed to have a default value of `0`.
- The interpreter expects commands to be well-formed and does not perform extensive input validation.
- Commas are required between command arguments as shown in the examples above.
## License
This software is provided under the terms of the [GNU General Public License v3.0](LICENSE).