• Please review our updated Terms and Rules here

Any one have a BASIC interpreter written in C ?

smbaker

Experienced Member
Joined
Oct 21, 2016
Messages
416
Location
Oregon, USA
I'm looking to add a BASIC interpreter to my Z8000 project. The Z8000 has an assembler and it has a C compiler. But that seems to be about it.

I'm looking for something that would be relatively portable and easy to compile on an ancient (circa 1984) C compiler. Something that's more-or-less a plain ordinary basic implementation consistent with the feature set of MBASIC / BASIC-80.

Scott
 
Maybe there's some fodder for you here.

I'll look through that thread. My concern is most things floating around on the general internet are two new. Folks here know of more old stuff.

For example, https://github.com/paladin-t/my_basic is a potential candidate, but it includes a bunch of C include files that don't exist in CP/M-8000. I'm sure it could all be fixed given a bit of effort.

Scott
 
There is Bywater BASIC https://sourceforge.net/projects/bwbasic/files/bwbasic/ Early versions date from 1992 and might be adaptable to pre-C90 compiler with modest effort.
https://github.com/robhagemans/hoard-of-gwbasic/tree/master/ProgrammersHeaven had 4 different directories with early Bywater releases in BWBASIC* and BBASIC. I haven't checked closely what the differences are between the versions.

Awesome, Programmer's Heaven was one of the sites I was trying to find, but was excluded from the internet archive. Thank you for this!
 
Another one I'm looking for, that was listed as being a page on programmer's heaven was this:

http://www.programmersheaven.com/zone6/cat700/16060.htm Integer Tiny Basic in C (by Herbert Schildt, 1988)

Apparently Schildt wrote a fairly nice C book, and it has the basic interpreter in it. The book is readily available, but likely without the disk that would have been enclosed with it.

Anyone have any leads on this one? A tiny basic isn't necessarily what I was going for, but could be an alternative if the real basics just don't fit.
 
Another one I'm looking for, that was listed as being a page on programmer's heaven was this:

http://www.programmersheaven.com/zone6/cat700/16060.htm Integer Tiny Basic in C (by Herbert Schildt, 1988)

Apparently Schildt wrote a fairly nice C book, and it has the basic interpreter in it. The book is readily available, but likely without the disk that would have been enclosed with it.

Anyone have any leads on this one? A tiny basic isn't necessarily what I was going for, but could be an alternative if the real basics just don't fit.
This? https://gist.github.com/pmachapman/661f0fff9814231fde48
 
If you really get stuck, I converted the Z80 Tiny BASIC from a NASCOM to a CRAY-1 (in assembler)!

It didn't actually take that long - and it is not really a 'tiny' BASIC anymore with 64-bit integer arithmetic and access to plenty of memory... I was thinking of adding some of the vector processing next :)!

Dave
 
I assume if you have C working, you are working with the split memory, like the M20 has. It has split places for data and instruction memory.
I was curious as to how you implemented it?
Dwight
 
Thanks, that looks promising.

If you really get stuck, I converted the Z80 Tiny BASIC from a NASCOM to a CRAY-1 (in assembler)!

It didn't actually take that long - and it is not really a 'tiny' BASIC anymore with 64-bit integer arithmetic and access to plenty of memory... I was thinking of adding some of the vector processing next :)!

Dave

I did think about taking one of the Z-80 basics that had assembly source and converting it over to Z-8000, but that also seemed like quite a bit of work, when all I really want to do is run a compelling demo for my blog (every time I build a vintage computer, I write a short basic program for it).

I assume if you have C working, you are working with the split memory, like the M20 has. It has split places for data and instruction memory.
I was curious as to how you implemented it?
Dwight

Basically, with a PLD that takes the SN6..SN0 to get the segment number and ST3..ST2 to differentiate between I and D, and then sets the memory page address and memory chip selects. I have a video up at :


The split-I/D commands weren't working during the video due to a mistake in mapping the I-as-D segment.
 
Found my way to this one (or one like it; I forgot to write down the URL), and I might go with it: https://gist.github.com/zanothis/9167288

It's for an arduino, but it was easy enough to strip out the arduino-specific parts and compile it on linux with stdio.h being the only dependency. It's possible I could follow its trail back; it mentions "TinyBasic for 68000" and "Palo Alto Tiny Basic" from an old Dr Dobbs. Regardless, whatever it is, it's good enough.
 
