Nakazoto / Hellorld

A collection of the greatest programming on the planet!
21 stars 3 forks source link

Hellorld! on a TRS-80 Model II using assembler (CP/M) #15

Open DiPDoTer opened 10 months ago

DiPDoTer commented 10 months ago

The TRS-80 Model II may not be the most obscure on the planet, but I think it represents a brief stage where Radio Shack was positioning themselves for a more business-oriented market. The Model II was different from the Model I in almost every way (aside from sharing the same processor), including a backplane for card-based expansion, 4MHz Z80 (instead of the paltry 1.77MHz in the model I), and a large (and power-hungry) 8" Shugart Floppy drive.

Screenshot 2023-12-17 at 5 39 58 PM

Screenshot 2023-12-17 at 5 39 37 PM

My machine came with many diskettes, but only one working CP/M boot diskette. While it doesn't contain all of the usual CP/M utilities, it does contain ASM (Assembler) and DDT (Dynamic Debug Tool). No higher level languages in sight, I'm afraid. Screenshot 2023-12-17 at 5 42 26 PM I didn't want to use ASM.COM because that would've required me to write the source code using ED.COM, and ED isn't exactly the most user-friendly editor in the world. So, on with the show using DDT instead!

According to Digital Research's CP/M Interface Guide, CP/M creates the typical logical memory blocks of the day, a BOOT (000H), TBASE (0100H) and so on. The size of the TBASE is dependant on how CP/M is configured to use available memory. The CBASE and FBASE are then piled on top. The FBASE is contains the FDOS which we will leverage to print our HELLORLD! to the big screen.

Screenshot 2023-12-17 at 5 35 51 PM Screenshot 2023-12-17 at 5 36 23 PM And here we'll key on the specific function we will use: Screenshot 2023-12-17 at 5 36 55 PM

Interestingly (at least to me), CP/M DDT (and ASM) display 8080-based instructions, which can be an issue on this Z80. Fortunately in our case, the instructions translate to the appropriate opcodes.

Screenshot 2023-12-17 at 5 37 30 PM

The D register (technical D+E register to contain the 16-bit address) is pointing at 0110H, so we'd better put our string there and end it with a "$". Screenshot 2023-12-17 at 5 38 26 PM

Finally, we execute a "GO" to execute code at 0100H...drumroll please... Screenshot 2023-12-17 at 6 11 00 PM

And TADA! HELLORLD! from a TRS-80 Model II running CP/M!

Screenshot 2023-12-17 at 5 38 50 PM