Skip to content

Commit

Permalink
Fix the mapping of addresses on labels
Browse files Browse the repository at this point in the history
There was a big missunderstanding on how things were to be laid out in
the end file, and so it was needed to create a proper understanding on
what's a Mapping and what's a Segment. These turned out to be
fundamental concepts that I failed to grok up until this commit.

Hence, this commit re-arranges completely how variables and labels are
stored in the Context, and how these objects can then be translated into
bundles that can be spit out to the caller.

This commit, besides introducing the new Mapping struct, also introduced
a more general Object, which abstracts things from the Bundle struct,
and allows us to pass certain metadata about the bundle at hand.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Dec 16, 2024
1 parent 7ade650 commit 1d0bb4d
Show file tree
Hide file tree
Showing 5 changed files with 867 additions and 328 deletions.
6 changes: 3 additions & 3 deletions crates/nasm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap::Parser as ClapParser;
use std::fs::File;
use std::io::{self, Read, Write};
use xixanta::assembler::Assembler;
use xixanta::mapping::{Segment, EMPTY, NROM, NROM65};
use xixanta::mapping::{Mapping, EMPTY, NROM, NROM65};

/// Assembler for the 6502 microprocessor that targets the NES.
#[derive(ClapParser, Debug)]
Expand Down Expand Up @@ -57,7 +57,7 @@ fn main() -> Result<()> {
};

// Select the linker configuration.
let segments: Vec<Segment> = match args.config {
let mapping: Vec<Mapping> = match args.config {
Some(c) => match c.to_lowercase().as_str() {
"empty" => EMPTY.to_vec(),
"nrom" => NROM.to_vec(),
Expand All @@ -71,7 +71,7 @@ fn main() -> Result<()> {
};

// Initialize the assembler with the given linker configuration.
let mut assembler = Assembler::new(segments);
let mut assembler = Assembler::new(mapping);

// After the parse operation, just print the results.
if args.disassemble {
Expand Down
Loading

0 comments on commit 1d0bb4d

Please sign in to comment.