• Please review our updated Terms and Rules here

TRS-80 Level II BASIC cross-assembly source?

Eudimorphodon

Veteran Member
Joined
May 9, 2011
Messages
7,073
Location
Upper Triassic
My google-fu seems to be failing me; does anyone know of a github repository or other location where someone's put together a commented disassembly of the TRS-80 Level II BASIC source that's easily built with one of the many Z80 cross-compilation packages that are floating around?

(There's an absolutely beautiful repo covering the 6502 versions of MS-BASIC that will let you cross-assemble binary-perfect versions of the BASIC for multiple 70's vintage machines, it would be great if someone's done something similar for BASIC-80 and I'm just having a bad time finding it.)
 
You could perhaps try the book 'MICROSOFT BASIC DECODED'? http://www.trs-80.org/microsoft-basic-decoded/
This has the entire Level II code disassembled. I borrowed this from a schoolfriend and typed in the 12k of hex code into my Australian Applied Technology S-100 machine (took a week or two) and patched the keyboard routine to call the DGOS monitor keyboard one, and changed the 64x16 video memory start to that of my ETI-640 VDU card and it worked fine. I didn't get the cassette load/save going though. I don't think it wouldl be difficult to do the same for say a SOL-20 as that was the basis for the ETI board.
 
You could perhaps try the book 'MICROSOFT BASIC DECODED'? http://www.trs-80.org/microsoft-basic-decoded/

I was going to mention in the OP that this existed, I just, well, am lazy enough to really not want to have to manually reconstruct it given I‘m sure folks must have already done it. (The listing in the book isn’t complete, you have to fill in all the extended op codes and whatnot.)

Short version is I’m looking to hack together a pseudo-Model I compatible from scratch.
 
There are some pieces of generic Microsoft BASIC-80 scattered around, but mostly in text or PDF format. I think you'll have to gather them together yourself.

For TRS-80 ROM Basic itself, there are binaries galore but no downloadable assembly code. Certainly not in Github. All we have are text from many books: the famous "Basic Decoded", or alternatively "Model III ROM Commented". (I was always annoyed that the books only stick to the ROM and never decoded disk extensions like DEF FN.) The PDF's have been OCR'd, so maybe you wouldn't have to type everything in from scratch. Ira G himself has ROM disassemblies on trs-80.com, but in HTML.

TRS-80's 12K Basic is the closest match to Altair/BASIC-80 version 4.x ("OBASIC.COM"), which falls just in the middle between earliest and final 8080 versions. The ones around it have been disassembled, but not that one. What I've found:

You might get other insight from Microsoft's other Z80 BASICs, like the MSX ROM. (Found it in a weird place: what's it doing in z88dk?) https://github.com/z88dk/techdocs/blob/master/targets/msx/msxbasic.asm
 
here's a disassembly of level 2 basic rom. (from years ago) The commenting is not complete but at least you wont start from nothing.
I used the basic decoded book to help with determining code from data.

joe
 

Attachments

  • levelII.zip
    33.8 KB · Views: 14
Thanks for all the links. I guess if I have to I'll try sucking it up and pasting something together based using the BASIC decoded book as the primary map. (I guess as part of that I need to stop faffing around and figure out which cross-compiler I want to target.) One of the reasons I was hoping there was an already proved-out distribution out there is I don't have a lot of assembly experience (and most of what I have is on other CPUs), but hopefully I can muddle through.

There's a beautifully formatted and annotated assembly listing of MS's 8K basic for the NASCOM computer that embodies what I was hoping someone had already done. Ah well.

TRS-80's 12K Basic is the closest match to Altair/BASIC-80 version 4.x ("OBASIC.COM"), which falls just in the middle between earliest and final 8080 versions. The ones around it have been disassembled, but not that one. What I've found:

Again, it would be really awesome if all the detective work into these various versions could be combined into something like that 6502 MBASIC repo, but maybe there are things about BASIC-80 that make that a bigger ask.

