• Please review our updated Terms and Rules here

Developing for the IBM PC

pontus

Veteran Member
Joined
Aug 13, 2008
Messages
698
Location
Uppsala, Sweden
Hi!

I just got myself an IBM 5150. And I though that it might actually be an interesting experience to do some software development for it and on it. I am a software developer by trade so I think (or at least hope) I know what I'm getting myself into. But I would like some pointers on how to set up a suitable development environment. Also a pointer to some good books or web pages on the subject would be nice.

I don't mind starting out on an emulator or more modern machine (I have a 486) if that is good stepping stone.

So, where do I start?
 
It all depends on to what level you want to program it. If you really want to understand how the PC work on the lowest level, I would suggest you get a book that covers the inner workings of the PC. A book I can suggest here is the revised edition of "The IBM Personal Computer from the inside-out" by Murray III Sargent and Richard L. Shoemaker. This book gives a full description of how CPUs and the x86 assembler language works (including the x87 FPU), some basics on TTL-logic, and then some chapters on the various devices that makes up the PC. It also has sections on communication, timing, and how to interface with analog devices. This book also contains a lot of references to books of futher and more detailed/technical literature.

If you just want to program, without nessecarely understanding how the PC works on a lower level, then you can read up on some 3rd-level languages like Pascal, C or Fortran. You may still be interested in learning how the BIOS interface works and how some of the devices in the PC works, like the CGA, MDA and EGA.
 
What language?
The purpose would be to get a bit more intimate with the IBM PC, high level stuff I do all day :) C interspersed with assembler sounds like a suitable combination.

A book I can suggest here is the revised edition of "The IBM Personal Computer from the inside-out" by Murray III Sargent and Richard L. Shoemaker.
Thank you Per, I'll check that book out.
 
The Waite Group's MS-DOS Developers Guide is a fantastic resource, too. I have the 2nd edition, which covers EGA/VGA and up through the 386. I'm not sure where the first edition stops, so it might be a bit 16 or 32 bit centric for a 5150, but it's still a good mix of Hardware and software knowledge.
 
I can't remember what processor it was compiled for but there was a great little dos app called helppc which at least this link also converted to a web reference. It has most of the BIOS and MS-DOS interrupts and functions listed as well as simple examples of usage which was a huge help to a friend and I when we were playing around.

Other than that you could get an IDE or install of tasm, masm, or just play inside of debug.com which is what I did. To make it easier I wrote things in a text editor and made it a batch file to macro my commands to debug (in order to name and write my txt file).
 
Hi!

I just got myself an IBM 5150. And I though that it might actually be an interesting experience to do some software development for it and on it. I am a software developer by trade so I think (or at least hope) I know what I'm getting myself into. But I would like some pointers on how to set up a suitable development environment. Also a pointer to some good books or web pages on the subject would be nice.

I don't mind starting out on an emulator or more modern machine (I have a 486) if that is good stepping stone.

So, where do I start?


You could write a Windows Like OS with web browsing capabilities in pure assembly, that will run on the 8088, that will keep ya busy..

:)
 
My introduction to x86 assembly language was via cracking copy protection on DOS games. There are a few good tutorials out there (search for buckaroo bonzai cracking) and there are some dead simple games to crack. My first crack was Harley Davidson Road to Sturgis.
This way you get to dive in head first, plus you get the reward for beating an obstacle and making software do what you want. I quickly learned interrupts and CPU registers this way, and from there, since I was drunk with power, nothing could stop me!
 
I would suggest the Borland compilers to start with just because the early versions are officially free (turbo pascal 3.01 and 5.5, Turbo C 3.0), the later versions are easy enough to find. On a low memory systems Turbo Pascal 3 is one of the few that can operate in as little as 128k of RAM with a built in editor off a single 360k floppy with room to burn... while more robust versions like turbo pascal 7 remains one of the best compilers ever made for DOS -- even compared to most C implementations INCLUDING Borland's own attempts.

