Writing my first program, 28 years after

Let's go back to 1994 and write my first program
Published on November 21, 2022 under the tag programming, qemu

If you are a programmer then you probably remember the first time that you wrote an actual program. It probably wasn’t sophisticated piece of software. Maybe you just copied some chunk of code and ran it to see the effect. Maybe you changed some lines or played with variables. The first things we do are the most influential for our life.

For me the year was 1994 and I had an 486 pc which I used as most other kids to play games. I think I got the source code on piece of paper from some programming book or maybe a file from my friend. It was written in QBasic and after copying line by line all the code and running it, the result was a sequence of colored dots displayed on my screen. Amazing !!! Let’s try and recreate this nostalgic experience.

First we need to install msdos. I think I was running msdos 5.0 at that time.

Let’s download msdos 5.0. First link Microsoft MS-DOS 5.00 (3.5-720k) promises .7z file.

$ wget -q 'https://dl.winworldpc.com/Microsoft%20MS-DOS%205.00%20(3.5-720k).7z'
$ ls
'Microsoft MS-DOS 5.00 (3.5-720k).7z'
$ 7z e 'Microsoft MS-DOS 5.00 (3.5-720k).7z' > /dev/null
$ ls *.img
Disk01.img  Disk02.img  Disk03.img

We will use qemu to emulate our hardware. I don’t remember the exact spec of my pc. But according to this 1994 pc, 486DX2 was coming with 8MB of RAM and 320 MB disk size.

$ qemu-img create -f raw msdos.disk 320M
Formatting 'msdos.disk', fmt=raw size=335544320

Now let’s run our system and install msdos5.0

qemu-system-i386 -m 8M -hda msdos.disk -L . -fda Disk01.img -boot a

Installing msdos is pretty easy. Just press enter, enter, enter, enter 4 times (choosing the default options). The msdos will format the disk. It will install the first floppy from three floppies and ask to insert the second one. To do this you can switch to qemu monitor (using Ctrl+Alt+2), where you can use the following command to switch the floppy image.

(qemu) change floppy0 Disk02.img

Then go back to the display (Ctrl+Alt+1) and press enter. Repeat same sequence for the third disk (change floppy0 Disk03.img). When the prompt asks to remove all floppy disks you can switch to qemu monitor and run eject floppy0. Then press enter and the msdos 5.0 will start from hard disk.

You can press Shift+f9 to enter the command prompt and then just type qbasic.exe to enter the qbasic program.

Press ESC to clear screen and then write the program

SCREEN 1
FOR x = 0 TO 10
  FOR y= 0 TO x
    PSET (x * 10, y * 10), RND * 2 + 1
    t0 = TIMER
    DO
    LOOP UNTIL TIMER - t0 > .1
  NEXT
NEXT

After that pressing F5 will run the amazing program which will display colorful dots in the shape of triangular.

This was the start of my programming adventure. First steps always look so simple after you walked for a long time.