3 ms·
At risk of sounding like an old git... I built my own machine AND half-arsed Forth implementation for Z80 back in '92 from a couple of library books, a dismant
by chrisjsmith 15y ago
At risk of sounding like an old git...
I built my own machine AND half-arsed Forth implementation for Z80 back in '92 from a couple of library books, a dismantled broken RM380Z and a PC with DOS 3 and TASM on it. It sort of worked but was a little unreliable (it was all on stripboard, most of the bus timing was guessed and the XTAL was way too fast). I think the entire Forth impl assembled down to about 4K.
That sort of thing is just impossible with today's equipment. It's depressing. To much abstraction these days. Ironically Forth was probably the first language that supported writing DSLs :)
I'll dig it out and document it one day.
- zitterbewegung 15y agoLisp is probably the first language that supports writing DSLs.
- chrisjsmith 15y ago...within the syntax constraints of s-expressions. Forth allows you to define your own syntax as long as it's whitespace delimited.
- limmeau 15y ago... and as long as every sequence of words is a valid program.
- chrisjsmith 15y agoI think that applies to all programming languages :)
- limmeau 15y agoNo, many languages have a grammar in order to reject malformed programs, so that not every sequence of words is a program. AFAIK, you can define your own FOR loops in FORTH, but you can't enforce statically that each FOR has a matching LOOP; the mismatched program will happily run and corrupt the return stack (if you use the return stack top to store the loop index so that it will be available using the magic word I).
- chrisjsmith 15y agoThat is true - i'll give you that. TBH I have fallen down that hole.
- zitterbewegung 15y agoI don't see how that refutes my point?
- zokier 15y agoImpossible? I don't know, micro-controllers can be used that way too if you wish so.
- chrisjsmith 15y agoA fair whack of the microcontroller market uses harvard architecture (separate program/data) which makes it very hard for self-modifying programs to exist (such as Forth at a low level). Not only that, the programs are stored in Flash which has a limited lifetime so if you do go and modify it regularly, it will die. 90% of embedded ARM, PIC, AVR, MSP430, eZ80, 68HC11 etc fit that description in one way or another. This is of course all IMHO.