home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1995 November / PCWK1195.iso / inne / dos / programo / pmw120.exe / EXAMPLES.ZIP / EXAMPLE4.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  1.7 KB  |  60 lines

  1. /*****************************************************************************
  2.  
  3.   This program demonstrates memory availability under PMODE/W. Keep in mind
  4. that under VCPI, on systems with more than 16 megabytes of memory, you will
  5. have to use PMWSETUP to modify the example program to use more than 4 VCPI
  6. page tables so that PMODE/W can access more extended memory.
  7.  
  8. *****************************************************************************/
  9.  
  10. #include <dos.h>
  11. #include <math.h>
  12. #include <stdio.h>
  13.  
  14. #pragma aux DOSalloc4k =\
  15.         "mov bx,0100h",\
  16.         "mov ax,0100h",\
  17.         "int 31h",\
  18.         "mov ecx,0",\
  19.         "jc short done",\
  20.         "mov bx,dx",\
  21.         "mov ax,0006h",\
  22.         "int 31h",\
  23.         "shl ecx,16",\
  24.         "mov cx,dx",\
  25.         "done:",\
  26.         modify [ax bx dx] value [ecx];
  27.  
  28. #pragma aux DPMIalloc4k =\
  29.         "mov cx,1000h",\
  30.         "mov bx,0000h",\
  31.         "mov ax,0501h",\
  32.         "int 31h",\
  33.         "mov edx,0",\
  34.         "jc short done",\
  35.         "shrd edx,ebx,16",\
  36.         "mov dx,cx",\
  37.         "done:",\
  38.         modify [ax bx cx si di] value [edx];
  39.  
  40. void main ()
  41. {
  42.   unsigned u, DOScount, DPMIcount;
  43.  
  44.   for (DOScount = 0; u = DOSalloc4k (); DOScount ++)
  45.     printf ("Allocated 4k DOS block at:  0x%08x\n", u);
  46.  
  47.   for (DPMIcount = 0; u = DPMIalloc4k (); DPMIcount ++)
  48.     printf ("Allocated 4k DPMI block at: 0x%08x\n", u);
  49.  
  50.   printf ("\n"
  51.           "Total DOS 4k blocks allocated:   0x%08x (%dk)\n"
  52.           "Total DPMI 4k blocks allocated:  0x%08x (%dk)\n"
  53.           "\n"
  54.           "Total 4k blocks allocated:       0x%08x (%dk)\n",
  55.           DOScount, DOScount * 4,
  56.           DPMIcount, DPMIcount * 4,
  57.           DOScount + DPMIcount, (DOScount + DPMIcount) * 4);
  58. }
  59.  
  60.