IBM PC 5150 Development Notes

IBM PC (5150) Development Notes

Here are some notes during my quest to find a real-mode C compiler for the 16-bit x86, and to produce a binary that is not dependent on DOS.


Why the IBM PC 5150?

The 6502-processor was available in 1975. It’s utility was first demonstrated in 1976 with the KIM-1, and integrated into a functional system (the Commodore PET) in January 1977. Similarly, the Z-80 processor was released in 1976, and integrated into a functional system (TRS-80) in August 1977. Having already accomplished builds for these early systems, why bother with a 1981 system that was based on a June 1979 8088-processor? Just for the challenge of it.

The IBM PC 5150 represents a major shift in Personal Computers, to an even more expansive and open architecture. While it was a more complex system (e.g. 20-bit segment:offset addressing, extensive interrupts), it allowed more diverse hardware and use of even larger amounts of RAM.

The late model Commodore SuperPET maxed to 96KB of RAM. The TRS-80 series peaked at 48KB. The Apple II was also limited to 48KB, with the Apple II+ being expandable to 64KB. Commodore and Tandy also released some 128KB systems (C128 and Color Computer III).

Between 1977-1981, most systems were around 4K to 64K. But the potential of software was becoming better understood and more programmers were being trained, becoming more formal parts of universities as they started offering Computer Science degrees. While certainly more capable computers existed, they were still physically massive and expensive. The demand for software in small business and home offices was rapidly growing, and the industry found ways to reduce costs to satisfy these demands.

RAM chip prices were coming down as more production factories became available worldwide and the process becoming better understood. The industry was ready to move beyond 64KB, but needed more extensive Operating Systems to help “organically” load software (and to avoid accidental use of already port-mapped addresses). The IBM PC system supported up to 1MB (16 segments of 64KB, where 10 were for end-user usage and 6 reserved for system services). Things like screen buffers were placed at the top 384KB portion. Thus for many years, a sort of 640KB system RAM barrier existed for the IBM-PC system (primarily to retain backwards compatibility). This could be viewed as having 10 “regular” 64KB machines available, but DOS made this RAM appear as one contiguous “conventional memory” region. [ note: Bill Gates never actually said this would be enough for anyone ]. The “640KB barrier” was not resolved until late 1980s (with the 386, and introduction of things like EMS, DPMI, HIMEM, and supporting software drivers).

The IBM PC 5150 represents essentially the last 64KB real-mode PC system, that also supported a cassette tape input and a 40×25 text-mode resolution (attributes similar to the original 1977’s PC). Soon after 1981, then 128KB, 384KB, 640KB systems became commonplace, and true graphics modes became standard (with “off the shelf” components — whereas, if the video circuits of the Commodore PET or Apple ][ break, they are very difficult to replace, see here). Niche “boot-up-BASIC” systems (like C64 and Tandy Color Computers) did persist (sold-to-consumers) until roughly 1990, but the IBM PC and MS-DOS came to dominated the PC market (with the Macintosh as a viable, but expensive, alternative).

With larger memory available, more robust programming environments could be used (Pascal, C) allowing even more sophisticated software applications (web browsers, e-mail, image editing, large scale databases for inventory and accounting, astronomy, and of course gaming).

During all this industry growth, IBM-clones were not without competition (re: Commodore Amiga, Apple Macintosh). But the “off the shelf components” nature of IBM-clones and dominating presence of MS-DOS made them extremely popular. The Tandy system, for example, was ultimately unable to compete in the market and the TRS-80 series ended roughly in 1991 (Tandy did have their own IBM PC-clone line until about 1993). Similarly, Commodore essentially ceased around 1993/1994. Apple, too, nearly went under in 1997, but was miraculously rescued (which was then followed by the iMac in 1998 and iPod in 2001 — a suave portable device that could decode digital music and had a useful battery life, putting the Sony Walkman to rest).

In 2005, Apple abandoned the PowerPC (an IBM/Motorola sponsored processor), details here, which aligned even more of the industry behind the x86 architecture. The reasons were more economical rather than technical (licensing costs of the PowerPC were too expensive, although the PPC system did have some technical benefits). In 2020, Apple had acquired so much money, they announced development of their own processor chips to be used across their products (see here), to reduce their dependence on Intel (x86).

