18.3 Using PModeLib: A Framework

Any program that uses PModeLib should follow this basic framework. It must also link with lib291.a (this will be done by default in the protected mode MP).

%include "lib291.inc"

GLOBAL _main

...

SECTION .text

_main
        call    _LibInit         ; You could use invoke here, too
        test    eax, eax         ; Check for error (nonzero return value)
        jnz     near .initerror

... do stuff using PModeLib functions ...

        call    _LibExit
.initerror:
        ret                      ; Return to DOS