OpenSUSE 42.1 + DJGPP v2.05 + GCC 6.1.0
docker pull anibali/djgpp
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
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
Content type
Image
Digest
Size
105.6 MB
Last updated
almost 10 years ago
docker pull anibali/djgpp