As the concepts of IoT (Internet of Things) and use of chips expand further, we may see a revival of highly-efficient software to accommodate low-powered embedded systems (space/medical applications, and more casual consumer devices, including even clothes/fabric, sunglasses, watches, or applications where fan or liquid cooled CPUs aren’t suitable).

NOTE: 640K barrier explained here. (it wasn’t just a Microsoft fault)

The IBM PC 5150 was successful (see here), barebones being ~$1500 and “fully loaded” at $6000 (256KB RAM, color video) due to the appeal and confidence of the IBM branding and industry partners. But the initial specs were quite humble: 80×25 text screen (640×200 CGA graphic), limited sound and graphics, 160KB 5.25″ floppy disks, the initial IBM PC even supported a cassette drive, and the 8088 was an unexciting processor from 1979. Just like the earlier 1977 machines, it booted up to Microsoft BASIC in ROM. From a hardware standpoint, it wasn’t particularly revolutionary.

The difference was IBM and Microsoft were setting the foundational architecture for an enduring modular system. The system was well documented and had many industrial partners, who built peripherals that quickly expanded the capabilities of the IBM PC. While Commodore and Apple did have a limited “open architecture” and expansion card options, it essentially came down to finding a critical mass of industrial partners to support the “hardware ecosystem” – which was something that IBM, Intel, and Microsoft excelled at. And, the rest is history: the IBM PC-clone and x86 architecture remains in use as the dominant home/office Personal Computer system to this day.

Developing the Code

NOTES on using the Borland Turbo C compiler (and how to setup 86BOX for a typical 486 MS-DOS 6.0 configuration). While this did work, I abandoned this path in favor of what is described below.

Here are notes on the C compiler chosen for this project:

  • WATCOM C/C++ compiler DOWNLOAD (2.0) or DOWNLOAD (1.9)
  • Use This: Open WATCOM Portable Compiler 1.9 LINK
  • NOTE: Actually you might try version 1.9 to build the .COM (I actually installed both, and realized in my successful builds I am actually using the 1.9 version per the Help|About of the IDE)
  • WATCOM C was a little odd to use at first, but I created a .COM target as follows (below). With very code changes, and some very useful compiler warnings, DHUNTER has been compiled and a .COM file is produced. However, I already know some PEEK/POKE updates are needed before actually running it.
  • Advantages of using WATCOM: 64-bit IDE means I can keep all existing long-filenames (whereas with importing to 86BOX, PC-DOS, Borland I have to use 8.3 filenames, yuck!).

The .COM produced needs to get transferred over to the IBM PC system. To do this, use the following tool…

  • WinImage for creating 360K (for PC-DOS 2.10)
  • For MS-DOS 3.x or 6.x: use 1.44MB floppy disk images [DOS 3.x and 6.x can use 360K floppies, but the Borland/TASM install images are on 1.44mb, so I just use that format also under those versions of the OS]
  • NOTE: WinImage is unable to create 160KB single sided floppy disk images (as used by the original IBM PC-DOS 1.0). When you go to File|New, it will list 160KB as a standard format option – but WinImage can not read existing 160KB single sided images (i.e. can’t add files to them), and the 160KB format it creates doesn’t appear to be compatible with PC-DOS 1.0. The 180KB format MIGHT be compatible, but the 360KB format is for-sure compatible back to PC-DOS 2.10. [ the 86BOX emulator is able to read PC-DOS 1.0 160KB images, so you can boot to PC-DOS 1.0 but difficult to add files to it ]
  • Proposed alternative: DiskExplorer (vector.co.jp)
  • NOTE: PC-DOS 2.10 image has preserved the October 1983 date! πŸ™‚

NOTE: Choosing the name of the binary is important, since it will be limited to the 8.3 PC-DOS convention. Fortunately “DHUNTER.COM” fits nicely.

Have resolved INT16 for keyboard input, and suitable “far-address” POKEs to write to the screen buffer. Now working on TIMER and SOUND interrupts, and updating the character codes — and after that, Destiny Hunter will be available on the x86 πŸ™‚ I think I can even offer both a COLOR version like the C64 build.

