moa/src/bin/m68kas.rs
transistor 62a484d317 Modified the parser to work on the entire input
Previously it was going line by line, but that makes it hard to
properly parse multiline comments, so I modified it to include line
terminators in the token stream.  I also added parsing of /* */
and | \n comment types.  There is still a problem with line numbers
in the post-parsing phases, but they seem correct in the parser/lexer
stage.  It's still not able to parse the syscall.s file from Computie
but it's mostly just issues with named constants preceeded by a
"#" or "-" character.  As for the encoding stage, it has a problem
with a move instruction that uses a label.
2022-05-15 20:44:36 -07:00

28 lines
599 B
Rust

use std::fs;
use std::env;
use moa::cpus::m68k::M68kType;
use moa::cpus::m68k::assembler::M68kAssembler;
fn main() {
let mut assembler = M68kAssembler::new(M68kType::MC68000);
let filename = env::args().nth(1).unwrap();
let text = fs::read_to_string(filename).unwrap();
match assembler.assemble_words(&text) {
Ok(words) => {
println!("Output:");
for word in words.iter() {
print!("{:04x} ", word);
}
println!("");
},
Err(err) => {
println!("{}", err.msg);
},
};
}