DOS-Extender and 386|DOS-Extender Are Trademarks of Phar Lap Software, Inc
Total Page:16
File Type:pdf, Size:1020Kb
Open Watcom C/C++ Programmer’s Guide Version 2.0 Notice of Copyright Copyright 2002-2021 the Open Watcom Contributors. Portions Copyright 1984-2002 Sybase, Inc. and its subsidiaries. All rights reserved. Any part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of anyone. For more information please visit http://www.openwatcom.org/ Portions of this manual are reprinted with permission from Tenberry Software, Inc. ii Preface The Open Watcom C/C++ Programmer’s Guide includes the following major components: • DOS Programming Guide • The DOS/4GW DOS Extender • Windows 3.x Programming Guide • Windows NT Programming Guide • OS/2 Programming Guide • Novell NLM Programming Guide • Mixed Language Programming • Common Problems Acknowledgements This book was produced with the Open Watcom GML electronic publishing system, a software tool developed by WATCOM. In this system, writers use an ASCII text editor to create source files containing text annotated with tags. These tags label the structural elements of the document, such as chapters, sections, paragraphs, and lists. The Open Watcom GML software, which runs on a variety of operating systems, interprets the tags to format the text into a form such as you see here. Writers can produce output for a variety of printers, including laser printers, using separately specified layout directives for such things as font selection, column width and height, number of columns, etc. The result is type-set quality copy containing integrated text and graphics. Many users have provided valuable feedback on earlier versions of the Open Watcom C/C++ compilers and related tools. Their comments were greatly appreciated. If you find problems in the documentation or have some good suggestions, we would like to hear from you. July, 1997. Trademarks Used in this Manual DOS/4G and DOS/16M are trademarks of Tenberry Software, Inc. OS/2 is a trademark of International Business Machines Corp. IBM Developer’s Toolkit, Presentation Manager, and OS/2 are trademarks of International Business Machines Corp. IBM is a registered trademark of International Business Machines Corp. Intel and Pentium are registered trademarks of Intel Corp. Microsoft, Windows and Windows 95 are registered trademarks of Microsoft Corp. Windows NT is a trademark of Microsoft Corp. NetWare, NetWare 386, and Novell are registered trademarks of Novell, Inc. iii Phar Lap, 286|DOS-Extender and 386|DOS-Extender are trademarks of Phar Lap Software, Inc. UNIX is a registered trademark of The Open Group. WATCOM is a trademark of Sybase, Inc. and its subsidiaries. iv Table of Contents 1 Open Watcom C/C++ Application Development ........................................................................................ 1 DOS Programming Guide .................................................................................................................................... 3 2 Creating 16-bit DOS Applications ............................................................................................................... 5 2.1 The Sample Application ...................................................................................................................... 5 2.2 Building and Running the Sample DOS Application .......................................................................... 5 2.3 Debugging the Sample DOS Application ........................................................................................... 6 3 Creating 32-bit Phar Lap 386|DOS-Extender Applications ......................................................................... 9 3.1 The Sample Application ...................................................................................................................... 9 3.2 Building and Running the Sample 386|DOS-Extender Application ................................................... 9 3.3 Debugging the Sample 386|DOS-Extender Application ..................................................................... 10 4 Creating 32-bit DOS/4GW Applications ..................................................................................................... 13 4.1 The Sample Application ...................................................................................................................... 13 4.2 Building and Running the Sample DOS/4GW Application ................................................................ 13 4.3 Debugging the Sample DOS/4GW Application .................................................................................. 14 5 32-bit Extended DOS Application Development ........................................................................................ 17 5.1 Introduction ......................................................................................................................................... 17 5.2 How can I write directly to video memory using a DOS extender? ................................................... 18 5.2.1 Writing to Video Memory under Tenberry Software DOS/4GW .............................................. 18 5.2.2 Writing to Video Memory under the Phar Lap 386|DOS-Extender ........................................... 19 5.3 How do I get information about free memory in the 32-bit environment? ......................................... 19 5.3.1 Getting Free Memory Information under DOS/4GW ................................................................ 20 5.3.2 Getting Free Memory Information under the Phar Lap 386|DOS-Extender .............................. 21 5.3.3 Getting Free Memory Information in the 32-bit Environment under Windows 3.x .................. 22 5.4 How do I access the first megabyte in the extended DOS environment? ........................................... 24 5.4.1 Accessing the First Megabyte under Tenberry Software DOS/4GW ........................................ 24 5.4.2 Accessing the First Megabyte under the Phar Lap 386|DOS-Extender ..................................... 25 5.5 How do I spawn a protected-mode application? ................................................................................. 26 5.5.1 Spawning Protected-Mode Applications Under Tenberry Software DOS/4GW ....................... 26 5.5.2 Spawning Protected-Mode Applications Under Phar Lap 386|DOS-Extender .......................... 27 5.6 How Can I Use the Mouse Interrupt (0x33) with DOS/4GW? ........................................................... 28 5.7 How Do I Simulate a Real-Mode Interrupt with DOS/4GW? ............................................................ 32 5.8 How do you install a bi-modal interrupt handler using DOS/4GW? .................................................. 33 The DOS/4GW DOS Extender ............................................................................................................................. 39 6 The Tenberry Software DOS/4GW DOS Extender ..................................................................................... 41 7 Linear Executables ....................................................................................................................................... 43 7.1 The Linear Executable Format ............................................................................................................ 43 7.1.1 The Stub Program ....................................................................................................................... 43 7.2 Memory Use ........................................................................................................................................ 44 8 Configuring DOS/4GW ............................................................................................................................... 47 8.1 The DOS4G Environment Variable .................................................................................................... 47 8.2 Changing the Switch Mode Setting ..................................................................................................... 48 v Table of Contents 8.3 Fine Control of Memory Usage .......................................................................................................... 49 8.3.1 Specifying a Range of Extended Memory .................................................................................. 49 8.3.2 Using Extra Memory .................................................................................................................. 50 8.4 Setting Runtime Options ..................................................................................................................... 51 8.5 Controlling Address Line 20 ............................................................................................................... 52 9 VMM ............................................................................................................................................................ 53 9.1 VMM Default Parameters ................................................................................................................... 53 9.2 Changing the Defaults ......................................................................................................................... 54 9.2.1 The .VMC File ............................................................................................................................ 54 10 Interrupt 21H Functions ............................................................................................................................