Campus LIsP (32K)

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
User avatar
stefano
Posts: 568
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Campus LIsP (32K)

Post by stefano »

EDIT - This is a buch better version !!!

This is my port for a 32K expanded zx81 od the "Campus LIsP" interpreter.

It is quite barebones, the simple line editor uses the printer buffer: I strongly suggest to type a NEWLINE when you fill 2 text lines. In any case a cursor is shown and backspace is now available.

It is a bit toy Language (no iteration structures, no strings nor "lambda" are supported, no load/save) but you have enough to enjoy quite powerful recursion experiments.
Decimal numebrs are not supported, the range for integers is +/- 120.000.000 and math should be fast.

The native commands are:
t, nil, read, eval, gc, cons, car, cdr, quit, defun, quote (or "), setq, eq, null, atom, numberp, princ, terpri, rplaca, rplacd, progn, cond, and, or, not, list, +, -, *, /, divide, >, <, >=, <=, even?, odd?, comment, zerop, symbp, consp, random, rem (in place of '%'), if, 1+, 1-, equal, =

More commands can be added by typing them .. see library.l
hanoi.jpg
hanoi.jpg (93.4 KiB) Viewed 2872 times
gcd.jpg
gcd.jpg (94.02 KiB) Viewed 2872 times
Attachments
clisp.zip
Campus LIsP interpreter - 32K
(22.61 KiB) Downloaded 133 times
Last edited by stefano on Wed Apr 08, 2015 10:24 am, edited 2 times in total.
User avatar
stefano
Posts: 568
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Campus LIsP (32K)

Post by stefano »

I must apologize, I left too little space for the regular z80 stack !
A fixed version will follow soon, atm you can just try simple algebric stuff, e.g. (* 3 4 5 6)
Moggy
Posts: 3267
Joined: Wed Jun 18, 2008 2:00 pm

Re: Campus LIsP (32K)

Post by Moggy »

I'm quite fond of the idea of trying new languages on the Zeddy, many thanks for this Stefano. :D
User avatar
stefano
Posts: 568
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Campus LIsP (32K)

Post by stefano »

EDIT - The minimalistic version is now deprecated, the full version should now be in full working condition..
clisp.jpg
clisp.jpg (61.43 KiB) Viewed 2906 times
I'm ashamed for not having noticed that bug.
In the meantime I post the minimalistic version. Some of the missing functions (1+, zerop, etc..) can be added by typing them:


; factorial, minimalistic mode example
(defun fact (n)
(cond ((< n 1)
1)
(t
(* n (fact (- n 1))))))


; print
(defun print (n) (progn (terpri) (princ n)))

; zero?
(defun zerop (n)
(eq n 0))

; greater than or equal to?
(defun >= (n1 n2)
(or (> n1 n2) (= n1 n2)))

; less than or equal to?
(defun <= (n1 n2)
(or (< n1 n2) (= n1 n2)))

; eq?
(defun = (n1 n2)
(eq n1 n2))

; increment
(defun 1+ (n)
(+ n 1))

; decrement
(defun 1- (n)
(- n 1))

; remainder
(defun % (a b) (- a (* (/ a b) b)))

; sum
(defun sum (n)
(cond ((< n 1)
0)
(t
(+ n (sum (- n 1))))))

; power
(defun power (x n)
(cond ((< n 1)
1)
(t
(* x (power x (- n 1))))))

; equal
(defun equal (s1 s2)
(cond ((atom s1)
(eq s1 s2))
((not (atom s2))
(and (equal (car s1) (car s2))
(equal (cdr s1) (cdr s2))))
(t
nil)))
Attachments
a.P
(14.07 KiB) Downloaded 132 times
User avatar
stefano
Posts: 568
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Campus LIsP (32K)

Post by stefano »

Yet another cute example 8-)

Please note that the LIsP on the top of this page is now updated and fully working (I understand that a LOAD/SAVE function would be appreciated).

pairlis.jpg
pairlis.jpg (65.65 KiB) Viewed 2865 times
User avatar
stefano
Posts: 568
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Campus LIsP (32K)

Post by stefano »

SAVELOAD/CLISPB.P is a variant thought for ZXPAND or similar devices. It does not initialize the instruction set, it expects it in the higher 16K block.
To run such variant it is necessary to load clisp.p and to load a ".sav" memory block at position 32768. It won't work without the pre-loaded command set.
I'm providind two savefiles, a standard one and a full version provinding also:

print positivep negativep expt abs endp nthcdr nth last reverse append revappend memq member length union intersection copy-list copy-tree subst assv set-difference count-leaves acons sublis pairlis apply

The little extra space gained by removing the initialization stuff should leave enough space for simple BASIC operation to LOAD/SAVE such block (pos:32768 len:16384).

Issuing a (QUIT) command from within LIsP will return to BASIC and permit to save a copy of the mentioned block with any extra element/function you may have defined.

..it is now time to try writing a real program :S
Attachments
clispb.zip
(35.67 KiB) Downloaded 145 times
User avatar
stefano
Posts: 568
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Campus LIsP (32K)

Post by stefano »

I just put in this beauty a new embedded function called "while" based on the idea of the same simplification made for EMACS lisp. Since there is still an annoying bug not protecting from memory overflows I'm waiting before posting the new (final) version. BTW be aware that the final version won't be compatible with the current memory save snapshots.

I'll announce the final version in the SOFTWARE section, probably more suitable.. perhaps this topic could be moved as well ?
User avatar
stefano
Posts: 568
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Campus LIsP (32K)

Post by stefano »

As already said, it continues in the software section:

viewtopic.php?f=11&t=1630&sid=33550e759 ... b8d4b88a2a
Post Reply