"Palo Alto Tiny Basic" was written in Assembly though (Intel's 8080). Originally published in Dr Dobb's May 1976, the article is on archive, though all bounded together with the other editions from 1976 (page 129) of the archive, p.12.

I tried understanding the code for my own BASIC language, but the assembly for it exceeds my knowledge. There's also modifying the original code from TTY to VDM, which I recall there being an extra supplement for. Though I've just started writing a BASIC language with what I know, BASIC, and make the adjustments into Assembly. Early BASIC seems convient because it's Command Word first, followed by the operational stuff, which makes for a fairly organised source code.
 
I'm starting to remember what ancient c compilers were like.

Doesn't like the keyword "void".
Doesn't like the keyword "const".
Doesn't like "unsigned" when applied to "char" (fine when it's applied to int though).
Doesn't like types parameter types declared in the function declaration.
Doesn't like if a struct has a field that's the same name as a global variable.
Truncates function names to 8 characters.
If it encounters a syntax error, then it inserts the missing token (why???) and proceeds to generate syntax errors for every single line that followed the original alleged syntax error.

Oh, and I have no persistent storage (my compactflash interface prototype arrives from China by the weekend), so my only solution is to copy-paste the source code over serial into the ED program every time I want to modify it. Paste with a 1ms delay between characters, as there's no flow control and a serial buffer overrun crashes* the BIOS.

It's fun, like the good ol' days.

* something to fix...
 
Last edited:
Someplace on the web is a copy of the PTB that I had for my Poly8080. It had a unique feature that was to add Basic instructions to the command interpreter. I don't recall if the original PTB had that feature. I added two instructions that I'd load by tape to do PEEK() and POKE(,). With that I wrote a simple disassembler, in TB.
I recall, it was not very efficient but one could add instructions to TB. There were two instruction paths, one that took single input and another that took two inputs.
Dwight
 
Last edited:
I'm looking to add a BASIC interpreter to my Z8000 project. The Z8000 has an assembler and it has a C compiler. But that seems to be about it.

I'm looking for something that would be relatively portable and easy to compile on an ancient (circa 1984) C compiler. Something that's more-or-less a plain ordinary basic implementation consistent with the feature set of MBASIC / BASIC-80.

Scott
Cool you did a simple Z8000 based controller, But to add a basic interpreted will require some code rewriting/hacking.
The simplest way to get a BASIC interpreter to work is if that version of CP/M-8000 has the Z80 emulation enabled is to use a older Z80 CP/M based version that supports VT series data terminals. Do to hardware differences you might have to do a hardware emulation overlay for the OS or patch the BASIC interpreter in order to get in to work. ( Old Digital Research basic for CP/M-80).
..
Graphics Displays for use with basic under CP/M 80, This subject could get really large for our host. (So I keep it to a minimum amount of text for now). If the machine that you based it off had additional on board hardware (Aka: like onboard video and was based off a existing known Z80 design, this would be easy to patch the hardware and the basic interpreter to get in to work). Most basics for the Z-80 that allowed graphics to be displayed under a Graphics terminal through the serial port have code to handle the graphic and screen translations. Yes some more advance systems use a separate microprocessor on the serial port controller to handle this. The usual terminal emulations where DEC. VT, IBM 3270G, ANSI graphics, Tecktronic's 40xx series, but could also be AT&T 5260, Vidtext, UNISYS (UTS40/60, Burroughs), others. The GSX interpreter may also have to be converted and patched in order to get Serial Graphics Terminal to display the screen images properly.
..
Most of the Z8000 based system that I still deal with are Zilog Z8000 System or Olivetti L1Mxx family I/O compatible or are advance models that have additional IBM 3/360, S/370 Compatibility mode. (Not North American models). Some system do not have the Z8015 and Z8016 installed - their are easier to convert for.
..
Other basics (Available on line). you will have to re-cross compile code and them you might possibly have to write new code.
Their is other messages that already point to this, so I will not re note it for now.
..
Other companies systems information - The Kaypro, AMPRO, and a flew other are fully documented on line and most of their software and firmware images are available (if you decide to go this way, or not is up to you).
..
As for the project at github.com the authors lecture is a little limited, It could be a semi custom design, or based off some other design MCU. Looking at that logic design and yours basically code is going have to be written and possible some hardware emulation/or other hardware added for graphics modes under basic.
..
Hopefully I will see a future update on your progress and this message helps give you some more suggestions.
 
Hi Scott
I tried to send an email from the address you posted on your home page and it bounced.
Dwight
Hmm, I'll have to have a look at that. I'm using a google domain product, and everything there is supposed to auto-forward to my primary account.

In the meantime, if you send me a PM here, I should be able to receive it.

