32016 stand alone planetfall!

InfoTaskForce’87 running on a simple NS32016 emulator

What is it?

It sure may not look like much but it was an adventure getting here.

First, what is it? Well it’s the very simple NS32016 from here, with a few minor changes. I expanded the RAM from 256kb to a whopping 8MB. Then I added simple character I/O allowing me to print messages to the screen. Next looking at the toolchain page, I used my old Linux to Windows GCC 4 cross compiler to build the appropriate Canadian cross compiler to the NS3216.

Building the tools

A while back, I had built a cross compiler from Linux to Windows using GCC 4.1 as the basis as it was the last version that didn’t have massive external dependencies. NS32016 support was dropped some time in the late 3.x or early 4.x GCC so it means we need to go old anyways. I arbitrary picked GCC 2.8.1 for this build, while using the recommended Binutils 2.27

I cheated and just downloaded my existing linux-minw32.7z cross compiler as I didn’t feel like rebuilding everything again, although it is all in the Building a MIPS Compiler for Windows on a Linux VM! article. I also used an old Linux to Linux i586 32bit compiler (back from the OSKit build!) although you can use your hosts as well.

configuring Binutils is pretty simple like this:

./configure --prefix=/cross --target=ns32k-pc532-netbsd --host=i686-mingw32 --build=i586-linux

You can try omitting the –build portion, Debian GNU Linux 10 seemed okay with Gcc 8 as the default system compiler.

configuring GCC 2.8.1 was pretty similar:

./configure --target=ns32k-pc532-netbsd --prefix=/cross --disable-libssp --build=i586-linux --host=i686-mingw32

GCC 2.8.1 doesn’t quite know what we are doing so there is some flags we need to run off in auto-config.h namely

  • #define HAVE_BCMP 1
  • #define HAVE_BCOPY 1
  • #define HAVE_BZERO 1
  • #define HAVE_INDEX 1
  • #define HAVE_KILL 1
  • #define HAVE_RINDEX 1
  • #define HAVE_SYS_RESOURCE_H 1
  • #define HAVE_SYS_TIMES_H 1

You can just comment them out, or remove those lines all together.

When it came to building GCC, I did run into issues with GCC 7/8 trying to build GCC 2.8.1. I found it much easier to either have that Linux 4.1 compiler, or if you have access to Wine or WSL you can just run the Win32 binaries for the gen phases.

./configure --prefix=/cross --target=ns32k-pc532-netbsd --host=i686-mingw32
make CC=i686-mingw32-gcc xgcc cccp cc1 cc1obj

If you can run your own Win32 exe’s on Linux it’ll run just fine using the Linux to Windows GCC 4 cross. Otherwise you will need to either patch GCC or make your own GCC 4 hosted Linux to Linux cross compiler like this:

make CC=i686-mingw32-gcc HOST_CC=i586-linux-gcc xgcc cccp cc1 cc1obj

Hopefully that worked enough, and now you have your cross compiler. Now it’s time to build libgcc1.a

cp cccp cpp.exe
cp cc1 cc1.exe
cp xgcc xgcc.exe
cp ../binutils-2.27/gas/.libs/as-new.exe as.exe
cp ../binutils-2.27/binutils/.libs/ar.exe ar
cp ../binutils-2.27/binutils/.libs/ranlib.exe ranlib
make libgcc1.a TARGET_TOOLPREFIX="./" OLDCC=./xgcc.exe

Again you really want to be able to run the resulting programs on Linux but I guess you could script it out. Naturally if you wanted to just use Linux, it’d be easier to make that cross compiler directly, although I’m not sure how much of GCC 2.8.1 I want to fight, or just get GCC 4 running on Linux and use that to port.

crt0, somewhere for C to start

As mentioned a crt0.s is missing but there was enough inspiration to come up with this:

        .align 1
.globl _start
        enter [],0
#       setting the stack 256k under 8MB
        lprd sp,0x7c0000
        jsr _main
        exit []
#       setting the stack 256k under 8MB
        lprd sp,0x7c0000
        .align 1

#does nothing
.globl ___main
        ret 0

.globl _exit
        ret 0

I used a bit of the C example, and added some hooks that GCC was expecting namely a __main call that is made from main before it does anything (a place to init memory perhaps?), a place to catch an explicit exit call, along with setting the stack of course.

Patching InfoTaskForce without malloc / disk access

It’s not going to win any awards, but it was really great to get it to run a simple program written in GCC. Looking for something more fun, I took the old InfoTaskForce interpreter from ’87, and dug up my modification to run on cisco routers, and cooked up this version, that adds enough of printf from Linux, a bogus malloc that just allocates from a fixed memory array (otherwise you have to actually know about your platform), and a fun trick with later binutils where you can import a binary file directly as an object!


Since I don’t have any file I/O being able to have the game data in RAM is crucial. I tried to tweak it so you could build the same working thing on Windows (maybe others?).

So for anyone who wants to look at the standalone adventure Win32 hosted tools are here, although the emulator should be somewhat portable.

Quick and dirty i8080 emulator in BASH!

Based on the Toledo 8080 processor emulator, it’s Peter Naszvadi’s i8080.sh!

You will need bash version 4 for this to run. So for those of you in the 1990’s you are out of luck.

And to make this fun, the 2kb basic ‘ROM’ is bootstrapped into RAM for immediate execution!

$ ./8080.sh
Quick and dirty i8080 emulator by NASZVADI Peter, 2019.
Press Ctrl+C to quit anytime!
Initializing upper memory to NOPs
Initializing register values
Starting CPU emulation



So we’ve seen emulation in javascript of all things, but now you can run 8080 instructions from bash of all things!

And for anyone even more crazy there is always BDS C: which was opened up back in 2002, a K&R for the 8080 on CP/M!

Messing with the Monitor

The 68000 Microprocessor (5th Edition) Hardcover – Nov 25 2003
by James L. Antonakos (Author)

So I was trapped in the Library for a bit, and spied this book. It’s not every often in 2019 you are going to find books about the 68000, as I’m sure any good library will have removed stuff like this, and have it pulped ages ago. But the amount of current technical books in English here is pretty damned slim to none, so I was all to happy to pickup this book for a week.

The poor thing has been checked out 4 times in the last 15 years. I guess the kids don’t know what they are missing.

Anyways what was interesting in this book is that it has a CD-ROM, and on there is some lesson code from the book, along with an assembler that outputs to S-records of all things, and a small emulator that is meant to be compiled under MS-DOS. It was trivial to isolate the passing of DOS interrupts from Unix/MinGW and get the simulator running on something modern.

In Chapter 11 there is a brief walkthrough on building a board, which sounds like fun although I’m sure in 2019 finding parts will be.. challenging, along with a simple monitor program.

The built in assembler can happily assemble the monitor, but it’s geared for talking to the obsolete hardware as specified in the book. I just made a few small changes to instead have it’s console IO hook to the simulator’s TRAPs and I had the monitor running!

I then took the echo test program, and modified it to run at a higher location in memory, along with exiting via the RTS instruction, so that it will exit when you press Q back to the monitor. Then for the heck of it I further extended the monitor so you can Quit it, and return to the simulator.

Is this useful? I’m pretty sure the answer is absolutely not.

The CD-ROM is tiny, I thought it would be packed with goodies, but it’s 250kb compressed.


If anything people using this book will probably have lost the CD-ROM and want the programs.

  • ISBN-10: 0130195618

And my horrible changes here.

Wasting some cycles on FrontVM


A while ago I had chased FrontVM to moretom.net and found 2 links. One from 2003 which is a dead link, and the 2004 version which was archived by the wayback machine!

It was an interesting build, as it still used 68000 emulation from Hatari/UAE this pre-dates the 68000 to C or i386 ASM. However since it ran (mostly) the original code, it was more ‘feature complete’, although loading save games is broken for some reason (I think the decryption was not disassembled correctly). It was actually a stupid file mode setting. I just updated the source & put out a new binary, testing save games between Linux &Windows.

Anyways, it originally built on Cygwin, so I filled in the missing bits, and have it building on both MinGW & Visual C++

Parked outside Willow in the Ross 154 system

So yeah, it’s Frontier, for the AtariST with the OS & Hardware calls abstracted, still running the 68000 code under emulation. I think it’s an interesting thing, but that’s me.

I put it and the other original versions I found over on sourceforge.net

Download Frontvm

Oddly enough it’s already been downloaded, so go figure.

MASM386 & why you shouldn’t do this

I found myself unable to sleep and went looking at the masm386.c in the old GCC 1.2 line of code to discover what everyone had figured out at the time, that it was interesting to include it, but it didn’t do anything at all as it was never called in GCC.

So for some other reason I thought it’d be fun to mess with MASM386 the assembler that was in the original NT pre-releases up to the 3.1 DDK (maybe later, I dont’ have the 3.5 SDK/DDK on hand).

D:\temp\i>type hi.c
void main(){printf("hi!\\n");}

D:\temp\i>cl /c /G3 /Gd /Fahi.asm hi.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 8.00
Copyright (c) Microsoft Corp 1984-1993. All rights reserved.


D:\temp\i>masm386 /Ml hi.asm hi.obj nul.lst nul.crf
Microsoft (R) Macro Assembler Version 5.NT.02
Copyright (C) Microsoft Corp 1981, 1989.  All rights reserved.

      0 Warning Errors
      0 Severe  Errors

D:\temp\i>link hi.obj -debug:none -out:hi.exe /SUBSYSTEM:CONSOLE -defaultlib:LIBC -defaultlib:OLDNAMES
Microsoft (R) 32-Bit Executable Linker Version 1.00
Copyright (C) Microsoft Corp 1992-93. All rights reserved.


Yes this was a total waste of time.  Some things work, while other files explode for seemingly no apparent reason.

Windows NT 3.1 Pre-Release from October 1991

What is interesting is that it’s the same reported version from the 1991 pre-release.

With of course it making an appearance on the Microsoft OS/2 2.00 betas & SDK.

OS/2 2.0 build 123

The only thing more insane to waste time on is converting a.out to OMF…

Impuse Tracker open sourced

I’ve never been musically inclined, but for those who loved the whole tracker scene of 20 years ago, Jeffrey Lim has released the source code to Impulse Tracker!  It features an impressive sound card support list:

  • Sound Blaster
  • Sound Blaster Pro
  • Sound Blaster 16
  • Sound Blaster AWE 32
  • Terratec EWS64
  • Hoontech Soundtrack 97 PCI
  • Gravis UltraSound, PnP, Max
  • Pro Audio Spectrum
  • Pro Audio Spectrum 16
  • Interwave
  • PC Speaker
  • DAC on LPT

It’s all in assembly and can be built with Turbo Assembler 4.1

You can find the source code on bitbucket here. Github mirror!

easy68k & sozobon


I know this is a little weird to follow, but I thought it was somewhat interesting. Anyways I’ve been reading up on some CP/M stuff, and found some interesting m68k stuff. There is this really cool m68k simulator/test environment called easy68k. Ok so the 68000 isn’t exactly the hottest chip, but for anyone that’s used a Mac, Amiga, Atari ST, SEGA Genesis, or old SUN the m68000 was the end all be all CPU. Anyways you can download the easy68k simulator from here:


Now I’ve never been really all that good with assembly. I know one day I should learn, but until then, there is higher level languages, and of course the best ‘medium’ level language C. Back in the day the ‘sozobon’ compiler was somewhat portable, and a good & easy 16 bit C compiler. Now as far as I know there really hasn’t been any activity on this since 1991, so it’s getting hard to find, and of course the archived copies I found needed LZH.. You can find some archived copies here:


Since I didn’t want to go thru a big ordeal, I found an extracted copy of the sources here:


Building the sozobon compiler

Using wget I pulled down the source code. It’s worth noting that unlike GCC this is SMALL… although it only targets the 68000 cpu. The only source that I’m using is the actual C compiler. I suppose if I were better I could map the simulator, and setup the assembler & linker to target the environment all the way… However for now I’m just interested in showing the relationship between a compiler, to the assembler. Now the source is old enough that it uses the reserved word inline in gunk.c I simply changed it to Xinline. I’ve attached a diff for those who like diff’s however as you can see it’s really simple, I just renamed them, so they don’t conflict.

--- gunk.c Fri Feb 22 05:33:34 1991
+++ gunk-fix.c Mon Mar 9 14:35:33 2009
@@ -37,7 +37,7 @@
int (rewri)(); / rewrite function */

-int m_unfold(), unfold(), m_cast(), cast(), m_inline(), inline();
+int m_unfold(), unfold(), m_cast(), cast(), m_inline(), Xinline();
int m_hardas(), hardas(), m_fcmp(), fcmp(), m_md_shf(), md_shf();
int m_eident(), eident(), m_incdec(), incdec(), m_fldas(), fldas();

@@ -48,7 +48,7 @@
{m_eident, eident},
{m_incdec, incdec},
{m_hardas, hardas},
- {m_inline, inline}, /* must cast before inline /
+ {m_inline, Xinline}, /
must cast before inline */
{m_fcmp, fcmp},
{m_fldas, fldas},
@@ -424,7 +424,7 @@
return 0;

register NODEP nmp, cmap;
@@ -782,7 +782,7 @@
register NODEP tp;

spar1 = "%fpcmp";
- inline(np);
+ Xinline(np);

tp = copyone(np);
tp->n_left = np->n_left;

Now with that out of the way, you should be able to build with the make.unx

% make -f make.unx
gcc -DUNIX -O -c d2.c
gcc -DUNIX -O -c decl.c
gcc -DUNIX -O -c expr.c
gcc -DUNIX -O -c fix.c
gcc -DUNIX -O -c fun.c
gcc -DUNIX -O -c g2.c
gcc -DUNIX -O -c gen.c
gcc -DUNIX -O -c gsub.c
gcc -DUNIX -O -c gunk.c
gcc -DUNIX -O -c main.c
main.c:424: warning: 'optnl' was declared implicitly 'extern' and later 'static'
main.c:417: warning: previous declaration of 'optnl'
gcc -DUNIX -O -c md.c
gcc -DUNIX -O -c nodes.c
gcc -DUNIX -O -c out_st.c
gcc -DUNIX -O -c p2.c
gcc -DUNIX -O -c pre.c
gcc -DUNIX -O -c tok.c
gcc -DUNIX -O -c subs_c.c
gcc -o xhcc d2.o decl.o expr.o fix.o fun.o g2.o gen.o gsub.o gunk.o main.o md.o nodes.o out_st.o p2.o pre.o tok.o subs_c.o

Writing hello world!

OK, with the compiler built, let’s write a simple C program. I’ve setup a simple main, and calls to a ‘putc’ and an ‘exit’ that currently don’t do anything. We will have to fix that in the assembly source.. but for now it’s nice as it sets up a place holder.

char MESSAGE[]="this is a message";
void putc(c)
char *c;

void exit()

void main()
int j;

Now we can compile the source file (x.c) and use the -S flag, so it only outputs an assembly source, that we can then massage to work with easy68k.

% ./xhcc -S x.c ; cat x.s
.globl _MESSAGE
.dc.b $74,$68,$69,$73,$20,$69,$73,$20,$61,$20,$6d
.dc.b $65,$73,$73,$61,$67,$65
.dc.b 0
.globl _putc
bra L1
;var 4 8 _c
unlk a6
link a6,#-0
bra L0
.globl _exit
bra L4
unlk a6
link a6,#-0
bra L3
.globl _main
bra L7
;var 2 -2 _j
clr.w -2(a6)
move.l #_MESSAGE,-(sp)
jsr _putc
add.w #4,sp
jsr _exit
unlk a6
link a6,#-2
bra L6

As you can see from the source below the following changes were made:

-Added the ORG $1000
-Changed the formatting of the _MESSAGE into a format that easy68k’s assembler likes.
-Removed all the .globl statements.
-Renamed the _main section to START & and add the end start tags.
-Populated the exit procedure with the ‘exit’ code from easy68k’s example
-Changed putc to use the d0 register instead of d6, and added the print string code from easy68k.

ORG $1000

_MESSAGE dc.b $74,$68,$69,$73,$20,$69,$73,$20,$61,$20,$6d
dc.b $65,$73,$73,$61,$67,$65
dc.b 0

bra L1
;var 4 8 _c
move.b #14,d0
trap #15

unlk a0
link a0,#-0
bra L0

bra L4
unlk a6
move.b #9,d0
trap #15
link a6,#-0
bra L3

bra L7
;var 2 -2 _j
clr.w -2(a6)
move.l #_MESSAGE,-(sp)
jsr _putc
add.w #4,sp
jsr _exit
unlk a6
link a6,#-2
bra L6
end start


Now you can run the code in the simulator, and watch it enter the ‘start’ section, call the putc with the address of _MESSAGE, return to the main, and then call the _exit procedure, which calls the sim68k exit program interrupt. I’ll leave this as an exercise to the read for any real value…. I just thought it was cool, that without really learning any assembly I was able to write a basic ‘hello world’ type program in an hour….


Frontier Elite


While on the topic of Frontier Elite this week, I was wondering if they by any chance ever released the source code… It appears not, however there were largely two versions the original being in 68000 assembly then a port to 80286 real mode ASM.
But then I found this:
Tom Morton has taken the Atari ST version of Frontier, and removed the hardware access from the assembly, then tweaked a m68k assembler to either output in C or i386 asm… So he’s basically reversed a copy of Frontier to allow it to run natively!
And he’s added OpenGL support to some degree! It’s VERY cool!
At a minimum I bet there are people out there that would LOVE this guys programs to convert m68k assembly listings into either C or i386 asm. Or a chance to hack the ‘source’ like crazy.
I’ve also come across this great site http://www.jongware.com/galaxy1.html which goes over various algorithms from the game.