This zip contains minilisp (mlisp850). It compiles with glcc, but does not run as it should?
(Under Mac OS, it runs fine and on input (+ 1 2) it answers correct with 3..)
make output:
../../build/glcc -o lisp850.gt1 lisp850.c -map=64k -rom=v5a
lisp850.c:73: warning: expression with no effect elided
lisp850.c:74: warning: expression with no effect elided
lisp850.c:105: warning: missing return value
So this is currently NOT running as it should.
Maybe some c expert want to give it a try
That's because the Gigatron double format is not IEEE754 but period correct Microsoft floating point (5 bytes). There are no NaNs, so NaN boxing won't work...
typedef struct { double d; char t; } cell_t;
#define I unsigned long
#define L cell_t
#define D(x) ((x).d) /* This macro is new and needs to be added in the right places everywhere */
#define T(x) ((x).t)
...
The result is very slow because it relies on passing structures by copy and on floating point emulation. This is a bit more acceptable with dev7.rom because the new opcodes help a lot for those operations. Yet this is far from a speed competitive lisp.
And here is another one which represents the cells with longs. The tag is in the high four bits of the long. No floating point here. Yet it is closer to the original than the tagged version. This is a bit faster because it only uses long emulation and avoids structure copies. Still much better under dev7.rom though.
#define I unsigned
#define L long
#define T(x) (I)(x>>24)
#define B(t,x) ((L)(x)&0xffffffL|(((L)(t))<<24)). /* This is a boxing macro to be used instead of T(n) = ... */
....
L box(I t,I i) { return B(t,i); }
I ord(L x) { return (I)x; }
L num(L n) { return ((n&0xfffffffL)^0x8000000L)-0x8000000L; }
...
L atomic() {
char *endptr; L n = strtol(buf, &endptr, 0);
return isdigit(buf[*buf == '-']) && !*endptr ? n : atom(buf);
}
...
Thx again!
The included gt1 doesnt run? New compiled = works fine in romv5a and 64k
---
To the minilisp from: https://github.com/rui314/minilisp
After first simple changes, glcc doesnt seem to like the declaration around line 71 `struct Obj':
../../build/glcc -o minilisp.gt1 minilisp.c -map=64k -rom=v5a
minilisp.c:71: field name missing
minilisp.c:81: field name missing
minilisp.c:87: field name missing
minilisp.c:90: field name missing
minilisp.c:94: illegal expression
minilisp.c:94: cast from `int' to `struct Obj' is illegal
minilisp.c:94: lvalue required
minilisp.c:94: syntax error; found `TTRUE' expecting `;'
minilisp.c:94: redeclaration of `TTRUE' previously declared at minilisp.c:43
minilisp.c:94: syntax error; found `}' expecting `;'
minilisp.c:94: skipping `}'
minilisp.c:95: illegal expression
minilisp.c:95: cast from `int' to `struct Obj' is illegal
minilisp.c:95: lvalue required
minilisp.c:95: syntax error; found `TNIL' expecting `;'
minilisp.c:95: redeclaration of `TNIL' previously declared at minilisp.c:44
minilisp.c:95: syntax error; found `}' expecting `;'
minilisp.c:95: skipping `}'
minilisp.c:96: illegal expression
minilisp.c:96: cast from `int' to `struct Obj' is illegal
minilisp.c:96: too many errors
make: *** [minilisp.gt1] Error 1
petersieg wrote: ↑12 Aug 2023, 08:03
The included gt1 doesnt run? New compiled = works fine in romv5a and 64k
My mistake. These were the dev7 versions. The lisp850sim.gt1 one is intended to run in the glcc test simulator gtsim. This is convenient for debugging.
petersieg wrote: ↑12 Aug 2023, 08:03
To the minilisp from: https://github.com/rui314/minilisp
After first simple changes, glcc doesnt seem to like the declaration around line 71 `struct Obj':
../../build/glcc -o minilisp.gt1 minilisp.c -map=64k -rom=v5a
minilisp.c:71: field name missing
No luck. These is a convenient C11 feature called anonymous structure and unions (see https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html) but lcc only supports C89. It won't work without adding names and using these names in all places where they were elided. I looked briefly at the code and it seems that some macros also depend on mixing declarations and statements.
Last edited by lb3361 on 05 Sep 2023, 23:22, edited 1 time in total.
Yes. Some need and small code relies on brand new features
Maybe some other minilisp is better/easier to convert towards glcc and Gigatron?
Anyway, we have now lisp850
thx, Peter
Attachments
Bildschirmfoto 2023-08-12 um 18.33.55.png (46.09 KiB) Viewed 286 times
lb3361 wrote: ↑13 Aug 2023, 07:04
No luck. These is a convenient C11 feature called anonymous structure and unions (see https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html) but lcc only supports C89. It won't work without adding names and using these names in all places where they were elided. I looked briefly at the code and it seems that some macros also depend on mixing declarations and statements.
I just implemented two useful features found in C99 or C11:
Mixed declarations and statements.
Anonymous structs and unions.
This might be a good time to give another try minilisp.c.
There might still be problems with this kind of initialization