Retro programming! Pascal and CP/M on an RC2014 Z80 computer
Вставка
- Опубліковано 23 сер 2024
- Let's investigate CP/M on my RC2014 Z80 based computer.
CP/M was an operating system before MS-DOS existed, and it requires surprisingly few resources to run. This computer runs at 7MHz and has 64K of RAM. CP/M itself fits into just 8K!
If you want the code for the Pascal Mandelbrot program, it's on this pastebin URL pastebin.com/A...
Boy this brings me back. I had an S100 buss machine with two, count 'em, two 8 inch floppies. It had an assembler, a basic interpreter and a basic compiler - BASCOM. But it came alive for me when I learned PASCAL and got my first Borland compiler for $30.00. PASCAL was the first, and, to this day, the cleanest programming language that has ever been. l learned it from a professor who was a hardware engineer for Nick Wirth. If I ever got stuck on something I went back to the railroad diagrams and plowed right through the speed bump. Those railroad diagrams made me realize how easy it could be to implement a compiler as long as the language could be described by such a clean format/representation. It was a one-pass compiler and I loved the pre-declaration requirement - whatever "it" was had to be declared before it was referenced - variables, constants, types, functions, procedures, whatever. And the executables were tighter than anything ever produced by a C compiler - even the Borland turbo C compiler. I programmed on that box for 2 or 3 years before the PC came out but I can't tell you what I programmed, with 2 exceptions - I programmed my senior project on it (I was an electrical engineering (digital hardware) student), and I wrote a CP/M version of a unix program called GREED. That was all 40 years ago in the early '80s. So many fond but fading memories. Thanks for the reminder.
I loved reading it. Thanks❤
WordStar was trivial to learn. I got up to speed playing with it after school in just a couple of days and started writing papers in it immediately. Those were heady days!
This was actually the first proper show of how RC2014 works, and I still don't get it, but I haven't found videos that show how it works better than this video! Thanks!
I still love Pascal, one of the best programming languages ever. I started with hisoft pascal on a zx spectrum, later on an amstrad. Then i switched to turbo pascal on the early pc’s and continued with Delphi. I learned myself object oriented programming with delphi and i loved it. It is so much better than any c variant, although c sharp comes close
That's so cool that Turbo Pascal runs on this. That was my programming language along with C in the 1980's. I used to use a C cross compiler called Avocet to compile Z80 programs on my PC.
One of the advents of the CP/M era was the common standardized BIOS (Basic Input/Output System). It had well known software interrupt handlers baked into the ROM which basically defined a software API. It made it so that any program could work on any computer with a compatible BIOS. The programs didn't need to know how to move the cursor or how to write text to the screen, they just called the appropriate interrupts with the correct values loaded into certain registers and it would trigger the function they wanted to accomplish.
On a side note: in Windows 10, there's a registry setting you can turn on that will enable the old ANSI terminal commands if your software depends on those.
As for future projects, it would be neat to build a video card for this (even if it used a microcontroller, or perhaps an old scavenged ISA card), and to program a BIOS to use the video card instead of writing to the serial port.
That CPM format on compact flash has become the standard thing for several computers like N8VEM and FPGA boards. It's a pig to access from a PC. The best I was able to do was to lift the first 8M and access the A drive user 0 with cpmtools. There are a lot of files in the image under users 1-15. It's an utter pain in CPM to move files between users. You're right about Basic. Reading someone else's code in Basic is a nightmare. It's interesting looking at so many old languages in CPM.
I used to program in LISP on my CP/M 68K machine. LISP is meant to represent formal mathematical structures, so there's a lot of weird things one can do in LISP, like taking derivatives and doing integrals, calculating with polynomials, or even write LISP programs that rewrite themselves. One of the oldest programming languages, I haven't heard of it being used much lately, although AutoCAD and Mathematica were based in LISP.
We did Prolog at university, and I had a look at Lisp when trying to learn EMACS back in the 90s. I quickly discovered I never got on with that style of programming. Either the syntax was too confusing, or the way you think kept confusing me. I watched either Computerphile/Numberphile or StandupMaths writing some code using Haskell and the way you can write code that calculates sequences of numbers with barely any code was interesting, but I couldn’t work out how it was functioning.
Amiga basic helped me get thru my Fortran 77 class. Basic came out of Fortran, and Amiga basic didn't need line numbers, so I could code my assignments into Amiga basic and used a minimum tweaking to compile into Fortran. This kept me from an hour commute to the computer lab.
Ah the good old days.
As a kid I couldn't cope with BASIC without line numbers, it just didn't make any sense to me :) Wasn't until I started learning Pascal that "real" programming made sense.
@MichaelKingsfordGray 🤔
Smart move. I hated line numbers and BASIC. I switched to Assembler because I found it easier.
AmigaBASIC was written by Microsoft and true to form crashed every time you used it. Never loaded it again.
I can recommend TeraTerm on windows. Does a great job as VT100 /ANSI terminal.
I have recently written a BIOS for CPM 3 for John Winans' z80 retro board and it's a lot of fun.
Where did you get CP/M 3? Please.
TYIA,
(S) Derek
@@dereklassen4841 if you google for "CPM source code", the page comes up. It has all sources for not only cpm 3, but 2.2 and mp/m as well
Used Pascal on a TRS-80 at college where they had a CP/M computer (used an Intel CPU) and Turbo-Pascal and Borland C at home.
8:10 THIS. Programming is not knowing about a specific language and syntax, but the idea about how everything works behind it. If you know the specific paradigm - procedural, OOP, functional - you can just use the language if you have a reference. And the thing is people these days think that Google and Stack Overflow isn't the same thing as those 2000 page reference manuals we used in the 90's for checking the syntax. If you know one programming paradigm, you know all the languages that use that if you just check the syntax and code reference. (I personally still have problems with understand functional programming as a paradigm - I sometimes get it, but I still couldn't code my way out of my life in LISP) ((ALSO sorry for spamming the comments, I commented as I was watching, much many comments came :D )
Maze Maker was a good one. It makes mazes with ASCII characters
You need to find XMODEM or any other upload protocol to transfer data! I guess there would be com stuff in the bbs era, also compression too! CP/M is kind of limiting by it's size, but you have Basic, Pascal, Fortran and even C! The real limiting stuff will be that CP/M is geared towards text only. I dont know if there is video cards for the rc2014 although there should be yamaha sound cards, to at least give you music!
You have been successful in leaving 100s of men (maybe women too) with the most childish of grins remembering the challenges of 8 bit programming. Retro programming is a curious phenomenon. Why would intelligent humans yearn for antiquated technology when they are watching videos such as this on technology that has almost limitless resources? I think I may have an answer (no, I am not going to insult me fellow viewers). When humans come up against limited resources, they are at their most creative. They experience incredible achievements to come up with results that if performed on current technology would be seen as a slog. So, thank you for this trip down memory lane.
Is there a decent IDE and C compiler on CP/M? Compilers were considered exotic creatures back in the day. I still had loads of fun with Z80 and 6502 assembly but would have been far more productive with Visual Studio. Happy days.
"CP/M and Pascal" now there's a couple of things that "give me the warm and fuzzies".
GOTO is programming for "real men"! ;)
There's a T-shirt!
I remember learning Jackson Structured Programming, aimed at Pascal. There was this thing called program inversion that required the use of a GOTO to deliberately break structure. Say you were printing a report, that had a structure, each page had a header and footer, the report had a title and column headings, body data and sub totals and totals. Yet the data itself had a different structure. You were supposed to structure your program around the structure of the data but in this case the structure of the report as well. The conflict was resolved using a single well placed GOTO.
ProTip: .... Putty on windows can do serial communication last I looked and is very good on it's ansi support.
Wanted to say the same
7MHz is 3.5 times as fast as what I had, back in the day (Apple II CP/M-card, which ran at 2MHz)...
seeen your work on the olc i liked it
You have the same syndrome as me. I've been taught to not fix what's working. However, I do not consider stuff working "adequately" as working, so I keep trying to fix it to perform better. I think that's kind of the drive for innovation and trying to make things - never settle for less than perfect (though it's important to learn to accept "just good", perfectionism is such a disease - better to have done than not at all because you don't know how to make it perfect)
Get an engine running before you tune it.
There are structured BASICs. The only real issue with programming in the language was laziness on the part of the programmer by not using top-down design and stepwise refinement and by writing the code away from the computer - essential to good programming.
Well if you're using a Structured BASIC then it's practically PASCAL. It's not true that using good programming solved the problems of BASIC. I was struggling to write a large program in BASIC and being as disciplined as possible but it was becoming a nightmare with two letter variable names and all global namespace. Switching to Turbo PASCAL transformed everything. Now I could have a for/next loop with I as many times as I wanted with no conflicts to give a very simple example. Being able to pass values and variables was extremely valuable.
In fact for large programs MS BASIC was so bad that Assembler was more structured. If you needed to use a register in a subroutine you could push it on the stack and pop it off when done.
If you want to write a 40 line program that's basically one procedure then nothing beats BASIC. Anything more than 100 lines is a total dogs dinner.
FYI, you can redraw the screen in the Turbo Pascal editor by hitting Ctrl-L.
I really enjoy your video, but it's way above my head. I would like to have a retro-CP/M prebuild, like a Phoenix256 or a Commander X16 or such. Also, I like to play around with BASIC hobby coding. If anyone here wants a fast line number style BASIC for a modern computer, PC-BASIC is a free download. It would run this code shown above very,very quickly.
What didn’t you like about Putty on windows? I use minicom on Linux, minicom or ZTerm on OS X and Putty on Windows. Putty has good terminal emulation and is fairly configurable.
As an ssh client Putty was quite good (although now I’ve found Bitvise which handles disconnections better). I just found the combination of Windows Terminal, WSL and minicom a nice combination. It felt like a “real” Linux terminal.
Putty is probably the best general purpose terminal emulator on Windows. Lately I have started using Microsoft SSH client in Windows Terminal for ssh sessions though. The config file option for SSH is great... it’s allows you to just use a simple alias for common connections and not have to mess with a bunch of command line options if you’re connecting to nonstandard ports or using different usernames. For serial connections though... Putty every time.
Man PASCAL was the first real language I learned programming on (I do not count BASIC as a real programming language)
It was my first real language too. I think it was the first language where I realised I could do more than type in other people's code.
That's a bit elitist... why would you not consider BASIC a real language? I know it had that reputation back in the day, but I've always felt it was a bit unfair really.
That said, if you want a good BASIC for CP/M, look at Microsoft BASIC 80. It's pretty functional for it's day, and almost identical to the Locomotive BASIC that came on the Amstrad CPC.
@@calebfuller4713 Yeah, I actually agree with you on this. I'm a bit self-contradictory on this, as I hate gatekeeping and I'm all for making programming accessible for everyone. In my defense all I can think of is that back in the day there was no easy way to compile BASIC, and it is missing high level data constructs in most dialects, not to mention other QoL features which would make me want to develop bigger projects than simple gamelets.
So, yes, BASIC is a real programming language, and no, I don't feel like it is, for possibly irrational reasons.
I remember C64 Basic, GW-Basic, QBasic, and even Blitz Basic and Amos Basic, both of which had some higher level constructs and were compilable iirc. Pascal was the first I actually felt like I was actually programming, Basics just always feel to me like some introductory, "you are not going to ever use this but you'll learn basic programming principles" course.
@@janikarkkainen3904 I understand. BTW there was Microsoft BASIC compiler for CP/M! But yes, I think the interpreted nature of most implementations made people feel it wasn't suitable for large projects.
I mean, you could point out the lack of modern definable sub-routines and functions, and the unstructured nature of many programs with their excessive GOTO, but then FORTRAN had all those issues (which is where BASIC got them from) and no-one ever said FORTRAN wasn't a real programming language! 🤣
I guess back then, each programming language was somewhat unique and they all had distinct looks and feel. It's ironic when you look at more modern versions they all seem to have gradually converged, borrowing ideas from each other and dropping stuff that's obsolete, to the point the code on most looks almost identical! Basic looks like Fortran looks like Cobol looks like Pascal looks like C, and they all seem to look like Java! 😂
BASIC is a real programming language!
To be honest, modern operating systems don't derive from DOS. Current day Windows come from Windows NT. That did get some bits and bolts to run some ancient code, but it was different from the ground up. Edit: I'm glad to have grown up with BBC Micro's ... at least the BASIC on there had things like functions and procedures, didn't need to GOTO anything.
I think RC2014 also has a FPU board (Am9511) I wonder if Pascal could use it for massive speed improvement 🙂
I likes. Please continues
I'd suggest trying Forth or COBOL for a different programming experience.
I did COBOL on my A Level Computing course back in the day. It was an experience, that's for sure 😬
Forth can do so much with such ridiculous hardware requirements .. but it is so obscure for people like me not used to it .. :-/
It's actually not that bad. It's just a different way of thinking.
@@ASCIITerminal Think like Yoda, you do, to use FORTH.
CP/M on a Z80? Cmon, TRSDOS for the win! 🤣
I agree the "DOWNLOAD" program is a pain. I use winrar to zip my files without compression (store) then send them to my cp/m machine with Xmodem and unzip them there. It's a bit more typing but a lot less hassle.
Or set up a BBS system on your PC and use a terminal program on the CP/M to download files.
I remember Kermit file transfer. That's got error correction and compression.
6:01 Yes, that's what I call fun. :P
Hi James,
Does the BASIC (ROM version) support DATA, POKE and USR? I guess you can poke machine code into some safe place in RAM and run Z80 code.
Back in the old days - I used MASM80 (Z80 Assembler) under CPM, sending code to Z80 game machines using a PIO chip.
Best wishes -
I'm sure the 'break' statement is a special 'goto' statement, BTW! Damn!
John Wilson I think basic does support those commands, they’re listed on this site searle.x10host.com/z80/SimpleZ80.html#RomBasic which is the basic used by the RC2014. So yeah, you could probably assemble some Z80 and then put the hex values into a little BASIC program like we did on the ZX Spectrum.
@@ncot_tech Happy days!
Yes, it breaks structure. There is a legitimate structured programming use for GOTO when you need to break structure rather than spoil your clean structure with IF statements.
Get bbc basic and you can write inline assembly.
Nice video, thx for it. It's possible download pascal mandelbrot source ? I want run it on my RC2014.
I've just put it on this pastebin pastebin.com/ALGdMnbs
Doesn’t it use XMODEM to upload files?
If you can get something like Kermit running, it can do more useful file transfers. I couldn’t make it work though, so ended up using the download tool.
@@ncot_tech Use PuTTY on your windows machine. It knows how to transfer using Xmodem.
@@ncot_techI’m 3 years late to this but on a Windows host I’ve been using TeraTerm XMODEM to send/receive files to and from 8-bit 1802 programs on an OS called ELF/OS. Granted you would need some code within CPM in order to initiate the transfers, I’d be surprised if they don’t exist. I’m using a program called Serial (I think) on MacOS which handles it as well. I enjoy a little retro programming for recreation too.
I'd say try programming BBC Basic. You can do it on a modern Raspberry Pi as long as you can stick RiscOS on it. You'll see that you can program without a single GOTO.
Microsoft BASIC, while not quite as structured as the BBC version, did support GOSUB/RESUME, so you could also write relatively strucured code without GOTO if you wanted to. Unfortunately it won't GOSUB so you still need fixed line numbers and good commenting. There IS a DEF FNxxx() that lets you make simple user defined functions though - unfortunately only standard BASIC formulas, not full code.
@@calebfuller4713 Night and day. BBC BASIC was pretty much PASCAL or at least the bits that made PASCAL better than BASIC. The BBC Micro was the most amazingly well designed 8 bit computer ever. Commodore and Atari had some fancy hardware features but the Beeb allowed you to plug ROMs into the motherboard for extra functionality.
MS BASIC was thrown onto every other home computer. Excellent for maths and print statements and features to poke the hardware but a terrible applications programming language.
My rc2014 doesn't want to write anything to CF under cp/m, don't know how to diagnose this problem.
Didn't CP/M have a kermit capable communication program? Then there *is* a bit of error checking.
Yeah, but I couldn't make the PC side work for some reason.
Wow.. i remember using Aztec C, HiTec, dbase, wordstar, televideo, osborne, kaypro, LOL
Can CPM handle graphical output like with a VGA adapter something like that.
No, it was for text terminals only.
You know something i'd like to see done?
I'd like to see someone write tetris for CP/M :)
IIRC the original was written in PASCAL....
Yes, it has been done and in Pascal. See c64retr.blogspot.com/2016/09/cpm-tetris-clone-in-turbo-pascal-30.html
I bet there is Tetras for CP/M.
@@wayland7150 yeah the problem is finding one that works with the terminal emulators
Sorry. I meant search for Kilobaud archives
Is there a VGA board for the RC2014? Probably need a keyboard input too.
We are talking jape of the decade. We are talking April, May, June, July and August fool. That's right. I am Queeg.
Isn't 7mhz a bit fast?!
The C64 ran at 1mhz, and some squeezed a lot out of a C64...
256kb of RAM???
That seems excessive for CPM. Not that I ever really used it. But I played around with it. A Commodore c128 also had a Z80 and a CPM Disc. But even back in 1989ish there was hardly any Software - it was really already completely obsolete by then....
Maybe some companies might have still had an old Z80 machine.
Yeah! GOTO statements!
That is how you learn to code the real way!!!
Not even using labels but mind less line numbers. That way your brains memory got trained to the Max. Of course nobody else could read your code.
But then eventually not using them anymore was the really fun Part.
It made things so much better 😊😊😊😊😊
I agree CPM was very unintuitive. In my case the arrow keys might have worked to control the Cursor, but it was rather a surprise if something else worked as expected. Usually it didn't 😢
Since I had zero documentation it was pretty useless even in the late 80s.
I mean I had a Commodore c128. It had 3 modes: c64, c128 and cpm
The c64 Mode was the one to use to play games but it was only 40 characters wide (320x200px).
The c128 Mode was useful to use a terminal emulator and go online with it since it was 80 characters wide. That also made it a valid word process ing option.
The CPM Mode was just useless compared to the other two.... I really tried to use it but it was to hard to get Software or Information about it.
I also never met anyone in real life who had even heard about it ( except from me), let alone used it....
Can it run SymbOS?
Thanks for the video.
As it is no, there's no display hardware and only 64k of RAM/ROM. But if someone made a video board for it, then ... I supposed technically it could.
@@ncot_tech I watched a video of a Amiga being modified to output HDMI from a daughter board used as a Hat on a Raspberry Pi Zero and the Denise chip. If could find a graphic chip from a Spectrum or Armstand that used a Z80 or Z180 CPU well maybe I could be possible,...
Thanks for the update.
Actually a good program to try on CP/M would be dBASE II. This was a full multi-file relational database system that had it's own interpreted language targetted at database manipulation. It's about as sophisticated a business application you're likely to find, as you can use it to develop any business application that is built around databases. (Well, you could probably write a text adventure with it too... 😂)
It later got ported to MS-DOS, and was the leading database application during the 80s.
(p.s. You WILL need to find a pdf manual or reference for it, as it just loads to a "." prompt. If you have a manual, the actual dBASE code is pretty easy to get the hang of though, especially if you already know programming.)
That's a very good choice. I think Borland may have had some database products for CP/M because they had them for MS-DOS.
Pascal is a great language and it is fast
Oh yes, it's very fast compared to MS BASIC which is the other option you might consider.
There's no such language as 'Pascal', even less on 8-bit machines.
dma?
You can try mumath
why?
You do know that the structure of a program is down to the programmer and not the language. A BASIC program can be as structured as any other. The big problem was that may programs written in BASIC have been written by people that have never learned structured programming. I program in C, PASCAL and BASIC and they all seem very much the same but maybe that is because of the way I code.
I find looking unknown PASCAL code just as confusing as looking unknown BASIC code.
Lets take a very simple counting program. PASCAL First
program forLoop;
var
a: integer;
begin
for a := 10 to 20 do
begin
writeln('value of a: ', a);
end;
end.
From a BASIC programers view point: Why do we need the key words "do", "begin" they seem superfluous.
Now the same in BASIC
For a=10 to 20
Print "value of a: ",a
Next a
The only thing we don't know about is if "a" is a integer or not. How ever we can just say the default type in integer.
Now if we add the superfluous key words to the BASIC program we get:
For a=10 to 20 do
begin
print "value of a: ",a
Next a
end
Or adding even more superfluous lines
begin
for a = 10 to 20 do
begin
print "value of a: ", a
next a
end
end
Or we could remove the superfluous key words from PASCAL
var
a: integer;
for a := 10 to 20
writeln('value of a: ', a);
end;
end.
Queeg-500 lol
@MichaelKingsfordGray given the reference, probably much much older.... April, May, June, July Fools
I can't hear what you're saying because of the bloody awful 'music' blasting away.