Somewhere I have squirreled away the original assembly source for Level II BASIC...not a disassembled version. It builds but produces more than 12KB of ROM code. I never did figure out what that's about but might be worth revisiting.

I'm curious what the provenance of that was. It's probably a fair assumption that they used some kind of post-processor on it to build the final ROM image?

don't forget, Level 2.5 (TWOHAF) BASIC has many disk commands such as INSTR, MID$=, MKI$, MKS$, MKD$, (and conversions back), & (for HEX), DEF FN and DEF USR
details are on George & Peter website, http://48k.ca/trs80gp.html or www.trs-80.org.uk

I need to try to track it down again, but I think someone has actually posted the source of MS's "Level III BASIC", which provides similar enhancements.

Do you know if an assembly listing of, say, the Extron Stringy Floppy extension ROM, or other similar alternate mass storage device, is floating around anywhere? The initial thing I was hoping to find the LII BASIC assembly for was to modify the initialization code to set up some hardware additions like a memory pager and some video related goo, but I'm also really interested in the idea of possibly implementing an extension to provide LOAD and SAVE commands that would target a flash storage device (maybe using one of those cheap CH375 USB modules, or bit-banging an SD card) without having to implement a full TRS-DOS disk system.
 
I'm curious what the provenance of that was. It's probably a fair assumption that they used some kind of post-processor on it to build the final ROM image?

Hard to say. I haven't looked at it in 20+ years. When I find it we can investigate more. It had comments in it from the usual suspects at MS at the time so seemed more or less legit. I found all the Radio Shack strings that should be there for Level II BASIC as well as some of the abstractions they used for targeting different platforms, so it was obviously not just a disassembly with fake comments added. If I recall correctly it wasn't Z-80 mnemonics, either. Maybe 8080 with macros for the Z80 instructions. There could have been post processing involved or just some configuration options I hadn't figure out when playing with it.

Do you know if an assembly listing of, say, the Extron Stringy Floppy extension ROM, or other similar alternate mass storage device, is floating around anywhere? The initial thing I was hoping to find the LII BASIC assembly for was to modify the initialization code to set up some hardware additions like a memory pager and some video related goo, but I'm also really interested in the idea of possibly implementing an extension to provide LOAD and SAVE commands that would target a flash storage device (maybe using one of those cheap CH375 USB modules, or bit-banging an SD card) without having to implement a full TRS-DOS disk system.

Some years ago I was also hunting around for "the knowlege" of how to extend commands in Level II BASIC. A few good sources are the above mentioned ESF, various books I found in the Color Computer archive (techniques still applicable to the Z80 BASICs), as well as more generic articles on how to use the error trap to add new commands.
 
Basically, the important part is to have all the address references set up properly so that it can be properly reassembled at any address. I have it set up in my disassembler, so I can just push out a source file and do whatever with it. I have some comments in there too. Mostly I just use it as a quick reference of what's in the ROM. I suppose if I got really bored I could put in the comments from one of those Decoded books, but they were bad about disassembling data as code.

"the knowlege" of how to extend commands in Level II BASIC

Yeah, I was able to do that back in the day, but it was a mess of hooking up some patch vectors and checking the return address inside the patch. It just seemed so icky. If you were really hardcore, I guess you could just have it slide over to your own inner loop, but that's getting even more absurd. I'd rather just have overlay RAM and copy the ROM into it like on a 64K CoCo.
 
You could perhaps try the book 'MICROSOFT BASIC DECODED'? http://www.trs-80.org/microsoft-basic-decoded/
This has the entire Level II code disassembled. I borrowed this from a schoolfriend and typed in the 12k of hex code into my Australian Applied Technology S-100 machine (took a week or two) and patched the keyboard routine to call the DGOS monitor keyboard one, and changed the 64x16 video memory start to that of my ETI-640 VDU card and it worked fine. I didn't get the cassette load/save going though. I don't think it wouldl be difficult to do the same for say a SOL-20 as that was the basis for the ETI board.
Another DG680/DG640 S100 System Owner - Cheers!
All of the abovementioned systems and microbee are very similar. Getting the tape load and save shouldn’t be overly difficult if you employ the DGOS Tape APIs.
 
