davidadkins1 / DIY-Forth-Interpreter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DIY Forth Interpreter

In the early 80's I bought a North Star Computers Horizon S100 computer. The OS was CP/M. I used it to put together a two axis data collection, correction, and validation system for our CalComp digitizers. For the application code I started with the article "Write Your Own FORTH Interpreter", by Richard Fritzson, in Kilobaud Microcomputing, February 1981 pages 76 thru 92. I typed in and compiled the Forth interpreter as the foundation of the control software that I wrote. The article can now be found in the public domain in the Internet Archive at: https://archive.org/details/kilobaudmagazine-1981-02/page/n75/mode/1up?view=theater

I am "copying" all of the listings, minus the hexidecimal bytes, for re-use here. My plan is to later branch this to a #RC2014 robot project.

To copy the listings I used the Archive to export a PDF of the magazine. I cut and paste the listing code into forth.asm, created with Notepad++ (https://notepad-plus-plus.org/). This is not quite as easy as it sounds, but it seems easier then retyping it all. As I said, my goal is to run this on a #RC2014 Z80 computer, but to compile and test it, it is faster to use the CP/M emulator MyZ80 (http://z80.eu/myz80cpm.html) running under DOSBox (https://www.dosbox.com/). I am including my DOSBox configuration file in this repository. It simply sets cycles=max, mounts a DOS C: drive, and starts MyZ80. Depending upon your system, you can just leave it running minimized until needed. From the CP/M command line I switch to the C0: drive and import forth.asm. To compile it I simply type "asm forth". This lists any errors and generates a FORTH.HEX and a FORTH.PRN file. I export the .prn file and keep it open in Notepad++ for update and review.

About the files: Forth.asm replicates the code, minus the hex data, in the article and compiles under CP/M with no errors. FORTH.PRN is the listing file genrated from "asm forth". I used it to verify that the generated code matched the article. ForthCPM.ASM is forth.asm modified to run under CP/M. The original may have run fine in an 8K system, but the I/O call addresses were absolute. I modified it and made sure it runs in my CP/M emulator and my RC2014 Mini. You can explore the changes by searching for ";DA". They are minor. FORTH.COM was generated by loading FORTHCPM.HEX with DDT. Using it I loaded the hex file into memory then, without executing the code (because it is self modifying), I exited and saved 6 blocks of memory to FORTH.COM.

About


Languages

Language:Assembly 100.0%