diff --git a/stage1/words.s b/stage1/words.s index 2976a8c..ce48973 100644 --- a/stage1/words.s +++ b/stage1/words.s @@ -278,6 +278,12 @@ INITIAL_WORDS: .ascii "unbox-integer$" .balign 8 + .quad WORDS + .byte 6 + .byte LISP_OBJECT_TYPE_INTEGER + .ascii "words$" + .balign 8 + # end .quad 0 .quad 0 diff --git a/stage2/03-list-util.lsp b/stage2/03-list-util.lsp index 2689e88..616084f 100644 --- a/stage2/03-list-util.lsp +++ b/stage2/03-list-util.lsp @@ -65,3 +65,13 @@ (eval scope (car args)) (eval scope (cadr args))))))) +; (range 0 5) => (0 1 2 3 4) +(define range + (proc args scope + (let1 start (eval scope (car args)) + (let1 end (eval scope (cadr args)) + (if (zero? (car (call-native -$ 1 end start))) + () + (cons start (range + (car (call-native +$ 1 start 1)) + end))))))) \ No newline at end of file diff --git a/stage2/22-words-util.lsp b/stage2/22-words-util.lsp new file mode 100644 index 0000000..307f956 --- /dev/null +++ b/stage2/22-words-util.lsp @@ -0,0 +1,7 @@ +(define get-words (fn (index) + (let1 addr (peek.d (+ words$ (<< index 3))) + (seq + (call-native acquire-object$ 0 addr) + (deref addr)))))) + +;(map (fn (index) (length (get-words index))) (range 0 63))