Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

32-bit C compiler targetting 16-bit 8086

631 views
Skip to first unread message

Paul Edwards

unread,
Nov 26, 2014, 1:03:06 AM11/26/14
to
Hi all. What 32-bit C compilers exist that can produce
a 16-bit real mode 8086 executable?

Is Open Watcom the one and only?

The problem I have is that PDOS/16 is pretty crappy
and will only handle small programs, so I can't run
Turbo C++.

PDOS/32 has access to plenty of memory.

Thanks. Paul.

Alexei A. Frounze

unread,
Nov 26, 2014, 2:04:29 AM11/26/14
to
My Smaller C can create real-mode programs, but it requires at least an i80386.

It comes with a bunch of limitations (language/library-wise) and produces rather crappy (big and slow) "16-bit" code in the huge memory model (but in this model it frees you from dealing with far pointers as all pointers are 32-bit physical addresses (the top 12 bits must be 0, though), and size_t is 32-bit too).

The tiny and small memory models are more performant but everything is 16-bit in them (so, no long type) and you said you wanted larger programs anyway, so they probably aren't for you.

The DOS binaries of my compiler are compiled with the compiler itself, so a ~200K executable isn't a problem.

I haven't considered a 32-bit DPMI version, but it should be much faster than what you get in the huge memory model. The 32-bit version for Windows is noticeably faster since it doesn't need to deal with segmentation under covers. Yes, as of now, Smaller C targets both DOS and Windows.

Anyway, if you're interested and haven't tried it yet, check it out:
https://github.com/alexfru/SmallerC (source/binaries/libraries)
https://github.com/alexfru/SmallerC/wiki/Smaller-C-Compiler-Driver-Wiki (docs)

I believe, I have all the documentation mostly up to date with the exception of the standard library. That part is still to be documented. But you will be able to see what's supported from the library header files.

Alex

Alexei A. Frounze

unread,
Nov 26, 2014, 2:53:07 AM11/26/14
to
On Tuesday, November 25, 2014 10:03:06 PM UTC-8, Paul Edwards wrote:
On a second thought, I may have misunderstood you.

Do you need a small DOS compiler that can run in real mode in whatever few kilobytes (400-500?) of "conventional" memory left after loading PDOS/16?

Alex

Paul Edwards

unread,
Nov 26, 2014, 3:30:48 AM11/26/14
to
On Wednesday, November 26, 2014 6:53:07 PM UTC+11, Alexei A. Frounze wrote:

> My Smaller C can create real-mode programs,
> but it requires at least an i80386.

I want the real-mode programs to only require an 8086,
so that I can generate the PDOS/16 binaries.

> It comes with a bunch of limitations (language/library-wise)

I want the C90 language. I expect to be providing
my own library.

> and produces rather crappy (big and slow) "16-bit"
> code in the huge memory model (but in this model it
> frees you from dealing with far pointers as all
> pointers are 32-bit physical addresses (the top
> 12 bits must be 0, though), and size_t is 32-bit too).

I'd like to maintain compatibility with TC++, so
a normal 16-bit version in large memory model for
the operating system and tiny memory model for
the loader.

> The tiny and small memory models are more
> performant but everything is 16-bit in them
> (so, no long type)

My tiny memory model loader uses "long".

> and you said you wanted larger programs anyway,
> so they probably aren't for you.

I don't think this is suitable for my use.

> On a second thought, I may have misunderstood you.
>
> Do you need a small DOS compiler that can run in
> real mode in whatever few kilobytes (400-500?)
> of "conventional" memory left after loading PDOS/16?

That would be nice, but I don't think that is
possible with PDOS/16 so I intend to abandon
PDOS/16 as a development environment and stick
with PDOS/32 to target both PDOS/32 and PDOS/16.

I believe Open Watcom has similarly abandoned
16-bit MSDOS as a development environment.

BFN. Paul.

Rod Pemberton

unread,
Nov 26, 2014, 8:23:18 PM11/26/14
to
On Wed, 26 Nov 2014 03:30:47 -0500, Paul Edwards <kerr...@w3.to> wrote:

> On Wednesday, November 26, 2014 6:53:07 PM UTC+11, Alexei A. Frounze
> wrote:

