comfy cat added by Kooda on Thu Nov 5 13:16:41 2020

(load "comfy.k")
(load "elf.k")
(load "syscalls.k")

(init-memory! 144)

($define! buf #x100)

($define! exit
    (seq (addi a0 zero 0)
         (addi a7 zero SYS_exit)
    0 0)) ;; never uses continuations

($define! entry
      (seq (addi a0 zero 0)
           (addi a1 zero buf)
           (addi a2 zero 256)
           (addi a7 zero SYS_read)
           (>? a0 zero) ;; read() returns 0 on end of input
           (addi a2 a0 0)
           (addi a0 zero 1)
           (addi a7 zero SYS_write)
    0 ;; loops forever of exit when test fails

(gen-elf-header! entry)
(save-bytevector "cat" (memory-vector))
(display "entry: ") (display entry) (newline)