Running the Code

IBM provided a manual called “IBM Guide to Operations” LINK that was available in the August 1981 launch of the IBM PC. This manual describes the differences between C1.0 (cassette), D1.0 (disk), and A1.0 (advanced) BASICs.

To match with this manual, use the IBM PC-DOS 1.0 image, which can work on a 64K IBM PC.

  • Machine Type: Set the machine type to IBM PC (1981), corresponding to the August 1981 release of the IBM PC. Set the machine to 64KB RAM (memory).
  • Disk Drives: High-density disks were not available yet in 1981. Set the disk drives for this emulator to 5.25″ 180k disks (at this time, 86BOX drive selection doesn’t list 160k drives – but its 180k drive support turns out to be compatible with the 160k images) .
  • Obtain PC-DOS image: PC-DOS 1.0 HERE
  • NOTE: The PC-DOS 1.0 and 1.10 disk IMG are single sided (160KB) images. Setting 86BOX to use 180KB drives still seems to be compatible with READING 160KB images. However, WinImage seems unable to read or write these 160KB images. This means in order to copy a .COM creation to a disk image, we need to use PC-DOS 2.10.
  • NOTE: PC-DOS 1.10 is equivalent to MS-DOS 1.25. This discrepancies in versions is a bit difficult to explain. IBM and Microsoft had a “relationship” early, with Microsoft doing much of the DOS software development. But it was still an IBM PC product and the early development had much secrecy. However, IBM had released a “spec” and very precise manuals, and used “off the shelf” parts. And so from the beginning, there were “IBM Clones” available. MS-DOS accommodated these particular OEM vendors with their hardware nuances (some being trivial differences, such as one MS-DOS might very be compatible with multiple OEM packages, but this wasn’t guaranteed).
  • An MS-DOS might also run on the original IBM PC. In any case, to be “canon” for this project, I am sticking with the original IBM PC spec and original IBM PC-DOS.
  • Despite the term PC-DOS, Microsoft was very much involved in its development. IBM and Microsoft continued a “relationship” for many years, perhaps until the later days of the OS/2 project (where eventually Microsoft went there own way down the “NT” path, while IBM continued to support OS/2). But all that time, Microsoft was free to license its MS-DOS to various PC vendors, while maintaining the “IBM-pure” baseline (PC-DOS). “Major” vendors like HP, DELL, Tandy, Compaq, Gateway would tend to have specialized packages of MS-DOS (leading to “Crapware” that continued into the Windows days, with vendor essentially including “extras” like product demos, advertisements, but occasionally actual unique features).

Review of PC-DOS 1.0 Content

The PC-DOS disk required no setup/install. However, the IBM Guide to Operation first instructions were to essentially teach how to make a backup copy of disks (like the PC-DOS disk, using the “diskcopy” program which ensures also copying of hidden files). The machine could be booted to C1.0 BASIC by not inserting any disks (i.e. boot up BASIC just like many PCs since 1977). Or PC-DOS could be booted by inserting a boot disk into drive A:.

The original boot disk contained a few .COM files, BASIC .BAS samples, and a single .EXE file. Note the date of the files: August 4, 1981. Also, the manual mentions that for PC-DOS 1.0 the root folder was limited to 64 files (and sub-folders did not yet exists).

COMMAND.COM built in commands: COPY, DIR, ERASE, RENAME, TYPE (notice lack of commands like MKDIR, CD, RM, but they did support “wldcards” which the manual calls “global characters”, asterick “*” and question mark “?”).
MODE ,r,t [ test pattern ]


To exit from BASIC.COM or BASICA.COM, type command “system”.

Within BASIC: (C1.X BASIC did not have disk access support)
DIR->FILES
ERASE->KILL
RENAME->NAME

Then IBM PC-DOS also contained various BASIC samples. The IBM Guide to Operations talks about how to load these programs:

  • Load BASIC.COM or BASICA.COM
  • Enter command: load”samples
  • Most the BASIC examples are accessed from the SAMPLES project. The SAMPLES includes a MUSIC sample, which will in turn load sample tunes from various other BASIC files.
  • One unique other project is: load”comm
  • This uses asynchronous capability of the communication port, to access “THE SOURCE” (aka Dow Jones)

