Reputation: 87321
I'd like to create tiny 32-bit (i386) executables for DOS.
As a reference, here is the NASM assembly source code of my tiny 16-bit (8086) executable for DOS:
; $ nasm -o hi16.com hi16.nasm # 26 bytes.
bits 16
org 0x100
mov dx, msg ; 16-bit pointer to string.
mov ah, 9 ; Print message.
int 0x21
ret ; exit(0).
msg: db 'Hello, World!', 13, 10, '$'
Since I want to use more than 1 MiB of memory in my 32-bit DOS executables, most probably I need a DOS extender. After looking at multiple DOS extenders, I've decided to try WDOSX, which seems to have the smallest stub (.exe prefix for setting up protected mode): WDOSX.DX (see here how to get it) is just 9720 bytes. The source code of my (wannabe) tiny 32-bit DOS executable is:
; $ nasm -o hi32.exe hi32.nasm # 37+9720 bytes.
bits 32
wdosx_dx_start:
incbin "WDOSX.DX" ; ~9720 bytes.
org wdosx_dx_start-$
mov ax, 0x901
int 0x31 ; Enable virtual interrupts.
mov edx, msg ; 32-bit pointer to string.
mov ah, 9 ; Print message.
int 0x21
mov ax, 0x4c00 ; exit(0).
int 0x21
msg: db 'Hello, World!', 13, 10, '$'
Both of these executables (hi16.com and hi32.exe) work out-of-the-box in DOSBox. By using DPMI function 0x0501 my 32-bit DOS program will able to allocate memory blocks larger than 1 MiB, thus my goal is fulfilled.
My question: Is there a stub smaller than WDOSX.DX (9720 bytes) I could use? WDOSX provides many features of a DPMI 0.9 host, and I don't need most of them, e.g. I don't need support for many binary formats (e.g. LE, PE), VCPI, INT15, 32-bit DOS API (all functions), mouse API, most of the DPMI API.
The features I need:
I'm looking for a link to code samples or finished implementation of these features with XMS (unreal mode?) and using the DPMI API.
Upvotes: 5
Views: 1066
Reputation: 87321
TL;DR The smallest achievable overhead overhead for writing 32-bit DOS programs is 5800 .. 9800 bytes.
I've looked around for DOS extenders, and here is what I've found:
More details about each DOS extender I've considered and the overhead they add:
Upvotes: 2