FOSBIC1 compiler

Or Basic compiler/system in Fortran IV

I came across fosbic1 on github by accident, so intrigued by the description:

This is the FOSBIC1 compiler developed at the University of Gießen, Germany
in the late 70s for the CDC 3300 batch system.

It is a BASIC compiler and runtime system which is written in FORTRAN IV.

The text book from which the source code was copied implies that it is
a modified version of a BASIC compiler named UWBIC from the University of Washington, developed by William Sharp in 1967, for their IBM 7094.

So, without going into it much further I went ahead and made a few minor changes to get it running on Microsoft Fortran


Instead of some boring example, I thought I’d try some Mandelbrot, so going through this collection on rosettacode, I thought the OS/8 version looked simple enough to work with.

Sadly it doesn’t seem to be very ASCII so it doesn’t understand numerical characters. Maybe I’m doing it wrong I didn’t see anything. Just as my attempt to set a string variable to itself + a new letter then print that string strangely failed. Also it does weird stuff with strings, again it maybe me, but I’m impatient. This is terrible, and yeah I know.

                                        TESTCOMPILER -- BASIC BWL 5 GIESSEN -- VERSION 6/76-04

                   10 X1=59
                   11 Y1=21
                   20 I1=-1.0
                   21 I2=1.0
                   22 R1=-2.0
                   23 R2=1.0
                   30 S1=(R2-R1)/X1
                   31 S2=(I2-I1)/Y1
                   40 FOR Y=0 TO Y1
                   50 I3=I1+S2*Y
                   60 FOR X=0 TO X1
                   70 R3=R1+S1*X
                   71 Z1=R3
                   72 Z2=I3
                   80 FOR N=0 TO 30
                   90 A=Z1*Z1
                   91 B=Z2*Z2
                   100 IF A+B>4.0 GOTO 130
                   110 Z2=2*Z1*Z2+I3
                   111 Z1=A-B+R3
                   120 NEXT N
                   130 REM PRINT CHR$(0062-N);
                   131 IF N=0  THEN 200
                   132 IF N=1  THEN 202
                   133 IF N=10 THEN 204
                   134 IF N=11 THEN 206
                   135 IF N=12 THEN 208
                   136 IF N=14 THEN 210
                   137 IF N=15 THEN 212
                   138 IF N=16 THEN 214
                   139 IF N=17 THEN 216
                   140 IF N=19 THEN 218
                   141 IF N=2  THEN 230
                   142 IF N=20 THEN 232
                   143 IF N=22 THEN 234
                   144 IF N=23 THEN 236
                   145 IF N=24 THEN 238
                   146 IF N=25 THEN 240
                   147 IF N=3  THEN 242
                   148 IF N=30 THEN 244
                   149 IF N=31 THEN 246
                   150 IF N=4  THEN 248
                   151 IF N=5  THEN 250
                   152 IF N=6  THEN 252
                   153 IF N=7  THEN 254
                   154 IF N=8  THEN 256
                   155 IF N=9  THEN 258
                   200 PRINT 'A';
                   201 GOTO 439
                   202 PRINT 'B';
                   203 GOTO 439
                   204 PRINT 'C';
                   205 GOTO 439
                   206 PRINT 'D';
                   207 GOTO 439
                   208 PRINT 'E';
                   209 GOTO 439
                   210 PRINT 'F';
                   211 GOTO 439
                   212 PRINT 'G';
                   213 GOTO 439
                   214 PRINT 'H';
                   215 GOTO 439
                   216 PRINT 'I';
                   217 GOTO 439
                   218 PRINT 'J';
                   219 GOTO 439
                   230 PRINT 'K';
                   231 GOTO 439
                   232 PRINT 'L';
                   233 GOTO 439
                   234 PRINT 'M';
                   235 GOTO 439
                   236 PRINT 'N';
                   237 GOTO 439
                   238 PRINT 'O';
                   239 GOTO 439
                   240 PRINT 'P';
                   241 GOTO 439
                   242 PRINT 'Q';
                   243 GOTO 439
                   244 PRINT 'R';
                   245 GOTO 439
                   246 PRINT '-';
                   247 GOTO 439
                   248 PRINT 'T';
                   249 GOTO 439
                   250 PRINT 'U';
                   251 GOTO 439
                   252 PRINT 'V';
                   253 GOTO 439
                   254 PRINT 'W';
                   255 GOTO 439
                   256 PRINT 'X';
                   257 GOTO 439
                   258 PRINT 'Y';
                   259 GOTO 439
                   439 REM
                   440 NEXT X
                   450 PRINT '-EOL'
                   460 NEXT Y
                   461 PRINT 'END'
                   470 END