[earlier]
> What 32-bit C compilers exist that can produce
> a 16-bit real mode 8086 executable?
> Is Open Watcom the one and only?
>
[currently]
> I believe Open Watcom has similarly abandoned
> 16-bit MSDOS as a development environment.

An 8086 executable? Yeah, I'm not sure.

A 16-bit DOS executable? There are a few,
mostly obsolete now, and some hard to find.


Searching for 16-bit DOS C compilers ...

Turbo C - Yes.
Borland C - Yes.
OpenWatcom - Yes.
Digital Mars - Yes.
Microsoft - Yes.
Pacific C - Yes.
Desmet C - Yes.
DJGPP - Yes. (see notes)
LCC - Yes.
BCC - Yes.
PCC - Yes.
Miracle C - ???
LCC-Win32 - No.
Pelles C - No.
DiceRTE - No.
Ladsoft CC386 - No.
Ladsoft Orange - No.
MinGW - No.
Cygwin - No.


Notes:

DJGPP's 16-bit capabilities are very rudimentary.
It's not available as part of the normal install.

OpenWatcom supported DOS as of version 1.3 and
their homepage says version 1.9 supports DOS (2010),
which is supposedly the lastest version. It's 2014,
not 2010. So, I don't know if their webpage is old
or what. If the latest version doesn't support DOS,
then try to get an older version. Version 1.3 definately
supports 16-bit DOS. It works well for me for 16-bit
code, but I haven't tried to target the 8086. The
CGUIDE.IHP for version 1.3 says it supports 8086,
80186, 80286, 80386, 80486, Pentium, and Pentium Pro.

Digital Mars claims their C compilers still support
a variety of 16-bit DOS targets, much like OpenWatcom.
I haven't used their compilers, but they should be
as good as OpenWatcom or even better.

Microsoft released a variety, but are now hard to
find. Visual C++ 1.52b, or perhaps 1.52c, was the
last 16-bit DOS version.

Pacific C was released or open licensed for the
Freedos project (16-bit).

LCC release versions 3.5 and 3.6 which supported
16-bit DOS, but they rapidly converted to only
32-bit with versions 4.1 and 4.2. IIRC, the Borland
C compiler, or perhaps Turbo C, is needed to build
the DOS versions too.

BCC (Bruce's C Compiler, not Borland C++ Compiler)
is supposed to produce 16-bit code for 8086. At
least one person on alt.os.development mentioned
using this compiler for 16-bit code. This seems
to be available for Linux hosts. I'm not sure
about DOS.

PCC - Apparently, there were some 16-bit ports of
PCC for 8086 and 80286. I couldn't find out if
these are for DOS.

Miracle C - Many sites say Miracle C is 16-bit, but
I can only find a website for a Windows version.
So, there might've been 16-bit versions.


Obviously, I didn't post links this time. Let me
know if you can't find something, except M$ product.


Rod Pemberton

Paul Edwards

unread,
Nov 26, 2014, 9:32:02 PM11/26/14
to
On Thursday, November 27, 2014 12:23:18 PM UTC+11, Rod Pemberton wrote:

> Searching for 16-bit DOS C compilers ...
>
> Turbo C - Yes.
> Borland C - Yes.
> OpenWatcom - Yes.
> Digital Mars - Yes.
> Microsoft - Yes.
> Pacific C - Yes.
> Desmet C - Yes.
> DJGPP - Yes. (see notes)
> LCC - Yes.
> BCC - Yes.
> PCC - Yes.
> Miracle C - ???
> LCC-Win32 - No.
> Pelles C - No.
> DiceRTE - No.
> Ladsoft CC386 - No.
> Ladsoft Orange - No.
> MinGW - No.
> Cygwin - No.

Hi Rod. Thanks for your reply. But I am not after
16-bit compilers. I'm after 32-bit compilers that
can produce 16-bit x86 code.

In addition (sorry, just remembered) I will need
them to be open source as well, since I need to
compile them using EMX 0.9d to produce an a.out
file that PDOS/32 can handle.

So could you tell me what my choices are within
these constraints?

I believe Open Watcom fits these constraints. Is
that the only one?

Thanks. Paul.
0 new messages