mirror of
https://github.com/transistorfet/moa.git
synced 2024-06-10 22:29:41 +00:00
586a16509f
It can encode some basic instructions but not the more complicated addressing modes or special instructions. It can keep track of labels and patch the displacement addresses after assembling the output data, but it doesn't check for duplicates or that a label has been declared before it appears. It also doesn't take into account the origin yet. To run it, there is an m68kas command that will take a file and print the data: ``` cargo run -p moa --bin m68kas <filename> ``` It's not yet tied into the rest of the system, but could be used in the debugger to allow insertion of new code into a running system.
23 lines
463 B
Rust
23 lines
463 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();
|
|
|
|
let words = assembler.assemble_words(&text).unwrap();
|
|
|
|
println!("Output:");
|
|
for word in words.iter() {
|
|
print!("{:04x} ", word);
|
|
}
|
|
println!("");
|
|
}
|
|
|