1

I'm trying to get started in 32 bits DOS assembly programming. I've started with a simple "hello, world" program that runs great in 16 bits mode (taken from Turbo Assembler manual), and just added a couple of directives:

.386
.model flat, stdcall
.stack 100h
.data
msg DB 'hello, world',13,10,'$'
.code
start:
mov ax,@data
mov ds,ax
mov ah,9
mov dx,OFFSET msg
int 21h
mov ah,4ch
int 21h
END start

I then compiled it with Open Watcom 2, but can't get it to run:

C:\>wcl386 hello
...
HELLO.ASM: 15 lines, 0 warnings, 0 errors
...
creating a DOS/4G executable

C:\>hello
...
DOS/4GW fatal error (1313): can't resolve external references

I understand that a lot of things are wrong in my setup, but I need something working before I dive into the DPMI spec. What are the minimal changes I need to make in the code and in the command line to get something started?

airman
  • 564
  • 1
  • 4
  • 16
  • You might get better responses on the retrocomputing site. – fuz Aug 20 '22 at 17:33
  • Looking up the [error message](https://open-watcom.github.io/open-watcom-v2-wikidocs/pguide.html), we see: *DOS/4G was unable to resolve all references to DLLs for the requested program, or the program contained unsupported fixup types. Use EXEHDR or a similar LINEXE dump utility to see what references your program makes and what special fixup records might be present.* Seems like a place to start. Missing DLLs was my first guess, so maybe scan the executable for anything ending in ".dll"? – David Wohlferd Aug 20 '22 at 18:00
  • What happens if you comment out `mov ax,@data` and build it? – Michael Petch Aug 20 '22 at 22:08
  • If you want to learn 32-bit x86, it might make more sense to create native executables for modern OSes like Linux or Windows, instead of using a bunch of old software to use protected-mode under a real-mode OS (DOS). If you're specifically interested in retrocomputing, that's fine. Especially if you already understand x86 basics, and more advanced x86 stuff like how segment registers work in real mode vs. protected mode, and are just curious about how DOS/4GW actually used those features to make things work under DOS. If so then have fun figuring out the complications. – Peter Cordes Aug 20 '22 at 23:52
  • @PeterCordes : looking at his posting history and his time on Stack Retro I suspect that he's deliberately chosen to work in the DOS domain. – Michael Petch Aug 21 '22 at 00:42
  • @MichaelPetch: Indeed, I have programmed, professionally or otherwise in many languages and assembly on many platforms, from OS/370 to Linux. The only thing I'm completely ignorant is DOS extenders. I tried on SO first, as there are multiple DOS/Win/assembly questions already. – airman Aug 21 '22 at 09:54
  • @MichaelPetch: When I comment out the ``mov ax,@data``, the executable fails with "C:\HELLO.EXE is not a WATCOM program". How strange. – airman Aug 21 '22 at 10:01
  • @airman Did you also comment out the `mov ds, ax`? – Martin Rosenau Aug 24 '22 at 07:07
  • Another problem could be the `mov dx, OFFSET ...`; in a 32-bit DOS extender, the address must be stored in `edx`, not in `dx`. – Martin Rosenau Aug 24 '22 at 07:10

0 Answers0