Skip to content

DOS programs

Scripts and tests for building and checking a DOS sysroot for the i8086-pc-msdos target of the clang-dos LLVM toolchain, and for 16-bit Windows (i8086-pc-win16, see below).

A sysroot holds, for each memory model:

<sysroot>/include/                       picolibc headers
<sysroot>/include/c++/v1/                libc++ headers
<sysroot>/lib/<model>/crt0.obj           startup code
<sysroot>/lib/<model>/libc.a             picolibc with the DOS layer
<sysroot>/lib/<model>/libclang_rt.builtins.a
<sysroot>/lib/<model>/libc++.a           libc++
<sysroot>/lib/<model>/libc++abi.a        libc++abi
<sysroot>/include/windows.h              16-bit Windows API (win16-sdk)
<sysroot>/lib/win16/windows.lnk          Windows API imports
<sysroot>/lib/win16/windows300.lnk       ... for Windows 3.0
<sysroot>/lib/win16/windows200.lnk       ... for Windows 2.x
<sysroot>/lib/win16/windows100.lnk       ... for Windows 1.x
<sysroot>/lib/win16/<model>/             the same libraries for Windows,
                                         with libentry.obj for DLLs

The models are tiny (.COM programs), small, medium, compact, large and huge (.EXE programs). Medium has far code (each source file gets its own code segment, so code can exceed 64 KiB) and near data. Compact has near code and far data: data pointers are 32-bit segment:offset values, while small globals and the stack stay in the 64 KiB DGROUP, the heap is a 64 KiB segment of its own after the program, and size_t stays 16 bits. Large has both far code and far data. Huge has far code and huge data pointers, which address objects over 64 KiB: size_t and ptrdiff_t are 32 bits, pointer arithmetic carries into the segment, and the heap takes all free DOS memory.

docs/memory-models.md helps you choose a model for your program, with the clang flags for common cases.

Full-screen programs

For full-screen DOS programs, the sysroot also has <conio.h> (in the C library), <graphics.h> and <fastgraf.h> (-lgraph: the Borland Graphics Interface and Fastgraph functions, from CGA to VESA), <curses.h> and <panel.h> (-lcurses: PDCurses 3.9, the curses library of X/Open and System V), <cwin.h> (-lcwin: the Windows 3.x API in text mode, in the style of the character-mode Microsoft applications) and <tui.h> (-ltui: a C++ text-mode window toolkit with menus, dialogs and the mouse). docs/graphics-and-tui.md describes them. Programs written for Mike Smedley's CXL and TCXL text libraries build against -lcxl, a new implementation of their API; see docs/cxl.md. Borland's Turbo Vision is there too, as <tvision/tv.h> and -ltvision in the models with far code (medium, large, huge and huge16): see tvision/README.md.

16-bit Windows

--target=i8086-pc-win16 makes Windows 1.x, 2.x and 3.x programs and DLLs (NE executables) in the small, medium, compact and large models. Their <windows.h>, the Windows API import lists and the script that builds the Windows libraries into this sysroot are in clang-dos/win16-sdk, with the documentation and the tests. scripts/build-sysroot.sh runs that script after the DOS libraries (see below).

The 32 and 64-bit Windows sysroots of the toolchain package (Win32s, NT 3.x to 11, 95/98/ME) are built by clang-dos/win32-sdk.