console_debug/
console_debug.rs1use uxn_tal::{Assembler, AssemblerError};
2
3fn main() -> Result<(), AssemblerError> {
4 let console_test = r#"
8 |0100
9
10 ( Test different console approaches )
11
12 ( Approach 1: Direct console write )
13 #41 #18 DEO ( 'A' to console port 0x18 )
14
15 ( Approach 2: Try stderr console )
16 #42 #19 DEO ( 'B' to console port 0x19 )
17
18 ( Approach 3: Standard output )
19 #43 #18 DEO ( 'C' to console port 0x18 )
20
21 ( Add newline )
22 #0a #18 DEO
23
24 BRK
25 "#;
26
27 let mut assembler = Assembler::new();
28 let rom = assembler.assemble(console_test, Some("console_debug.rs".to_owned()))?;
29 std::fs::write("console_test.rom", &rom)?;
30
31 println!("Created console_test.rom");
32 println!("This should output 'ABC' followed by newline");
33
34 let _working_example = r#"
36 |0100
37
38 ( Hello World - standard console pattern )
39 ;hello print-string
40 BRK
41
42 @print-string ( str* -- )
43 &loop
44 LDAk #18 DEO
45 INC2
46 LDAk ,&loop JCN
47 POP2
48 JMP2r
49
50 @hello "Hello! 00
51 "#;
52
53 let simple_hello = r#"
55 |0100
56 #48 #18 DEO ( H )
57 #65 #18 DEO ( e )
58 #6c #18 DEO ( l )
59 #6c #18 DEO ( l )
60 #6f #18 DEO ( o )
61 #21 #18 DEO ( ! )
62 #0a #18 DEO ( newline )
63 BRK
64 "#;
65
66 let mut assembler2 = Assembler::new();
67 let rom2 = assembler2.assemble(
68 simple_hello,
69 Some("console_debug.rs:simple_hello".to_owned()),
70 )?;
71 std::fs::write("simple_hello.rom", &rom2)?;
72
73 println!("Created simple_hello.rom");
74 println!("This should output 'Hello!'");
75
76 Ok(())
77}