; memory map M[.] ; code 0..500 ; global 1000..1100 ; symtab 2000..2999 ; global ; 1000 CH ; 1001 CS ; 1002 CP 1 call boot 2 end ; isNum c 20 fun 1 21 get 1 22 lit 48 23 ge 24 get 1 25 lit 57 26 le 27 and 28 ret 2 ;; isSpace c 29 fun 1 30 get 1 31 lit 32 32 eq 33 get 1 34 lit 10 35 eq 36 or 37 get 1 38 lit 0 39 lt 40 or 41 ret 2 ;; readc {c} 60 fun 2 61 sys 3 62 put 1 63 get 1 64 st 1000 65 get 1 66 ret 2 ;; readi c { n pos} 70 fun 3 71 get 3 72 lit 48 73 sub 74 put 2 75 get 2 76 put 1 77 jmp x loop: 78 get 2 79 lit 10 80 mul 81 ld 1000 82 add 83 lit 48 84 sub 85 put 2 x: 86 call readc 87 call isspace 88 not 89 jt loop 90 get 1 91 jf y 92 get 2 93 ret 4 y: 94 lit 0 95 get 2 96 sub 97 ret 4 ;; boot {op arg i} 100 fun 4 101 call readc 102 call readi 103 put 3 104 jmp x loop: 105 call readc 106 call readi 107 put 2 108 get 3 109 sys 1 110 lit 32 111 sys 2 112 get 2 113 sys 1 114 lit 10 115 sys 2 116 call readc 117 call readi 118 put 3 x: 119 get 3 120 lit 0 121 ne 122 jt loop 123 ret 4 ; test boot ; with some s-object 32 17 23 0 38 1 0