]> rethought.computer Git - sorel-lang.git/commitdiff
working puts keep/0412517544d4b63a90722aedcf9ca5be6bd5c47f
authorBryan English <bryan@rethought.computer>
Mon, 2 Feb 2026 03:50:47 +0000 (03:50 +0000)
committerBryan English <bryan@rethought.computer>
Tue, 10 Feb 2026 04:08:54 +0000 (04:08 +0000)
rel-lang/a.out [deleted file]
rel-lang/rel-ir/src/lib.rs
rel-lang/relc/src/ir.rs
rel-lang/relc/src/riscv_asm_codegen.rs
rel-lang/stdlib/out.rel
rel-lang/stdlib/test.sh

diff --git a/rel-lang/a.out b/rel-lang/a.out
deleted file mode 100644 (file)
index e69de29..0000000
index bb2550215482177b4c34200686735d7eed860aba..699dbba189adb026ceb2dbc505148425e73d6e22 100644 (file)
@@ -33,7 +33,6 @@ pub enum IR {
     Drop,
     Over,
     Rot,
-    PutS,
     PutN,
     If,
     Else,
index 003194b34e140c88350695637d117765ae059643..23309203943eb0ffbfa8ab17700e6e7419bce1a0 100644 (file)
@@ -121,7 +121,6 @@ impl ImportTree {
                             "drop" => IR::Drop,
                             "over" => IR::Over,
                             "rot" => IR::Rot,
-                            "puts" => IR::PutS,
                             "putn" => IR::PutN,
                             "if" => IR::If,
                             "else" => IR::Else,
index 69b39b4209307987c0c46d3d8a3950e6fb0a19ad..f2e99365f4ec1470456d5a0f3a081877e164d60d 100644 (file)
@@ -320,7 +320,7 @@ impl<'a> CodeGen<'a> {
                     self.label(format!("_endloop_{}:", loop_counter));
                     stack.pop();
                 },
-                _ => bail!("not implemented yet"),
+                _ => bail!("not implemented yet: {:?}", ir),
             }
         }
 
index 381d690f8a3552c0ff6c944b9478e5f467c06218..28f745d4602cdd3eb830f2865c03b1df6afb603a 100644 (file)
     1 + \ ( addr addr+1 )
     dup \ ( addr addr+1 addr+1)
     @:8 \ ( addr addr+1 byte )
-  endloop
-  drop \ ( addr addr+len )
+  endloop \ ( addr addr+len )
   swap \ ( addr+len addr )
   - \ ( len )
 ;
 
-"this is a string" strlen
+: puts ( addr -- addr)
+  dup dup \ ( addr addr addr )
+  strlen \ ( addr addr len )
+  1 \ ( addr addr len 1 )
+  rot \ ( addr len 1 addr )
+  rot \ ( addr 1 addr len )
+  write \ ( addr bytes-written-or-err )
+  drop \ ( addr )
+;
+
+"Hello, World! \n" puts
index c4469279196846de4c0833a840e3887980994f86..0d32765545c864577aa96bdcebf0f49669f1905a 100644 (file)
@@ -4,6 +4,6 @@
 # ./test-mem.out
 
 ../target/debug/relc out.rel
-riscv64-unknown-linux-gnu-as -o out.o out.asm
-riscv64-unknown-linux-gnu-cc -O1 -no-pie -o test-out.out putn.c out.o -nostartfiles 
+as -o out.o out.asm
+cc -O1 -no-pie -o test-out.out out.o putn.c -nostartfiles 
 ./test-out.out