17.5 Binding OS/2 MASM Programs

You can convert many OS/2 programs to run under both OS/2 and DOS 3.x. This conversion is called “binding” because it binds system calls to the API.LIB file provided with MASM 6.0. This file simulates OS/2 functions under DOS. The program must use a restricted set of system calls or it cannot be bound.

OS/2 function calls are known collectively as the applications program interface (API). If you restrict your system calls to a subset of these functions known as the Family API, the program can be bound. See the Microsoft Operating System/2 Programmer's Reference for a list of the Family API functions.

Summary: Online help also provides information on these utilities.

If you use PWB, binding is easy. Select Bound Application from the LINK Options command in the Options menu. PWB does the rest, calling the BIND.EXE utility.

If you want to bind the program to run under either OS/2 or DOS, use this command line:

ML /Fb hello.asm

You can use system calls outside the Family API provided that you never use them when running under DOS. The program can check the operating system and, if running under OS/2, can execute system calls that do not belong to the Family API. To follow this strategy, list OS/2-only calls with the BIND's /N option. It is the program's responsibility to make sure these calls are never made under DOS; otherwise, execution is terminated.