Here is an example of the PIECHART.BAS, which is interesting that it creates an actual proportional pie chart based on user-supplied data.

Per the “IBM Guide to Operations”, section “DOS 3-46” contains this description of the PC-DOS content:

NOTE: For MS-DOS, there were also two hidden files – IO.SYS and MSDOS.SYS, which were both HIDDEN and flagged with the SYSTEM attribute (see ATTRIB.EXE). It’s differences like this that characterize the distinction between MS-DOS and PC-DOS (“same but different”).

Example of Cassette Support in IBM PC

In the IBM Guide to Operations, in the “Problem Determination Procedures” (diagnostics) section, it describes how ot use the cassette recorder.

  • Boot the IBM PC with no disks inserted
  • In C1.0 BASIC (cassette), issue command load”ldcass
  • Wait a few seconds for the load to complete (“Ok” appears)
  • Type “run” (this really takes several minutes to initialize itself!)

After this, then here is the first available cassette program for the IBM PC.

NOTE: 86BOX doesn’t support cassette operation. So use the PCE-IBMPC emulator to model this. DOWNLOAD (I used pce-0.2.2-ibmpc.zip ) [ NOTE: Due to various controversies, a different emulator called “PCem” was essentially shutdown in Summer 2021; update: PCem it seems to be resumed as of December 2021 ]

NOTE: You will also need to download various ROMS in the “PC BIOS” section of the same link above. For example you can get the ibm-basic-1.10.rom

NOTE: To force booting of ROM BASIC, I updated the pce-ibmpc.cfg file to remove any reference to disk drives (make a backup copy of this file first before doing any modifications).


Some Interesting articles

The PC’s BIOS (pcministry.com)

https://www.pcworld.com/article/237878/can_you_do_real_work_with_the_30_year_old_ibm_5150_.html

Click to access IBM%20BASICA%20v1.10%20Manual.pdf

IBM 5150 Technical Reference 6025005 AUG81 (minuszerodegrees.net)

80×86 16-bit Compiling How-to by Alexei A. Frounze (narod.ru)

BIOS Data Area (stanislavs.org)

Int86 function in C| System interrupt, Union REGS, Int86x, Intdos, intdosx (equestionanswers.com)

Turbo C – Long Entry (itlnet.net) [example to read and set back video mode from C]

IBM Disk Operating System – Version 2.10 – Reference (retropc.se) [2-85 describes the EXE2BIN utility provided by PC-DOS!]

Inline assembly with Watcom Β· Cogs and Levers (tuttlem.github.io)

PCem: Emulate the Tandy 1000 & MS-DOS on an 8088. – The Developer’s Tidbits (devtidbits.com)


Rolling my own .COM binary…

Learned about the x86 OUT instruction, a specific CPU opcode for talking to I/O hardware ports.

.COM programs start 0x0100 (the first 256 bytes is a hold-over from CP/M origin of MS-DOS, where they had a 256 byte header that also held content after the filename command {i.e. command line arguments}).

climatex/5150CAXX: DOS cassette tape interface for IBM PC. (github.com)

Birth of a standard: The Intel 8086 microprocessor | PCWorld

Software spotlight: Cassette software for the IBM PC β€” WinWorld (winworldpc.com)

VC&G | Β» [ VC&G Anthology ] Origins of the ASCII Smiley Character: An Email Exchange With Dr. David Bradley (2011) (vintagecomputing.com)

“IRQ: 7” – The Complicated World of early MS-DOS Sound Options – Fatnick Industries (mechafatnick.co.uk)

Beyond Beep-Boop: Mastering the PC Speaker | Bumbershoot Software (wordpress.com)

Reliable way of turning off cursor:

asm, Blinking cursor (computer-programming-forum.com)

For historical purposes, here is my first runnable conversion of Destiny Hunter for the IBM PC (from the Commodore PET version):

For notes on my physical IBM PC 5150, see here.

Leave a comment