home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / dos / envfree.lzh / ENVFREE.ASM next >
Assembly Source File  |  1986-08-10  |  1KB  |  68 lines

  1. ;History:17
  2.  
  3.     include    /include/macros.inc
  4.     include    /include/printf.inc
  5.  
  6. mcb    segment at 0h
  7. mcb_flag    db    ?        ;'M' for normal, 'Z' for final block
  8. mcb_owner    dw    ?        ;segment of owner's psp
  9. mcb_size    dw    ?        ;block size in paragraphs
  10. mcb    ends
  11.  
  12. code    segment    public
  13.     assume    cs:code, ds:code
  14.  
  15.     include    /include/phd.inc
  16.  
  17. start:
  18.     jmp    start_1
  19.  
  20. start_1:
  21.     mov    ah,52h            ;get in vars (whatever that means)
  22.     int    21h
  23.     assume    es:nothing
  24.     mov    es,es:[bx - 2]        ;load segment of first memory block
  25.     assume    es:mcb
  26.  
  27.     push ds                ;interrupt 2eh belongs to command.com
  28.     xor dx,dx
  29.     mov ds,dx
  30.     mov dx,ds:[2eh*4+2]
  31.     pop ds
  32.     .dowhl dx ne mcb_owner
  33.       mov    ax,es            ;get segment of current block
  34.       inc    ax            ;advance to contents of block
  35.       add    ax,mcb_size        ;add length of current block
  36.       mov    es,ax            ;segment number of next block
  37.     .enddo
  38.  
  39.     mov    ax,es            ;get segment of current block
  40.     inc    ax            ;advance to contents of block
  41.     add    ax,mcb_size        ;add length of current block
  42.     mov    es,ax            ;segment number of next block
  43.  
  44.     mov    di,16            ;make di->memory block contents.
  45.     mov    cx,mcb_size        ;make cx=size of enviornment block.
  46.     shl    cx,1            ;convert from paragraphs to bytes.
  47.     shl    cx,1
  48.     shl    cx,1
  49.     shl    cx,1
  50.     push    cx
  51.     .dowhl    <byte ptr es:[di]> ne 0
  52.       xor    al,al            ;search for a null.
  53.       repne    scasb
  54.     .enddo
  55.     pop    bx
  56.     mov    ax,bx
  57.     sub    ax,cx
  58.  
  59.     printf    "Enviornment space: %d free, %d used, %d max",cx,ax,bx
  60.  
  61.     mov    ax,4c00h
  62.     int    21h
  63.  
  64.  
  65. code    ends
  66.  
  67.     end    start
  68.