1use uxn_tal::{Assembler, AssemblerError};
2
3fn main() -> Result<(), AssemblerError> {
4 let minimal_source = r#"
6 |0100
7 #41 #10 DEO ( Output 'A' to console device 0x10 )
8 BRK
9 "#;
10
11 let mut assembler = Assembler::new();
12 let rom = assembler.assemble(minimal_source, Some("(minimal)".to_owned()))?;
13 std::fs::write("minimal.rom", &rom)?;
14
15 println!("Created minimal.rom ({} bytes)", rom.len());
16 println!("This ROM should output the letter 'A' and then halt.");
17 println!();
18 println!("ROM contents at 0x100:");
19 println!(" 0x100: 0x{:02x} (should be 0x41 = 'A')", rom[0]);
20 println!(
21 " 0x101: 0x{:02x} (should be 0x10 = console device)",
22 rom[1]
23 );
24 println!(
25 " 0x102: 0x{:02x} (should be 0x17 = DEO instruction)",
26 rom[2]
27 );
28 println!(
29 " 0x103: 0x{:02x} (should be 0x00 = BRK instruction)",
30 rom[3]
31 );
32 println!();
33 println!("Try: uxnemu minimal.rom");
34
35 Ok(())
36}