home *** CD-ROM | disk | FTP | other *** search
- Page 60,132
- ;RAMFREE
- ;Determine amount of available RAM without using CHKDSK
- ;Written for MicroSoft Assembler version 4.0
- ;Only works for up to 640K bytes
- ; Kim Kokkonen, TurboPower Software, 6/85, 408-438-8608
- ;
- ;Renamed FREERAM
- ;Modified to use same method as CHKDSK
- ;Added comma to numerical output
- ;Compatible with:
- ; Turbo ASseMbler version 1.0 and
- ; Microsoft ASseMbler version 5.10
- ;Assemble: TASM FREERAM
- ;Link: TLINK /T FREERAM
- ; Rick Housh 1/26/89
- ;
- CSEG segment public para
- assume CS:CSEG, DS:CSEG, ES:CSEG
- org 100H
- FreeRam proc near
- Start: mov ax,CS:[2] ;Offset 2 contains total memory size
- mov bx,CS
- sub ax,bx ;Minus our psp segment = memory available
- ;convert paragraphs to a doubleword number of bytes in dx:ax
- xor dx,dx
- mov dl,ah ;dl will contain top four bytes of ah
- mov cl,4
- shr dx,cl
- shl ax,cl
- ;convert doubleword to a six char ASCII number
- mov bx,offset nbyts+7
- mov cx,offset nbyts+3
- mov si,10 ;prepare to divide by 10
- nexdgt: div si ;divide dx:ax by si
- or dx,30H ;convert remainder to ASCII digit
- dec bx ;back up one space in buffer
- cmp bx,cx ;if not at comma
- jnz nocma ;store character
- dec bx ;else back up one space and
- nocma: mov [bx],dl ;store character
- xor dx,dx ;clear remainder
- or ax,ax ;all done?
- jnz nexdgt ;do next digit
- ;now output the string
- mov dx,offset bmess$
- mov ah,09H
- int 21H ;print string
- ;exit
- mov ax,4C00H
- int 21H
- FreeRam endp
- ;data area
- bmess$ db 13,10,'Free Ram: '
- nbyts db 32,32,32,',',32,32,32 ;holds ASCII digit
- db ' bytes',13,10,36
-
- CSEG ends
- end Start