Public | Automated Build

Last pushed: a year ago
Short Description
Cross-compiler for DOS applications
Full Description

DJGPP Docker image

OpenSUSE 42.1 +
DJGPP v2.05 +
GCC 6.1.0

docker pull anibali/djgpp

  • Cross-compile DOS applications written in C
  • Includes DJGPP's libc implementation

Usage

Compiling an application with libc

hello.c

#include <stdio.h>

int main() {
  printf("Hello world, with libc!\n");
}

Compile and link

docker run --rm -it --volume=$PWD:/workspace djgpp \
  gcc -o hello.exe hello.c

Run (requires dosemu)

curl -OJ http://www.delorie.com/pub/djgpp/current/v2misc/csdpmi7b.zip
unzip -p csdpmi7b.zip bin/CWSDPMI.EXE > CWSDPMI.EXE
dosemu -dumb hello.exe

Compiling a bare application

This is based on the excellent blog post
"How to build DOS COM files with GCC".

hello.c

asm (".code16gcc\n"
     "call  _dosmain\n"
     "mov   $0x4C,%ah\n"
     "int   $0x21\n");

static void print(char *string) {
  asm volatile ("mov   $0x09, %%ah\n"
                "int   $0x21\n"
                : /* no output */
                : "d"(string)
                : "ah");
}

int dosmain(void) {
  print("Hello world!\n$");
  return 0;
}

com.ld

OUTPUT_FORMAT(binary)
SECTIONS
{
  . = 0x0100;
  .text :
  {
    *(.text);
  }
  .data :
  {
    *(.data);
    *(.bss);
    *(.rodata);
  }
  _heap = ALIGN(4);
}

Compile

docker run --rm -it --volume=$PWD:/workspace djgpp \
  gcc -c -std=gnu99 -Os -nostdlib -m32 -march=i386 -ffreestanding hello.c

Link

docker run --rm -it --volume=$PWD:/workspace djgpp \
  ld -o hello.com --nmagic --script=com.ld hello.o

Run (requires dosemu)

dosemu -dumb hello.com

Credit

Docker Pull Command
Owner
anibali
Source Repository