How 16-bit programs starts up?

Back in 16-bit Windows, MS-DOS cast a long and dark shadow. The really ugly low-level munging was very much in the MS-DOS spirit. You opened files by setting up registers and issuing an int 21h, just like in MS-DOS. Although the interrupt went to Windows instead, Windows maintained the MS-DOS calling convention. Process startup followed […]

Back in 16-bit Windows, MS-DOS cast a long and dark shadow. The really ugly low-level munging was very much in the MS-DOS spirit. You opened files by setting up registers and issuing an int 21h, just like in MS-DOS. Although the interrupt went to Windows instead, Windows maintained the MS-DOS calling convention. Process startup followed the same "real men write in assembly language" philosophy.

All the parameters to a 16-bit program were passed in registers. The entry point to a 16-bit process received the following parameters on Windows 3.1:

AX zero (used to contain even geekier information in Windows 2)
BX stack size
CX heap size
DX unused (reserved)
SI previous instance handle
DI instance handle
BP zero (for stack walking)
DS application data segment
ES selector of program segment prefix
SS application data segment (SS=DS)
SP top of stack

Full Article

MS-DOS, DOS, Windows, 16-bit, Startup, Microsoft, Knowledgebase