home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / SYSUTL / TSRWRK32.ZIP / FREERAM.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-06-01  |  1.6 KB  |  60 lines

  1. Page 60,132
  2. ;RAMFREE
  3. ;Determine amount of available RAM without using CHKDSK
  4. ;Written for MicroSoft Assembler version 4.0
  5. ;Only works for up to 640K bytes
  6. ; Kim Kokkonen, TurboPower Software, 6/85, 408-438-8608
  7. ;
  8. ;Renamed FREERAM
  9. ;Modified to use same method as CHKDSK
  10. ;Added comma to numerical output
  11. ;Compatible with:
  12. ; Turbo ASseMbler version 1.0 and
  13. ; Microsoft ASseMbler version 5.10
  14. ;Assemble:  TASM FREERAM
  15. ;Link:      TLINK /T FREERAM
  16. ; Rick Housh  1/26/89
  17. ;
  18. CSEG    segment public para
  19.     assume  CS:CSEG, DS:CSEG, ES:CSEG
  20.     org    100H
  21. FreeRam proc    near
  22. Start:  mov    ax,CS:[2]    ;Offset 2 contains total memory size
  23.     mov    bx,CS
  24.     sub    ax,bx        ;Minus our psp segment = memory available
  25. ;convert paragraphs to a doubleword number of bytes in dx:ax
  26.     xor    dx,dx
  27.     mov    dl,ah        ;dl will contain top four bytes of ah
  28.     mov    cl,4
  29.     shr    dx,cl
  30.     shl    ax,cl
  31. ;convert doubleword to a six char ASCII number
  32.     mov    bx,offset nbyts+7
  33.     mov    cx,offset nbyts+3
  34.     mov    si,10        ;prepare to divide by 10
  35. nexdgt: div    si        ;divide dx:ax by si
  36.     or    dx,30H        ;convert remainder to ASCII digit
  37.     dec    bx        ;back up one space in buffer
  38.     cmp    bx,cx        ;if not at comma
  39.     jnz    nocma        ;store character
  40.      dec    bx        ;else back up one space and
  41. nocma:  mov    [bx],dl        ;store character
  42.     xor    dx,dx        ;clear remainder
  43.     or    ax,ax        ;all done?
  44.     jnz    nexdgt        ;do next digit
  45. ;now output the string
  46.     mov    dx,offset bmess$
  47.     mov    ah,09H
  48.     int    21H        ;print string
  49. ;exit
  50.     mov    ax,4C00H
  51.     int    21H
  52. FreeRam endp
  53. ;data area
  54. bmess$  db    13,10,'Free Ram: '
  55. nbyts    db    32,32,32,',',32,32,32 ;holds ASCII digit
  56.     db      ' bytes',13,10,36
  57.  
  58. CSEG    ends
  59. end    Start
  60.