Scott
 
Just wanted to let everyone know, the tinybasic is ported to the Z8000 and working. I'll be putting the patched code up over the weekend.

The porting was relatively uneventful with two exceptions:

* zcc truncated all function names to 8 characters, causing two different globals (program_start and program_end) to appear as one.
* zcc does not handle word writes at non-word alignment, and this was causing line numbers to get corrupted.

N.Brown I would like to learn more about the Z80 emulation. I'm pretty sure the version I'm running does not have that. I wasn't even aware it existing (Ciarcia's Trump Card does mention running CP/M-80, but I figured he had written a translator)
 
Just wanted to let everyone know, the tinybasic is ported to the Z8000 and working. I'll be putting the patched code up over the weekend.

The porting was relatively uneventful with two exceptions:

* zcc truncated all function names to 8 characters, causing two different globals (program_start and program_end) to appear as one.
* zcc does not handle word writes at non-word alignment, and this was causing line numbers to get corrupted.

N.Brown I would like to learn more about the Z80 emulation. I'm pretty sure the version I'm running does not have that. I wasn't even aware it existing (Ciarcia's Trump Card does mention running CP/M-80, but I figured he had written a translator)
The easiest way to check for Z80 and Intel 8080 emulation is to try out an old Utility or application for that class of microprocessor.
Normally if the system does not error out (a none program status error), crash, lock up, etc. then some sort on emulation is installed. with CP/M-8K or CP/M-68K. As fare as the OS Kernel files sizes they would change much depending how the emulation was done and if they are using kernel compression. They would only be slightly larger.
..
To test for 8080 emulation just run a old CP/M 2.2 utilities like the ones @
.................................................sq111.com Machine language SQueezer, very fast
.................................................uncr8080.com , uncr8080.txt 8080 uncruncher for LZW compressed files
.................................................uncr-z80.com is a Z80 uncruncher for LZW compressed files
> Of course the above listed (unarched executables) is to be tried on a junk fire on the system in question, or you could decompile the how OS to look for a emulation/translation code, but the above would be quicker to do for a test of an emulation module. (OLd school)
..
unfortunately our host (This message board) does not like some file extension. COM, EXE files, so I added a short link above to them.
..
The original OEM Emulation modules were not very large to add to add to a CP/M kernel that did not have them.
Integrated VT52 Emulation module for CP/M was around 4K in size, VT100 wasn't much bigger
Oem VT52 Graphics extension for CP/M was around another 4K to 8K in size (without using the GSX-80 extension)
Microprocessor Emulation. The objective code was from about 16K to 18K in code size for the Z80 emulation but could be up to 32K in size depending on how it was done.
..
I have included a short link to some 8080 emulators if you wish to try to add it to your CP/M 8000 kernel.
8080 emulation code
https://github.com/eeTurcanu/emu8080 for dos but has source code link
http://gunkies.org/wiki/Emu8080 is a JAVA scrip version without OS kernel. A new link would have to be written.
https://github.com/topics/8080?l=c has a A complete emulation of the Intel 8080 processor written in C99.
> Their are several others still available, but their support is questionable, Their use of undocumented function calls, instruction , shortcuts, Newer C extensions bugs with older compilers, Etc., Etc..
Two other links are : https://gitlab.com/gbrein/tnylpo/-/tree/master/mine and http://www.z80.info/z80emu.htm
--------------------- http://www.cpm.z80.de/emulate.html and https://www.autometer.de/unix4fun/z80pack/
..
The big thing is the OS kernel would have to be patched at the point where the OS loads the Application or Utility or program to auto detect the microprocessor code being used and then use the Emulation code to run it. Etc. ,Etc. , The OS error kernel should also be updated.
..
Newer OEM version of Concurrent CP/M-86, 68K, Z8K, Concurrent DOS 86 had some sort of X80, Z80 emulation module installed if their was no real microprocessor on the system. As for Intel 8080 emulation under MC68000 microprocessor the Corvus Concept native OS used a Intel 8080 emulation/translator module to run CP/M-80 stuff. yes, a Intel 8080 combability module for their OS.
..
The old Byte magazine Project - Ciarcia's Trump Card does mention running CP/M-80, they did integrate a Z80 combability module and built itin. Even with all the units that they sold - No body bothered to archive any of its software and firmware. (To bad Because I could of used a couple of them).
..
Their where other emulation modules for use by OEM's for the Z8000 based systems, but their data is mostly lost now days.
To keep this message short for our host - I just gave the basic outline of it.
 
Last edited:
Back
Top