It runs in batches, so it’s not interactive. Very mainframe/1960’s minicomputer like. I guess it’s fitting again being in FORTRAN.

******************* EVERYTHING SEEMS OK -- LET'S GO AHEAD

                    PERCENT OF AVAILABLE STORAGE USED               31.081
                    PERCENT OF AVAILABLE DATA STORAGE USED            .000

AA    A    A    A    A    B    B    B    B    B    K    K    K    K    K
K    K    K    K    K    K    K    K    K    K    Q    Q    Q    Q    Q
Q    T    T    T    U    X    F    D    E    T    Q    Q    Q    Q    K
K    K    K    B    B    B    B    B    B    B    B    B    B    B    -EOL

I’m not sure what is up with the AA and after that, it’s all tabulated. I ended up running it through sed to remove the spaces, and using notepad to stitch the lines together. I guess I could have bash’d it some more but.. I’m impatient.

So yeah, it looks like it worked! Very amazing. And of course it’s crazy fast but that should be expected I suppose. I don’t like the hard coded table, but I just wanted to get it to generate an image.

Sadly, the author of the compiler, Weber seems to have disappeared, and the publisher Paul Haupt died in 1978, a year after this being published.

PCem ported to FreeBASIC

Yes, it’s that PCem. And yes BASIC.

From the post on the

Some time ago I raised a challenge: make a PC emulator 80486 in Basic !!!

To achieve this, I used a very old version of PCEM, with the help of “FreeBasic”, starting from PCEM-V4.1, about six months ago, I managed to make it work, in 80286 mode only. Then I went little by little adding functionalities of the following versions, until arriving at the V8 (not completely, but if great part). Due to the complexity and lack of speed in BASIC, I have only converted the modules that have interested me the most, eliminating many unnecessary ones, so I have managed to reach an 80486-DX2-66mhz with FPU, 16mb of RAM and VGA TSENG of 2mb.
I have removed many non-necessary modules, such as the sound (it does not have any sound), the LPT port, the PS2 port, the FDC unit and more.
It has many faults, but in general they work VERY well, and it is capable of running “WINDOWS 3.11”, “Deluxe Paint”, “Wolfstein 3D” and many other programs. 
It can reach a resolution of 800×600 to 16 colors, but it moves better in 640×480 16 colors.
The keyboard fails, all the keys do not work, and neither EMM386.EXE nor EXPANDED memory can be used, because it fails and becomes very slow.
It works in both protected mode and real mode, but when entering protected mode, the PC becomes slow.

It’s slow, but yes, it runs!

It only has one config hard coded, as jepalza ported enough of it for this one config. Oddly enough it’s my least favorite the ‘winbios’ 486.

I have to say this is pretty cool!

As always, here is my mirror (usual 404 page reading required) here: PCEM_FB486.rar

Booting a PC over serial port via ROM Basic!

Galaxian via Basic over the serial port

I was sent this link while out for vacation:

So this is great for machines that included the seemingly useless ‘casette basic’ as you could maybe shove over something to config the machine, maybe ‘rom dos’ directly into ram to fdisk/format without using disks… Interesting stuff to say the least!


Microsoft Game Studio

I’m on an extended work trip, so I’ve been unable to do much of anything blog like the last few weeks. But as a bonus I have about 6 months worth of random crap from Ebay packed up to take back to Hong Kong to review.

And yes, It’s nearly been a year in the making for this one, but rest assured unless the disks are un-readable this will happen!

Otherwise, the Diablo thing with the release to mobile only went over like a proverbial lead balloon.  Kind of gutsy to host a convention to die hard PC fans and try to keynote on a re-skinned rip off phone app, that’s just been accepted as now ‘official’.  Talk about outsourcing gone wrong.

UPDATE: sad news I have a piece of luggage MIA.  This may not be happening now. 

UPDATE2: Bag showed up, loaded the disks, and after 7% of disk one, my 5 1/4″ drive just died.


Microsoft XENIX 286 BASIC Compiler

(This is a guest post by Antoni Sawicki aka Tenox)

I have recently acquired this artifact:

It’s the Microsoft BASIC compiler for XENIX 286 Operating System. Compiler as opposed to just BASIC interpreter, it can produce executable a.out files, similar to C compiler for example.  

Carefully removed the shrink wrap. Inside were couple of 5.25″ floppies, registration card and a manual:

Interestingly the 32 year old disks read just fine on a first attempt. I need to start backing up important files to 5.25″ floppy disks as they seem to outlast everything else.

Thanks to efforts of Michal Necasek from OS/2 Museum now you can run Microsoft XENIX 286 in Virtual Box

