Skip to content

Add a LMC assembler#11

Merged
RandomSearch18 merged 24 commits intomasterfrom
rmc-asm
Nov 10, 2025
Merged

Add a LMC assembler#11
RandomSearch18 merged 24 commits intomasterfrom
rmc-asm

Conversation

@RandomSearch18
Copy link
Owner

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an assembler for the Little Man Computer (LMC) assembly language, enabling users to write programs in assembly and compile them to machine code binary files. It also updates the Cargo dependencies and editions.

  • Introduces a new rmc_assemble binary for assembling LMC assembly programs
  • Expands the Value API with methods for digit manipulation and binary serialization
  • Updates project documentation with instructions for assembling custom programs

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/rmc_assemble.rs New assembler implementation with parsing, label resolution, and machine code generation
src/lib.rs Adds from_digits and to_be_bytes methods to Value, makes value module public
src/main.rs Reorders import statements (cosmetic change)
demos/add.lmc Example LMC assembly program for demonstration
README.md Updates documentation to reference the new assembler tool
Cargo.toml Adds rmc_assemble binary configuration, updates edition specification
Cargo.lock Updates dependency versions and lock file format version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +48 to +56
pub fn from_digits(first_digit: i16, last_two_digits: i16) -> Result<Value, &'static str> {
if !(0..=9).contains(&first_digit) {
return Err("First digit out of range");
}
if !(0..=99).contains(&last_two_digits) {
return Err("Last two digits out of range");
}
Value::new(first_digit * 100 + last_two_digits).or(Err("Value out of range"))
}
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The from_digits function should have documentation explaining its purpose, parameters, return value, and potential errors. For example, clarify that it constructs a value from a first digit (0-9) and last two digits (0-99) to form a three-digit number.

Copilot uses AI. Check for mistakes.
@RandomSearch18 RandomSearch18 changed the title Create a LMC assembler Add a LMC assembler Nov 10, 2025
@RandomSearch18 RandomSearch18 merged commit 681ef88 into master Nov 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants