GCC IA-16 toolchain (tkchia)

Last modified: Thu Jun 11 13:30:22 EDT 2020

These are DWF's installation notes on the GCC IA-16 toolchain.  As the present maintainer tkchia describes it, this is a port of the GNU C and C++ compiler toolchain to the IA-16 target (16-bit Intel x86).  The toolchain itself is 32-bit (DJGPP DOS-hosted) or 64-bit (Linux-hosted), but it outputs 16-bit code.

DOS host

These notes pertain to the FreeDOS packages (supplied zip files) for the release dated 2020-03-21.

Gotchas

  1. Only C is supported, not C++.
  2. The version of GCC is 6.3.0 (released 2016-12-21).
  3. The included standard library is not GNU libc but rather Newlib, "a C library intended for use on embedded systems," version 2.4.0 (released 2016-03-29).
  4. The zip files were built with truncated (8.3) file names, so Long Filename (LFN) support must be disabled to avoid compilation failures.  E.g., _newlib_version.h: No such file or directory, because it was zipped as _NEWLIB_.H.
  5. The IA-16 toolchain requires some pieces from DJGPP.

Files

From https://github.com/tkchia/build-ia16/releases:

  660563 i16budoc.zip
 8504576 i16butil.zip
 9401263 i16gcc.zip
 1318085 i16gcdoc.zip
12448239 i16newli.zip

From ftp://ftp.delorie.com/pub/djgpp/current/v2/:

 2509574 djdev205.zip

From ftp://ftp.delorie.com/pub/djgpp/current/v2misc/:

   71339 csdpmi7b.zip

VM and DOS environment

Start with the "basic DOS configuration" documented in QEMU config for running DOS compilers, but modify AUTOEXEC.BAT to remove LFN support and add lines for both DJGPP and the IA-16 toolchain.  Delete the line with DOSLFNMS.COM.

SET DIRCMD=/A /P /O
SET PATH=C:\GCC-I16\DEVEL\I16GNU\BIN;C:\DJGPP\BIN;C:\LOCAL\BIN
SET DJGPP=C:\DJGPP\DJGPP.ENV
SET TZ=:America/New_York
SET TMPDIR=D:

Compiler installation

Mount the C: drive from Linux:  (The LFN stuff is extra in this case.)

mount -t vfat -o uid=1000,gid=100,shortname=winnt,loop,offset=32256 C.img /mnt

Install the DJGPP bits in /mnt/DJGPP:

mkdir /mnt/DJGPP; cd /mnt/DJGPP; unzip .../djdev205.zip; unzip .../csdpmi7b.zip

Optionally, move the DPMI swap file to the scratch drive as described for DJGPP.

Install the I16 zips in /mnt/GCC-I16:  (Info-ZIP UnZip 6.00 (2009-04-20) cannot unpack tkchia's zip files; use 7za instead.)

mkdir /mnt/GCC-I16; cd /mnt/GCC-I16; for f in .../*.zip; do 7za x "$f"; done

Test

C:\TMP>i16gcc -Os -o hello.com hello.c
C:\TMP>dir
HELLO    C             110  03-28-20  3:56p
HELLO    COM         6,550  03-28-20  8:12p
C:\TMP>hello
Good morning, thou cruel world

bash-4.3$ file HELLO.COM 
HELLO.COM: COM executable for DOS

Linux host

These notes pertain to the statically linked ELF binaries for the release dated 2020-04-10.

Differences from DOS-hosted version

  1. C++ is supported.
  2. The 8.3 file name issue goes away.
  3. Elks libc is supported as an alternative to Newlib, but probably only when the target OS is Elks.

Files

From https://github.com/tkchia/build-ia16/releases:

21744004 gcc-ia16-elf-static_6.3.0-20200307.16-ppa200410115.xenial_amd64.tar.xz
 2936276 binutils-ia16-elf-static_2.32.0-20190928.13-ppa200409161.xenial_amd64.tar.xz
 1918136 libnewlib-ia16-elf_2.4.0-20200215-stage1gcc6.3.0-20200307.16-binutils2.32.0-20190928.13-ppa200320163.xenial_amd64.tar.xz

Compiler installation

Although the file names reference Ubuntu 16.04 LTS (Xenial Xerus), the static binaries worked fine on Slackware64 14.2.  Unpacked in the root directory, the tarballs drop files in /usr/bin, /usr/ia16-elf, /usr/lib/x86_64-linux-gnu/gcc/ia16-elf/6.3.0, and miscellaneous directories under /usr/share.  Included man pages document the IA16-specific compiler options.

Test

hello.cc is this:

#include <iostream>
int main (int argc, char **argv) {
  std::cout << "Good morning, thou cruel world\n";
  return 0;
}

Try 1 to build hello.cc:

$ ia16-elf-g++ -Os -s -o hello hello.cc
/usr/lib/x86_64-linux-gnu/gcc/ia16-elf/6.3.0/../../../../../ia16-elf/bin/ld: Error: too large for a .com file.

Try 2:

$ ia16-elf-g++ -mcmodel=small -Os -s -o hello hello.cc
/usr/lib/x86_64-linux-gnu/gcc/ia16-elf/6.3.0/../../../../../ia16-elf/bin/ld: hello section `.text' will not fit in region `csegvma'
/usr/lib/x86_64-linux-gnu/gcc/ia16-elf/6.3.0/../../../../../ia16-elf/bin/ld: Error: too large for a small-model .exe file.
/usr/lib/x86_64-linux-gnu/gcc/ia16-elf/6.3.0/../../../../../ia16-elf/bin/ld: region `csegvma' overflowed by 67872 bytes

Try 3:

$ ia16-elf-g++ -mcmodel=medium -Os -s -o hello hello.cc
ia16-elf-g++: error: medium model not supported for C++

Fail on C++.  Falling back to C.

$ ia16-elf-gcc -Os -s -o hello hello.c

-rwxr-xr-x  1 dave users    6550 Jun 10 10:53 hello

$ file hello
hello: COM executable for DOS
C:\>dir

HELLO    COM         6,550  06-10-20 10:53a

C:\>hello
Good morning, thou cruel world

KB
Home