Vim 5.8 for the IBM XT
I wanted Vim on the 5160 as my editor for writing C, so I can stay in one place and run :make against Turbo C. Vim 5.8 was the last version with a 16-bit DOS build, and it was built with Borland C++. This fork builds it with Open Watcom 2 cross-compiling from the Mac, keeps it to 8088 instructions, and adds a swapper so a program run from Vim gets most of the 640K instead of about 60K. It runs on the real 5160 off the ST-251, and in 86Box for the automated tests.
Current state
As of 2026-10-09: Vim 5.8 builds with Open Watcom 2 and runs on the 5160 under DOS 5. The smoke test passed on the real machine twice. :! swaps Vim out to C:\TEMP and the program gets the memory; it takes about 10 seconds each way on the ST-251. :make is built in and tested in 86Box, but not checked against errors on the real machine yet. vim.exe is 388,790 bytes. The source is public at github.com/robertrico/vim-xt, and GitHub Actions builds it and checks it for 186 or later instructions on every push.
Architecture
Large memory model, 8086 instructions only, Vim’s MIN_FEAT set plus QUICKFIX turned back on for :make. Borland’s conio text-window calls are replaced by a small direct-video layer in os_msdos.c that writes to B000 or B800, waits for retrace on a real CGA to avoid snow, and uses BIOS int 10h for scrolling.
:! and :make go through dosswap.asm, a 1.5K stub linked first so it sits right after the PSP. It writes the rest of Vim and its heap blocks to a swap file, frees them, runs the program with DOS EXEC, then takes the same segments back and reads everything in. Every change against upstream is listed in PORTING.md in the repo.
Hardware
Runs on the 5160 from the ibm-5160 project: NEC V20, 640K, EGA in CGA mode, DOS 5, Turbo C 2.0. Installed to C:\VIM from the XT-IDE CF card with INSTALL.BAT.
Built on the Mac with Open Watcom 2 (wcc -0 -ml, wlink system dos, wmake -f Make_wat.mak). Tested in 86Box as an IBM 5160, 8088 at 4.77 MHz, 640K, CGA or MDA, on MS-DOS 5.00, 6.22 and PC DOS 3.30 images built with mtools.
Open problems
- Why the first
:!on the 5160 fell back to plainsystem()instead of swapping. :makejumping to Turbo C errors, checked on the real machine.- Editing a large file (vim.exe itself) hung in 86Box.
- Stack use not measured; it’s 8K now.
- The swap pause is about 10 seconds. EMS would be faster if I ever get a card.
vim_tempname()returns NULL when there’s no TEMP directory. Upstream bug, not fixed.- The Borland C++ reference build hasn’t been redone.
Links
- The fork: https://github.com/robertrico/vim-xt
- Vim 5.8 sources and patches: ftp.nluug.nl/pub/vim/ (unix/vim-5.8-src.tar.gz, extra/vim-5.8-extra.tar.gz, patches/5.8.001 to 5.8.009)
- vim-history, whose 5.8 tags turned out to be 6.0d alpha: https://github.com/vim/vim-history
- Open Watcom 2: https://github.com/open-watcom/open-watcom-v2