The disks can be installed in to XENIX running on Vbox following a few simple steps:

tar xvf /dev/fd0
./msinstall /dev/fd0

Upon installation you invoke the compiler like this:

bascom demo.bas

And it produced an a.out executable which worked perfectly fine.

It’s fun to write BASIC code in vi editor, which I just realized I never done before.

Curiously the compiler also worked on the brand spanking new Xenix 2018, or rather I should call it Open Server 6, which you can download here.

The BASIC compiler is available for download from my archive along with the manual in pdf.

Building the Original Commodore 64 KERNAL Source

I just found this post over, the source code to a bunch of old Commodore 8 bit products have been located and recovered, and place online over on github.  Even better there is detailed instructions on cross assembling from a suitable PET machine for building your own KERNAL ROM.

Other sources include:

  • BASIC_C64 reindented BASIC_C64, KERNAL_C64 and DOS_1540 to approximate the LST
  • BASIC_CBM2_A reindented BASIC_CBM2_[AB], KERNAL_CBM2_[AB] and EDITOR_CBM2 to appro
  • BASIC_CBM2_B reindented BASIC_CBM2_[AB], KERNAL_CBM2_[AB] and EDITOR_CBM2 to appro
  • BASIC_PET2001 added BASIC_PET2001
  • DOS_1540 reindented BASIC_C64, KERNAL_C64 and DOS_1540 to approximate the LST
  • DOS_1571 added DOS_1571
  • DOS_1581 added DOS_1581
  • DOS_4040 reindented DOS_4040 to approximate the LST output of the assembler
  • DOS_8070 reindented DOS_8070 to approximate the LST output of the assembler
  • DOS_8250 reindented DOS_8250 to approximate the LST output of the assembler
  • DOS_D9065 reindented DOS_D9065 to approximate the LST output of the assembler
  • EDITOR_CBM2 reindented BASIC_CBM2_[AB], KERNAL_CBM2_[AB] and EDITOR_CBM2 to appro
  • KERNAL_C64_01 added KERNAL_C64_03 and renamed the existing KERNAL_C64 to KERNAL_C64_01
  • KERNAL_C64_03 fix disclaimer of C64 KERNAL -03 to reflect the LST printout
  • KERNAL_CBM2_A reindented BASIC_CBM2_[AB], KERNAL_CBM2_[AB] and EDITOR_CBM2 to appro
  • KERNAL_CBM2_B reindented BASIC_CBM2_[AB], KERNAL_CBM2_[AB] and EDITOR_CBM2 to appro

Super late, but pretty cool too!

Of interest is the PET2001 Basic sources.  While there have been reversed efforts dating back for years, this is the actual source code.  Namely the header.




Which is pretty damned interesting. The infamous “WAIT6502,1” feature is also included!

Commodore Lemonade

Simulations before the sims

Lemonade on the PET

Back before there was sim city, the first popular simulation thing I can think of on our ancient basic bound 8 bit machines (and even mainframes running basic!) was Lemonade.  Wikipedia, naturally is full of Apple citations, and of course, is absent of any mention of the most popular selling home computer of all time, as Commodore is usually scrubbed from history in favor of this narrative that Apple was some how popular (it wasn’t).

Oddly enough tracking down these older versions of Lemonade is really hard.  But thankfully others have done the hard work for me!

First from The Sleeping Elephant,  and here is lemonade!.prg for the Pet microcomputer.  It’ll run fine in Vice, although it’ll run best using a Pet 3016 – 3032 and the model 4016 and 4032.  It needs more than 8kb of RAM, so the original models are out, and the ‘graphcis’ don’t display corrrectly on the larger 8000 models, although the game does run.

But what about the Commodore 64?

Commodore Educational Software

By the time the Commodore 64 came out, Commodore had stepped upped their game, and made available a large number of basic programs ported to the Commodore 64. As always the thinking is if you can convince parents that this is educational and it’ll help their kids, they’ll buy one.  Well in this case they were right!  Although lacking the cool animation of the PET, it does include more documentation.  And thanks to, You can download a tape file image here.

Game Play

Unsurprisingly the game play is pretty much the same.  You buy your Lemon concentrate, sugar and cups, try to predict demand based on your price and the weather.  You set a price, and sit back and hope for the best.

Lemonade Stand on the PET

Lemonade Stand on the Commodore 64

Once you figured out that the first few lines (3-5 on the C64) were there to not let you alter it, you were golden.  With the source, you could make summer last 10 years if you wished, or change any of the seemingly arbitrary limits.  If you were really keen on it, you could also print the source code and work out the logic flow with a pencil, something that you really needed back in the days of 40 column screens.

