Compiling C to 16bit 8086 binaries with MS C Compiler 3.0


The Microsoft C compiler 3.0 generates 8086 binaries which can be useful if you want to target an older 16bit architecture x86 machine. This compiler can be used in Dosbox and/or Windows 98 to test the output.

The is the standard folder setup I use

Directory of C:\.
.              <DIR>            08-01-2017 18:51
..             <DIR>            08-01-2017 17:50
BIN            <DIR>            08-01-2017 17:18
INCLUDE        <DIR>            08-01-2017 17:17
LIB            <DIR>            08-01-2017 17:19
SRC            <DIR>            08-01-2017 17:38
    0 File(s)                 0 Bytes.
    6 Dir(s)        262,111,744 Bytes free.

These are the commands that I use to set the environment variables for compilation.

set PATH=%PATH%;C:\bin
set include=C:\INCLUDE
set LIB=C:\LIB

Here is a simple helloworld listing to get yopu started
hello.c

#include <stdio.h>

int main(){
  printf("Hello\n");

  return 0;
}

This the compilation command and sample output

C:\SRC>cl HELLO.C /G0
Microsoft 8086 Object Linker
Version 3.01 (C) Copyright Microsoft Corp 1983, 1984, 1985
HELLO.C

Object Modules [.OBJ]: HELLO.OBJ 
Run File [HELLO.EXE]: HELLO.EXE/NOI
List File [NUL.MAP]: NUL
Libraries [.LIB]: ;

C:\SRC>HELLO.EXE
Hello

C:\SRC>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s