Recently Written · git

forthlisp-stm32

STM32F446 target for forthlisp: Thumb-2 Forth kernel built by an SBCL assembler, QEMU netduinoplus2

git clone https://github.com/equwal/forthlisp-stm32

Log | Files | Refs


transcript.txt (1613 bytes)

1 
2 === Layer 1: host Lisp compiles Lisp to Forth and runs it on the chip ===
3   ok.
4 [compiled] : sq dup over * nip ;
5 : sq dup over * nip ;  ok.
6 [compiled] : fact dup 2 < if 1 else dup over 1 - recurse * then nip ;
7 : fact dup 2 < if 1 else dup over 1 - recurse * then nip ;  ok.
8 7 sq . 49  ok.
9 10 fact . 3628800  ok.
10 
11 === Layer 2: load the Forth Lisp (core lisp.fs + prims compiled from prims.lisp) ===
12 unused . 23988  ok.
13  23988  ok.
14 
15 === Layer 3: Lisp (host) -> Forth (chip) -> Lisp (chip) ===
16 lisp 
17 > (+ 1 2) 
18 3
19 > (+ 1 2) => 3
20 (define (sq x) (* x x)) 
21 sq
22 > (define (sq x) (* x x)) => sq
23 (sq 7) 
24 49
25 > (sq 7) => 49
26 (define (fact n) (if (< n 2) 1 (* n (fact (- n 1))))) 
27 fact
28 > (define (fact n) (if (< n 2) 1 (* n (fact (- n 1))))) => fact
29 (fact 7) 
30 5040
31 > (fact 7) => 5040
32 (cons 1 (cons 2 '())) 
33 (1 2)
34 > (cons 1 (cons 2 '())) => (1 2)
35 (car '(a b c)) 
36 a
37 > (car '(a b c)) => a
38 (define (my-map f l) (if (null? l) '() (cons (f (car l)) (my-map f (cdr l))))) 
39 my-map
40 > (define (my-map f l) (if (null? l) '() (cons (f (car l)) (my-map f (cdr l))))) => my-map
41 (my-map sq '(1 2 3 4)) 
42 (1 4 9 16)
43 > (my-map sq '(1 2 3 4)) => (1 4 9 16)
44 ((lambda (x y) (- x y)) 10 3) 
45 7
46 > ((lambda (x y) (- x y)) 10 3) => 7
47 (map fact '(1 2 3 4 5)) 
48 (1 2 6 24 120)
49 > (map fact '(1 2 3 4 5)) => (1 2 6 24 120)
50 (let loop ((i 0)) (if (< i 10000) (loop (+ i 1)) i)) 
51 10000
52 > (let loop ((i 0)) (if (< i 10000) (loop (+ i 1)) i)) => 10000
53 (eq? (car '(a)) 'a) 
54 #t
55 > (eq? (car '(a)) 'a) => #t
56 (< 2 1) 
57 #f
58 > (< 2 1) => #f
59 (forth) 
60  ok.
61 (forth) => back at the Forth prompt
62 unused . 23988  ok.
63  23988  ok.
64 
65 SUCCESS: all three layers answered as expected.