home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0000 - 0009 / ibm0000-0009 / ibm0003.tar / ibm0003 / SRCR215.ZIP / SAMPLE2 < prev    next >
Encoding:
Text File  |  1989-03-24  |  5.6 KB  |  160 lines

  1.  
  2.  
  3.          sample  proc far
  4.          jmp short start       ────┐                                                         ; go to the start
  5.      start:                    <───┘
  6.          call getmem                                                                         ; get memory size
  7.          mov ax,totmem                                                                       ; total memory
  8.          mov di,offset tmemory
  9.          call convert                                                                        ; convert to ascii
  10.          mov ax,fremem                                                                       ; free (available) memory
  11.          mov di,offset amemory
  12.          call convert                                                                        ; convert to ascii
  13.          call display                                                                        ; display the answers
  14.      dosret:
  15.          int 20h                                                                             ; return to dos
  16.  
  17.  
  18.  
  19.          getmem  proc near                                                           ; get memory size
  20.          mov cl,6                                                                    ; shift count
  21.          mov si,2                                                                    ; point to top of memory in psp
  22.          mov ax,[si]                                                                 ; get top of memory
  23.          shr ax,cl                                                                   ; convert to KB
  24.          mov totmem,ax                                                               ; and save total memory
  25.          mov bx,cs                                                                   ; get current segment
  26.          shr bx,cl                                                                   ; convert to KB
  27.          sub ax,bx                                                                   ; subtract from total memory to get
  28.          mov fremem,ax                                                               ; free memory
  29.          ret
  30.          getmem  endp
  31.  
  32.  
  33.  
  34. getmem    proc near        ; get memory size
  35. ;----------------------------------------------
  36. ; input:     none
  37. ; output:    ax  bx  cx  si
  38. ;----------------------------------------------
  39. getmem    endp
  40.  
  41.  
  42.  
  43.          convert proc near                                                         ; convert number to ascii
  44.          push ax                                                                   ; save number
  45.          mov al,' '
  46.          mov cx,3
  47.          rep stosb                                                                 ; clear 3 bytes
  48.          pop ax                                                                    ; restore number
  49.          mov cx,10                                                                 ; divisor
  50.  ┌──>conloop:
  51.  │       xor dx,dx                                                                 ; clear remainder
  52.  │       div cx                                                                    ; divide by 10
  53.  │       add dl,30h                                                                ; convert to ascii
  54.  │       dec di                                                                    ; back up 1 byte
  55.  │       mov [di],dl                                                               ; save ascii number
  56.  │       cmp ax,0                                                                  ; done?
  57.  └───    jnz conloop                                                               ; no
  58.          ret
  59.          convert endp
  60.  
  61.  
  62.  
  63. convert proc near        ; convert number to ascii
  64. ;----------------------------------------------
  65. ; input:     dx  di
  66. ; output:    ax  cx  dx  di
  67. ;----------------------------------------------
  68. convert endp
  69.  
  70.  
  71.  
  72.          display proc near                                                                 ; display memory sizes
  73.          mov ah,9                                                                          ; display string
  74.          mov dx,offset total                                                               ; start of message
  75.          int 21h                                                                           ; let dos display it
  76.          ret
  77.          display endp
  78.  
  79.  
  80.  
  81. display proc near        ; display memory sizes
  82. ;----------------------------------------------
  83. ; input:     none
  84. ; output:    ax  dx
  85. ;----------------------------------------------
  86. display endp
  87.  
  88.  
  89.  
  90. sample    proc far
  91. ;----------------------------------------------
  92. ; input:     none
  93. ; output:    ax  di
  94. ;----------------------------------------------
  95. sample    endp
  96.  
  97.  
  98. sample (4)
  99.  ├─ getmem (6)
  100.  ├─ convert (8)
  101.  ├─ convert (8)
  102.  └─ display (6)
  103.  
  104.  
  105.  
  106.        Cross-Reference by Procedure
  107.  
  108. Procedure: sample
  109.  Labels:
  110. start
  111. dosret
  112.  
  113. Procedure: getmem
  114.  Called by:
  115. sample
  116.  
  117. Procedure: convert
  118.  Called by:
  119. sample(2)
  120.  Labels:
  121. conloop
  122.  
  123. Procedure: display
  124.  Called by:
  125. sample
  126.  
  127. Max Stack usage: 8
  128.  
  129.  
  130. PUBLIC items:
  131.  
  132. PUBLIC     sample   ; NEAR
  133. PUBLIC total     ; BYTE
  134. PUBLIC tmemory   ; BYTE
  135. PUBLIC avail     ; BYTE
  136. PUBLIC amemory   ; BYTE
  137. PUBLIC totmem    ; WORD
  138. PUBLIC fremem    ; WORD
  139. PUBLIC start     ; NEAR
  140. PUBLIC dosret    ; NEAR
  141. PUBLIC     getmem   ; NEAR
  142. PUBLIC conloop   ; NEAR
  143.  
  144. Items not public:
  145.  
  146. PUBLIC sample    ; FAR
  147. PUBLIC convert   ; NEAR
  148. PUBLIC display   ; NEAR
  149. PUBLIC getmem    ; NEAR
  150.  
  151.              Summary Table
  152. PROCEDURES:         5
  153. MACROS:             0
  154. CALLS:              4
  155. MACRO CALLS:        0
  156. EXTERNALS:          0
  157. Source Lines:      88
  158. SYMBOLS:           16
  159. Symbol Space:     117
  160.