Settings -> Virtual Device Traps

Settings -> Drive Settings -> (Uncheck) True drive emulation

Settings -> Peripheral Settings

And now you can click the printer #4 tab and set it to output a to a file

Assuming you have the program loaded you can then just type in:


*Remember that Vice emulates the Commodore layouts, which means on the PET machines, they use a number pad.

The above commands will open up the printer, print the listing output to the printer, then close the printer device.  If all went well you’ll have the source dumped to viceprnt.out although PETSCII won’t render on ASCII systems, nor will the machine language portion, and a lot of the BASIC may get down shifted but you can always fix that with tr.

tr ‘[:lower:]’ ‘[:upper:]’ < c64_lemonaide.bas > c64_lemonaide_upper.bas

BASIC language subset/dialect in C++

This one came to me from Peter, a set of C++ macros and define sets that implement a subset of BASIC.

YES, that is correct, BASIC.  It even has line number!  Let’s look at a simple hello world!

type hello.bas
#include “

BEGINBASIC(int,main,(int argc, char* argv[]))
10 PRINT “Hello, world!”;
20 GOTO 40;
30 PRINT “I am not printed”;
40 END;

It’s compiled with GCC like this:

c++ -pipe -xc++ -fpermissive -w -o hello.exe hello.bas

And then run it!

Hello, world!


From the docs in the main .cc file:

Implemented a BASIC language dialect/subset, with the following restrictions:

  •  All variables and statements must be allcaps
  • All lines must begin with a line number from 1 to 32767
  • All lines must have a trailing semicolon
  • One statement per line (except IF-THEN)
  • “THEN” must NOT be followed by a “GOTO” nor “GOSUB”!
    • Implemented keywords:
    • IF <C-style expression with “==” in case of equality> THEN <label>
    • GOTO <label>
    • GOSUB <label> / RETURN
    • STOP [optional errorlevel/return value]
    • END [optional errorlevel/return value]
    • LET <variable>=<expression>
    • PRINT <strings and/or variables in arbitrary order>
    • INPUT <one or more variables>
    • DIM <array variables with number of elements, p.ex. “NP(42)”>
    • FOR/NEXT loop (NEXT’s argument is mandatory, exactly one variable)
    • PRINT interprets comma as semicolon, except on the ENDS
      • thus PRINT does NOT interpret comma as tab injection
        basically, PRINT is some kind of writeln()
        but can be tricked: if CHR$(0) is inserted somewhere, it won’t print
        the remaining part including the trailing newline!
        variables are all float types, predeclared, and their names at most 2 chars long
    • (numerical) arrays can be used, must be declared before their first usage
    • Array numberings: DIM A(8) means that A(0) till A(7) are declared this way

So it’s not 100%, there is no strings, not even a REM (conver to C++ comments) so it’ll be a while until you can build more traditional basic programs.

Simple Mandelbrot set in BASIC

I used “mingw-i686-7.1.0-win32-dwarf-rt_v5-rev0” to test this on Windows.

You can download ptsvubas from it’s site here:

Usborne collection of 1980’s computer books!


Back in the 1980’s home computers were a new and exciting thing, and with these machines came very technical manuals.  But us young children wanted to program, and thankfully companies like Usborne filled the gap by providing programming books geared towards kids!  It was a golden age as every machine had a basic interpreter.  Then for some reason software companies (Microsoft/IBM) didn’t think it was a good thing anymore bundling in languages with their OS’s, or worse thinking that development tools should be a source of revenue and pricing amateurs out of the market (seriously SCO, $5000 for a C compiler?)  But now thanks to the common carrier network we all have (the internet) the rise of open and free software hackers have taken things into their hands, and we are back to empowering users.

So I thought it was interesting that Usborne opened up a bunch of it’s older books.  All available in PDF, free for personal use.

First computer library

Introductions to programming


Adventure games

You can see their page with full details here.


CBM Basic

I found this repository by accident, cbmbasic which is a ‘portable’ version of the old Microsoft Basic for the Commodore 8bit computers in C which can run on any manner of machine.

Really cool, right?

So for the heck of it, I fired up the x68000 toolchain, and in no time after gutting the file open operation as some stuff isn’t defined, and I wanted to see it run, I had a working executable.


CBM Basic

All the commands MUST BE IN UPPERCASE… Then again the Commodore did default to upper case, so I guess that isn’t a surprise.  There is no ‘system’ command to take you out of basic, but Control-C works just the same.

The other intersting thing, is that on the authors blog,, the original source code for the 6502 basic has been found.  Notably this version includes portions written by Bill Gates.  It is a very fascinating read.