3 THE IBM PC PROGRAMMER'S GUIDE TO C
\r
18 This publication remains the property of Matthew Probert. License is
\r
19 hereby given for this work to be freely distibuted in whole under the
\r
20 proviso that credit is given to the author. Sections of this work may be
\r
21 used and distributed without payment under the proviso that credit is
\r
22 given to both this work and the author. Source code occuring in this work
\r
23 may be used within commercial and non-commercial applications without
\r
24 charge and without reference to the author.
\r
27 Various functions for using Expanded memory
\r
29 #include "src\lib\ems.h"
\r
33 Tests for the presence of expnaded memory by attempting to
\r
34 open the file EMMXXXX0.
\r
42 /* Attempt to open the file device EMMXXXX0 */
\r
44 regs.x.dx = (int)"EMMXXXX0";
\r
45 sregs.ds = 0; //????
\r
46 intdosx(®s,®s,&sregs);
\r
48 error = regs.x.cflag;
\r
54 intdos(®s,®s);
\r
62 Checks whether the expanded memory manager responds correctly
\r
68 int86(EMM,®s,®s);
\r
74 int86(EMM,®s,®s);
\r
79 emmbase = MK_FP(regs.x.bx,0);
\r
86 Returns the number of available (free) 16K pages of expanded
\r
88 or -1 if an error occurs.
\r
94 int86(EMM,®s,®s);
\r
100 long emmalloc(int n)
\r
103 Requests 'n' pages of expanded memory and returns the file
\r
105 assigned to the pages or -1 if there is an error
\r
112 int86(EMM,®s,®s);
\r
118 emmmap(long handle, int phys, int page)
\r
121 Maps a physical page from expanded memory into the page frame
\r
123 conventional memory 16K window so that data can be transfered
\r
125 the expanded memory and conventional memory.
\r
133 regs.x.dx = handle;
\r
134 int86(EMM,®s,®s);
\r
135 return (regs.h.ah == 0);
\r
138 void emmmove(int page, char *str, int n)
\r
141 Move 'n' bytes from conventional memory to the specified
\r
148 ptr = emmbase + page * 16384;
\r
153 void emmget(int page, char *str, int n)
\r
156 Move 'n' bytes from the specified expanded memory page into
\r
163 ptr = emmbase + page * 16384;
\r
168 emmclose(long handle)
\r
171 Release control of the expanded memory pages allocated to
\r
178 regs.x.dx = handle;
\r
179 int86(EMM,®s,®s);
\r
180 return (regs.h.ah == 0);
\r