The official Embacardawhateverthehellthey'recalled site is a pain in the ass to download them from, but many sites have them mirrored... RGB Classic games for example:
http://www.classicdosgames.com/utilities/dos.html

Has Turbo C 2.0, Turbo C++ 1.0, and Turbo Pascal 1, 3.01 and 5.5 up. You go to someplace like WinWorld and they've got every major release up (of dubious legality, but hey...)

It also helps that bitsavers has a Borland directory in which you can download PDF copies of all the manuals:
http://www.bitsavers.org/pdf/borland/

One of the reasons I like the Borland compilers, especially later versions of Turbo pascal is it's so easy to include assembler... In TP3 you had to 'assemble' your own code first for inlining (which sucked) but by the time of TP4 and later it has a ASM directive, which triggers an actual assembler. My recent game release makes heavy use of that capability as the parts I need fast are all ASM, while I basically use Turbo Pascal as the "glue" to hold it together.

One of the best resources for old-school DOS programming is the SWAG -- sourceware archival group... It's mostly targeting pascal (with some asm laced in)... unfortunately the company that was hosting it online in HTML form was throwing errors, and now seems to have gone down completely. Thankfully there's a downloadable copy available for free on Simtel.
http://www.simtel.net/product/view/id/63036

Even if you're not programming in Pascal, the SWAG contains many easy to understand code examples that are easily ported to other languages.

One way I've 'sped up' my development process for the older systems is to do my preliminary testing in DosBox on my modern machine. If you screw up and crash it, it's a lot nicer (and faster) to be able to just kill DosBox and start up a new copy than to sit there waiting for one of the old systems to reboot. It also lets me use modern editors (I like Crimson Editor, but any good text editor will do) to manage the code, while using the command line versions of TASM, TP and Turbo C to compile and test inside DosBox -- it's much the same process as testing your OS level code for Linux or Windows development inside a VM like VirtualBox... the advantage being you can safely let the host PC have direct access to the directory DosBox is treating as a drive, and crashing the testing environment won't take your editor down with it.

I highly recommend yhkwong's SVN builds as it has a lot of bugfixes and feels "closer" to the real hardware than the current official binary release... and he throws in a bunch of stuff the main trunk can't include for legal reasons like MUNT, 3dFX Glide emulation, etc. Even has a better rendering tree (the openGL and direct3d modes are absolutely kick-ass)

It also lets one rapidly test multiple configurations -- I've got shortcuts on the desktop for CGA/PC Speaker, Tandy/TandySound, EGA w/CMS, VGA with Adlib/SB and VGA+MUNT. (as my real MT32 shit the bed) . It's also nice to be able to hit ctrl+plus and ctrl+F11/F12 to quickly play with the timings -- un-throttling it for instant compilation and then choking it down to 270 to 280 cycles to get a feel for what it will be like on a 4.77mhz XT.

While it's not 100% true to the real hardware, it's a great start especially if you are trying to target multiple platforms simultaneously.

There's also a few extra books I always find handy -- Ferraro's "programmers guide to the EGA/VGA" is pretty much a must-have; wish I could find that in PDF as my print copy is getting pretty threadbare. (and it would be nice to be able to do a fulltext search)... Another book that is really good once you get down to the low-level stuff is Micheal Abrash's "Black Book" -- a halfway decent HTML version can be found here:
http://www.phatcode.net/res/224/files/html/index.html

Though the later chapters cover 386 and higher processors and the VGA card, most of the early chapters apply well to the 8088 -- particularly the "cycle eaters" sections.

Ralph Browns Interrupt lists:
http://www.ctyme.com/rbrown.htm

