Open WATCOM Programmer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
this document downloaded from... Use of this document the wings of subject to the terms and conditions as flight in an age stated on the website. of adventure for more downloads visit our other sites Positive Infinity and vulcanhammer.net chet-aero.com Watcom FORTRAN 77 Programmer's Guide Version 1.8 Notice of Copyright Copyright 2002-2008 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 Watcom FORTRAN 77 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 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 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 Watcom FORTRAN 77 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 Watcom FORTRAN 77 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 .................................. 10 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? .................................. 17 5.3 How do I issue interrupts in a DOS/4GW application? ..................................................... 18 5.4 How do I get information about free memory in the 32-bit environment? ........................ 19 The DOS/4GW DOS Extender ....................................................................................................................... 21 6 The Tenberry Software DOS/4GW DOS Extender .......................................................................... 23 7 Linear Executables ........................................................................................................................... 25 7.1 The Linear Executable Format ........................................................................................... 25 7.1.1 The Stub Program ................................................................................................ 25 7.2 Memory Use ....................................................................................................................... 26 8 Configuring DOS/4GW .................................................................................................................... 29 8.1 The DOS4G Environment Variable ................................................................................... 29 8.2 Changing the Switch Mode Setting ................................................................................... 30 8.3 Fine Control of Memory Usage ......................................................................................... 31 8.3.1 Specifying a Range of Extended Memory ........................................................... 31 8.3.2 Using Extra Memory ........................................................................................... 32 8.4 Setting Runtime Options .................................................................................................... 33 8.5 Controlling Address Line 20 .............................................................................................. 34 9 VMM ................................................................................................................................................ 35 9.1 VMM Default Parameters .................................................................................................. 35 9.2 Changing the Defaults ........................................................................................................ 36 9.2.1 The .VMC File ..................................................................................................... 36 10 Interrupt 21H Functions ................................................................................................................. 37 10.1 Functions 25H and 35H: Interrupt Handling in Protected Mode ..................................... 40 v Table of Contents 10.1.1 32-Bit Gates ....................................................................................................... 40 10.1.2 Chaining 16-bit and 32-bit Handlers ................................................................. 41 10.1.3 Getting the Address of the Interrupt Handler .................................................... 41 11 Interrupt 31H DPMI Functions ...................................................................................................... 43 11.1 Using Interrupt 31H Function Calls ................................................................................. 43 11.2 Int31H Function Calls ...................................................................................................... 44 11.2.1 Local Descriptor Table (LDT) Management Services ...................................... 44 11.2.2 DOS Memory Management Services ................................................................ 49 11.2.3 Interrupt Services ............................................................................................... 51 11.2.4 Translation Services .......................................................................................... 53 11.2.5 DPMI Version .................................................................................................... 60 11.2.6 Memory Management Services ......................................................................... 61 11.2.7 Page Locking Services ....................................................................................... 62 11.2.8 Demand Paging Performance Tuning Services ................................................. 63 11.2.9 Physical Address Mapping