G'day Someone,
I didn't have an urgent need to get the TRS-80 Load and Save working because I knew the start address of the LII BASIC program in memory, and I could use DGOS to save that out to cassette, after doing a (?)warm reset back to the monitor. BTW DGOS was an awesome Z80 monitor packed into (IIRC) just a 2K ROM (the assembly listing is on the net somewhere).
So even though I sold my AT S-100 system decades ago to fund one of the early Amiga 1000's to come into Australia (in I think 1987), for some reason I kept a folder of some of my programs and ideas and other things. So here are some.

This is the command map of Microsoft Level II TRS-80 BASIC and what I believe is probably my changes to the binary to point to DGOS keyboard input routine and also the change to move the 64x16 display memory to (?)D000 or wherever my ETI-640 screen lived. It all worked extremely well:

TRS80_Radio_Shack_Level_II_Microsoft_BASIC_command_addresses_mediumres.png

TRS80_to_Applied_Technology_S-100_keyboard_screen_changes.png
I recall I was able to add new BASIC commands by "throwing out" the less useful (to me) commands in this table by overwriting them and vectoring the code off from where the parser called the original code. I recall I was extremely envious of the Apple ]['s HLIN AND VLIN commands so my friend helped me write the Z80 code for them.

I also got the TRS-80 Level II BASIC low res graphics commands to work perfectly on my S-100 system because I was lucky to have the ETI-640 add-on ETI-681 Programmable Character Generator board:
https://www.worldradiohistory.com/hd2/IDX-AUSTRALIA/IDX/Archive-ETI-AU-IDX/IDX/ETI 1980-06 June-OCR-Page-0067.pdf
Here is the low-res character set, I think it lived at F800 maybe. (Apologies for the scan, we used a bonkers paper size, Foolscap, back then)

TRS80_lowres_graphics_set_mapped_to_S-100_AT_Programmable_Character_Generator_mediumres.png

The difference though was (IIRC) the TRS-80 had an 8x15 character matrix but the PCG had an 8x16 matrix. So I made the lowest two low-res 2x3 TRS-80 pixels be 6 of the PCG's high-res pixels high, ie. 5 high, 5 high, 6 high.

Using this character set I also ported the TRS-80 flight simulator to S-100 (I don't recall where this came from or if this was a Microbee version?) and munged the keyboard call to get it to work. But, this was all 40+ years ago so my memories of what I did as a lucky schoolkid with a "home computer" is a little faded now. (BTW there was also a PCG circuit to build in one of the late 70s issues of BYTE)
But I suppose I wanted to show that Microsoft Level II BASIC can run on (some) other machines by just patching the binary.

Steve.
 
Last edited:
G'day Someone, ...

G'day Steve,
A fantastic write up that shows your expertise. I used to work at Applied Tech and worked on both S100 and microbee stuff.
The microbee emulated its TRS-80 graphics identically but the initialisation code used an algorithmic approach based upon N & 0x7F to save valuable ROM space.
Do you still have a copy of the ported flight simulator?

I gave away my Amiga 1000 to clear out some space but kept my S100 stuff.

Do you know about the microbee forum? It has a section for pre-microbee S100 stuff.

Cheers & Happy New Year
Someone
 
Sadly I don't have any of the hardware or software from the AT machine. All I recall is I sold it to a student from Sydney Uni (I didn't even go to that uni). So if that machine still exists then perhaps the tapes exist...
I've perused the MicroBee forum in the past, someone on there had an animated chicken(?) avatar that was really distracting so I gave up reading it.

Yes sadly my patronage of Applied Tech didn't end that well. One Saturday morning Dad drove me up to the Waitara store and Whaaaaaa????? what happened? No S-100 machines anywhere in sight, just these new MicroBees. A certain manager/director (let's call him OH) told us with a straight face that the MicroBee was "absolutely 100% compatible" with the S-100 machines. So I bought some MicroBee tapes which loaded, only to find that the new machine used a different keyboard setup (by re-purposing the light pen strobe on a 6845 or something?). So I had to figure out and patch those. I soon moved on to an Apple ][ clone then IBM PC clone then the Amiga then the Uni's 11/780s and Gould.

I have some more S-100 projects and code (four voice polyphony, cursive PCG character set, graphics routines, my own DOS attempt) I could post here sometime. I had an assembler but didn't like using it so instead hand-wrote pages of Z80 mnemonics + their hex opcodes and hand-calculated the offsets. If I made a mistake or had to add something I just liquid-papered the addresses and offsets and recalculated them. It was all fun.
 
Last edited:
Sadly I don't have any of the hardware or software from the AT machine. All I recall is I sold it to a student from Sydney Uni (I didn't even go to that uni). So if that machine still exists then perhaps the tapes exist...
I've perused the MicroBee forum in the past, someone on there had an animated chicken(?) avatar that was really distracting so I gave up reading it.