Is also VERY handy for doing DOS programming -- I refer to it all the time... (though my code is using software int's less and less)

That's all I can think of for now...
 
I'm a professional programmer by trade, but I usually work on big iron. Programming for old hardware is challenging too, but in different ways.

While I've been familiar with IBM PC architecture for close to 27 years now, I only really got good at it in the last four or five years.

If you want to program directly on the PC 5150 you need to restrict your programming environment quite a bit. The 5150 is slow and if you don't have a hard drive you will learn to hate shuffling floppy disks. I used the following environments on the 5150 and similar machines:

  • Turbo Pascal 3.0. (Later versions might be tolerable)
  • Interpreted BASIC and the BASIC compiler.
  • Zbasic 3.x and 4.x. (3.x was solid. 4.x could be flakey. Both would be hard to find now.)

Assembly language would work too, but that's like diving into the deep end of the pool on your first day.

If you want to just target the 5150 for the code you are going to run and you can program on a more capable machine you will have more options.

My favorite programming environment for quite a few years was Borland Turbo C++ 3.0 for DOS on a 386-40 machine. All of the mTCP code up until about a year ago was written using this environment. The Integrated Development Environment includes a debugger and you can embed assembly language into your C code fairly easily. Despite the name this compiler supports both C and C++.

Recently I moved to Open Watcom 1.9 on a "new" Windows XP machine. Open Watcom is a derivative of the original Watcom C compilers, and the compiler has versions that run natively under DOS, Windows and Linux. All of the compilers can generate code for other targets, so on my Windows XP machine running the Windows version of Open Watcom I generate 16 bit DOS applications. Open Watcom generates better (more optimized) code, has a more up-to-date run-time library, and it is still being updated. It is open source so if you have a problem with the run-time or the compiler you can look at the code, which I've done on several occasions. You can embed assembler or mix stand-alone assembler modules using the included assembler.

The current version of mTCP is running on Open Watcom. Being able to use my fastest machine with multiple editing windows has improved my productivity quite a bit.

For reference and light reading you should have a good library. Some of the books in my collection are:

  • Microsoft MSDOS Programmers Reference
  • DOS 6 Developers Guide, Kyle,
  • Undocumented DOS, 2nd Edition, Schulman
  • Memory Resident Programming on the IBM PC, Wadlow
  • Writing DOS Device Drivers in C, Adams/Tondo
  • The 8086/8088 Primer, Second Edition
  • IBM PC Assembly Language, Scanlon
  • Assembler for the IBM PC and PC-XT, Abel
  • The 80386/387 Architecture, Morse Isaacson and Albert
  • System BIOS for IBM PC/XT/AT Computers and Compatibles, Phoenix
  • Assembly Language For Intel-Based Computers, Irvine
  • More TCP/IP books than you can imagine
  • Language Refs, for C, BASIC, Pascal, etc.
  • Technical References for the major machines (for the BIOS references)


Documentation is your friend ....
 
I'm shocked people are actually using real hardware for development. Unless you're really a purest, save the grief and heartache and use DOSBox to develop and initially test code. Then use a real PC with some drive sharing network connectivity to do final testing.
 
I *very much* prefer to develop on 'real' hardware versus DOSbox. I don't even have DOSbox (or Winuae, or any other emulator) installed on my modern PCs. If I want to write code on my Win 7 box, I'll use Visual Studio and write a win 7 app. If I want to write code on my 386, I'll use Borland C++ and write code on my 386. A big part of the allure of this hobby, to me, is tied into the idea that these systems can be just as useful today as they were 25 years ago.
 
Thanks everybody for great answers!

Especially deathshadow and mbbrutman for some great pointers. Both Turbo Pascal and The watcom compilers sound interesting. Right now I'm leaning towards Open Watcom 1.9 since it runs on linux (which I use on my modern PC) and I know C, no need to learn Pascal as well (although I have written a few lines of code in Pascal back in the day).

First I want to get a bit more familiar with the hardware of the 5150 and then move on to learn a little assembly. If it can output a tiny demo after that, I'm satisfied :)

I suppose I will have to run on real hardware or find a half-decent emulator for the 5150. How good i DOSBox in this regard?
 
I'm shocked people are actually using real hardware for development. Unless you're really a purest, save the grief and heartache and use DOSBox to develop and initially test code. Then use a real PC with some drive sharing network connectivity to do final testing.

You shouldn't be so shocked - DOSBox isn't appropriate for a lot of testing.

It is an emulator - their primary focus is on games. At the moment it doesn't support DOS Ctrl-Break handling - most games don't use it. That makes it difficult to test code that requires that feature. (All of my code supports Ctrl-Break to break out of a program, and I have to trap it to shut down the networking code cleanly.)

DOSBox also uses the native filesystem, and thus doesn't adhere to the pathlength restrictions that real DOS requires. That became an issue when testing my FTP server.

There are other limitations ... go read the docs. Depending on your needs, testing on real hardware with different variations of hardware and software is prudent.

If you want to test your code on something more robust than DOSBox but not a full machine, VirtualBox and VMWare are good solutions. That at least lets you test different versions of DOS. They both support what would look like a fairly "newish" machine, so if your code is sensitive to the processor type you might still need to find older hardware. I found a bug in VirtualBox related to reprogramming the system timer; I'm not sure if it is fixed yet. (It ruined the timing of the entire virtual machine until the system timer was restored back to normal at the end of the program.) VMWare didn't have that problem. Your mileage will vary ...
 
pontus: Hey, we just talked about this on the IRC channel yesterday! :D

I have to agree with mbbrutman... I used to use Microsoft Quick-C for DOS, on my Tandy 1400 LT, and man, the shuffling of floppy disks really sucked. If the hardcard on that PC works, it really opens the door for your programming. I also recommend the Borland products, mainly because of their ease of acquiring. You can start with some of the older ones that are freely available from Borland, and if you look around, you might just find legal copies of other Borland compilers. I walked into Best Buy one day, a few years ago, and they were selling a boxed set of Borland C++ 5.5, and TurboC++ 3.0, for something like $30. You can probably get it cheaper off of eBay.

Anyway, those are good to get started with, and there are plenty of tutorials out on the web. Good luck, and have fun!
 
I too recommend the old Turbo compilers.. nothing can get you productive as fast and easy as those compilers. Back in the eighties I used TP on both CP/M and MS-DOS, and later also TC on MS-DOS. My main work environment was on minicomputers though and I found it easy to port my own as well as other people's code to the minis, despite the infamous "extensions" TP (in particular) had, compared to the so-called ISO standard. Those extensions made it easier actually, for some reason. A colleague ported the spreadsheet example that came with TP 3.x to VAX Pascal, even. (I worked mostly on a non-VAX architecture though).

I came across an old TP review in Byte the other day.. memories awakened again :) June 1984, there's a PDF copy at ftp://helpedia.com/pub/archive/temp/Byte/Other 2/ (I remember reading it back then when it was fresh).
 
i use Borland Turbo C++ 1.01 (which is freely available and sanctioned as such by Borland) on my PC and XT. here is a download link: http://www.uv.tietgen.dk/staff/mlha/download/dos/borland/tcpp101.zip

as long as you dont have a HUGE program to compile, it's quick enough on an 8088. the lack of syntax highlighting in the IDE for 1.01 is kind of annoying but not a deal-breaker. i like Microsoft QuickC as well.

when it comes the discussion of doing the actual development for DOS in an emulator, nah in a lot of cases i like doing it on real metal. sometimes i do it in my emulator Fake86 though, it's kind of fun to full developent in an emu you wrote yourself! xD

QEMU is also a great solution to code under DOS in.
 
Last edited:
There's also a copy of Borland TurboC 3.0 on the VCGM last time I checked. Unfortunately I'm not sure of the CPU requirements but anyone wanting to learn C on a dos system (I can say I've run it on a 386 and higher) it's GREAT with built-in help just like QuickBasic and examples on commands. Made it so much smoother for playing around with new commands or trying to figure out why a command isn't working.

Emulators have their place but yeah there were some oddities working on them and then real hardware. They are nice though for quick dev test systems and quick reboots.
 
Back
Top