mirror of
https://github.com/transistorfet/moa.git
synced 2024-05-29 04:41:29 +00:00
62a484d317
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.
28 lines
599 B
Rust
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);
|
|
},
|
|
};
|
|
}
|
|
|