Yes sadly my patronage of Applied Tech didn't end that well. One Saturday morning Dad drove me up to the Waitara store and Whaaaaaa????? what happened? No S-100 machines anywhere in sight, just these new MicroBees. A certain manager/director (let's call him OH) told us with a straight face that the MicroBee was "absolutely 100% compatible" with the S-100 machines. So I bought some MicroBee tapes which loaded, only to find that the new machine used a different keyboard setup (by re-purposing the light pen strobe on a 6845 or something?). So I had to figure out and patch those. I soon moved on to an Apple ][ clone then IBM PC clone then the Amiga then the Uni's 11/780s and Gould.

I have some more S-100 projects and code (four voice polyphony, cursive PCG character set, graphics routines, my own DOS attempt) I could post here sometime. I had an assembler but didn't like using it so instead hand-wrote pages of Z80 mnemonics + their hex opcodes and hand-calculated the offsets. If I made a mistake or had to add something I just liquid-papered the addresses and offsets and recalculated them. It was all fun.
Yep, what you recalled seems familiar to many of the loyal S100 customers. All of the S100 cards that remained were destroyed.
It would be great if you published your work and allowed it to be archived. I still use my S100 system and also have an emulator.
The microbee BASIC is the S100 Tape/ROM BASIC with a different BIOS (putch and getchar, and altered video drivers), some new features and a few bugs removed.
 
I just found this wonderful post :) It was me keeping the BASIC asm sources in z88dk-docs, there are multiple reasons for it I'm not explaining right now.
I saw the entry point maps done manually. I did the same in the past but I ended up in creating a tool spotting the entry points for me. Look in the main z88dk folder (the main archive or distro, not the "docs" one). We have a support/basck/ subfolder where we keep a tool able to analyse a binary block and spot the Microsoft (or others) BASIC entries and list them for you. If the code is within a tape or disk image it should be able to automatically understand where it is supposed to stay in memory.
It has got 2 different modes, -map and -ctl, being the latter a good starting point to set up a configuration file for skoolkit.
 
For what it's worth, I have been slowly working on my TRS-80 Model I/III/4/4P reverse-engineering repo, trs80i34-re. I've done a rough disassembly of the Model I US 1.2 ROM using z80dasm, converted it to source for Macroassembler AS (in ML12_1.z80), and I have that assembling and comparing correctly to the original ROM image. The next steps are to start to give labels proper names, add comments, etc. and after a bit of that add the appropriate conditional assembly code and build scripting to make it generate the Japanese, 1.1 and 1.3 ROMs. I also have, in the documentation, links to various other sources of reverse-engineering information for these ROMs.

I don't know when I'll get around to doing further work on this (I'm currently occupied with reverse-engineering the NEC PC-8001 ROM), but if anybody's interested in sitting down and doing some pair-programming on RE for the TRS-80 stuff, you can drop me a PM.

(And, as it stands, you can still grab the repo, tweak that listing, and build a new ROM if that's what you want.)
 
Back
Top