home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / msysjour / vol03 / 05 / msctsr / locs.c < prev    next >
C/C++ Source or Header  |  1988-08-31  |  994b  |  29 lines

  1. /* Figure 3. locs.c, a program that shows how to determine the size of a
  2. /* program. */
  3.  
  4.    #include <dos.h>
  5.    extern unsigned int _psp, end;
  6.    extern unsigned char _osmajor, _osminor;
  7.  
  8.    main()
  9.    {
  10.          char huge *startofitall;
  11.          char huge *endofitall;
  12.          unsigned blength;         /* byte length: psp + text + data */
  13.          unsigned plength;         /* paragraph length */
  14.  
  15.          printf("Dos version %d.%d\n", _osmajor,_osminor);
  16.  
  17.          FP_SEG(startofitall) = _psp;
  18.          FP_OFF(startofitall) = 0;
  19.          endofitall = (char huge *)&end;
  20.          blength = endofitall - startofitall;      /* bytes */
  21.          plength = blength;
  22.          if (plength & 0xf)      /* round up to next 16 byte para */
  23.                plength += 0x10;
  24.          plength >>= 4;          /* convert to paragraphs */
  25.  
  26.          printf("start %Fp, end %Fp, size %u (bytes) %u (paragraphs)\n",
  27.                startofitall, endofitall, blength, plength);
  28.    }
  29.