home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / DOS / UTILITY / GEHEUGEN / USE_UMBS / TEST!UMB.ASM < prev    next >
Assembly Source File  |  1991-11-08  |  8KB  |  218 lines

  1. TITLE  Test_umb  will test for Upper Memory Blocks
  2.  
  3. CR      EQU     0Dh
  4. LF      EQU     0Ah
  5. fwd     EQU     00h
  6. bwd     EQU    0FFh
  7. yes     EQU     00h
  8. no      EQU    0FFh
  9.  
  10. cseg    segment public
  11.         assume cs:cseg, ds:cseg, es:nothing
  12.  
  13. ;-------------------------------------------------------------------
  14. ; Code
  15.  
  16. init:   push    cs
  17.         pop     ds
  18.  
  19.         mov     ah, 09h
  20.         mov     dx, offset hello$
  21.         int     21h
  22.  
  23.         cld                             ;lets be sure
  24.         mov     es, [initadr]           ;start there (A000)
  25.  
  26. nxtBlk: call    ChkRAM
  27.         mov     [jmpsze], 0400h         ;take 400h size steps
  28.         mov     [direct], fwd           ;move to the right again
  29.         cmp     [flip], yes
  30.         jnz     short sayNo
  31.  
  32. sayYes: mov     dx, offset yesRAM$      ;found RAM
  33.         mov     [flip], yes             ;  indicate with flip1
  34.         jmp     short showMs
  35.  
  36. sayNo:  mov     dx, offset noRAM$       ;found no RAM
  37.         mov     [flip], no              ;  indicate with flip0
  38.  
  39. showMs: call    messge                  ;and tell it
  40.  
  41. move:   cmp     [direct], bwd           ;backward?
  42.         jz      short backw
  43.         mov     di, es
  44.         add     di, [jmpsze]            ;jump forward
  45.         mov     es, di
  46.         jc      endIt
  47.         jmp     short cont
  48.  
  49. backw:  mov     di, es
  50.         sub     di, [jmpsze]            ;jump backward
  51.         mov     es, di
  52.  
  53. cont:   call    ChkRAM                  ;check location for RAM
  54.         jz      move                    ;if no flip - keep jump'n
  55.  
  56.         xor     [direct], 0FFh          ;invert direction
  57.         mov     ax, [jmpsze]            ;get jmpsze
  58.         shr     ax, 1                   ;divide by 2
  59.         mov     [jmpsze], ax            ;and store new
  60.         jnz     move                    ;jump other way half dist'ce
  61.  
  62.         cmp     [direct], bwd           ;if direction bwd, then we are
  63.         jnz     goOn                    ;already on begin new blk, so we
  64.         mov     di, es                  ;we must recede one position
  65.         dec     di                      ;for end of last blk
  66.         mov     es, di                  ;so move left one paragraph
  67.         xor     [flip], 0FFh            ;don't worry, we'll flip back
  68. goOn:   call    endMes                  ;print this (end)location
  69.         xor     [flip], 0FFh            ;but if stand before RAMflip wrong
  70.         mov     di, es                  ;and proceed to begin next block
  71.         inc     di
  72.         mov     es, di
  73.         jmp     nxtBlk
  74.  
  75. endIt:  mov     dx, offset last$
  76.         mov     ah, 09h
  77.         int     21h
  78.         mov     dx, offset bye$
  79.         int     21h
  80.         mov     dx, offset warn$
  81.         int     21h
  82.         mov     ax, 4C00h
  83.         int     21h
  84.  
  85. ;-------------------------------------------------------------------
  86. ; Variables
  87.  
  88. jmpsze  dw     ?                        ;jumpsize
  89. initadr dw    0A000h                    ;starting address
  90. direct  db       fwd                    ;direction
  91. flip    db       yes                    ;ram at last loc
  92.  
  93. hello$  db CR,LF,'╔══════════════════════════════════════════════╗',CR,LF, \
  94.                  '║  Test_UMB   checks for RAM in  Upper Memory  ║',CR,LF, \
  95.                  '║ ┌──────────────────────────────────────────┐ ║$'
  96.  
  97. yesRAM$ db CR,LF,'║ │  Found RAM at paragraph $'
  98. noRAM$  db CR,LF,'║ │  None      at paragraph $'
  99. contd$  db                                   '#### until $'
  100. endMes$ db                                              '####  │ ║$'
  101. last$   db                                              'FFFF  │ ║',CR,LF,'$'
  102.  
  103. bye$    db       '║ └──────────────────────────────────────────┘ ║',CR,LF, \
  104.                  '║   Author: Marco van Zwetselaar  8 Nov 1991   ║',CR,LF, \
  105.                  '╚══════════════════════════════════════════════╝',CR,LF,'$'
  106.  
  107. warn$   db CR,LF,'PLEASE NOTE: Not all RAM displayed can be used!',CR,LF, \
  108.                  '  In *general*, segment A, D and E are safe.',CR,LF,CR,LF,'$'
  109.  
  110. ;-------------------------------------------------------------------
  111. ; Procedures
  112.  
  113. chkram  proc    near
  114.  
  115.         ;takes :    es : is paragraph to test
  116.         ;destr : di, bx, dx, cx
  117.         ;retur : zeroflag if flips equal, dl=old flip (FF=none, 00=RAM)
  118.  
  119.         xor     di, di
  120.         mov     bx, es:[di]             ;get memory contents at es:0
  121.         mov     dx, bx                  ;store in dx
  122.         xor     dx, 0FFFFh              ;invert all bits
  123.         mov     es:[di], dx             ;and store in memory again
  124.         mov     cx, 080h                ;Pause a moment, so that
  125.         loop    $                       ;we don't read what we wrote
  126.         cmp     es:[di], dx             ;compare to what we put there
  127.         mov     es:[di], bx             ;and restore original value
  128.         mov     dl, [flip]              ;save old flip
  129.         jz      flip0                   ;found ram?
  130.         mov     [flip], no              ;    NOT - flip to no
  131.         jmp     short pfff
  132. flip0:  mov     [flip], yes             ;    YES - flip to yes
  133. pfff:   cmp     dl, [flip]              ;set ZFlag if flipped
  134.         ret
  135.  
  136. chkram  endp
  137.  
  138. messge  proc    near
  139.  
  140.         ;takes : ds:dx points to mess (no/yesRAM)
  141.         ;      : es is segment-addr = paragr
  142.         ;destr : di, bx, ax
  143.         ;retur : unimportant - will print mess & addresses
  144.  
  145.         mov     ah, 09h                         ;print yes/noRAM
  146.         int     21h
  147.  
  148.         mov     dx, es                          ;paragraph into dx
  149.         mov     di, offset contd$               ;point di to location where
  150.         push    es
  151.         push    cs                              ;  it should be patched in
  152.         pop     es
  153.         mov     bx, offset digs                 ;ds:bx point to begin xtable
  154.         mov     ax, dx                          ;dx is paragraph address
  155.         xchg    al, ah                          ;ah patched 1st: must be in al
  156.         call    makehex
  157.         mov     ax, dx                          ;then patch al in
  158.         call    makehex
  159.         mov     dx, offset contd$               ;then print rest of messge
  160.         mov     ah, 09h
  161.         int     21h
  162.         pop     es
  163.  
  164.         ret
  165.  
  166. messge  endp
  167.  
  168. endMes  proc    near
  169.  
  170.         mov     dx, es                          ;paragraph number in dx=es
  171.         mov     di, offset endMes$              ;point es:di to patch
  172.         push    es                              ;but save es for later!
  173.         push    cs
  174.         pop     es
  175.         mov     bx, offset digs                 ;point ds:bx to xlat tbl
  176.         mov     ax, dx
  177.         xchg    al, ah
  178.         call    makehex
  179.         mov     ax, dx
  180.         call    makehex
  181.         mov     dx, offset endMes$              ;and show endlocation
  182.         mov     ah, 09h
  183.         int     21h
  184.         pop     es                              ;reset es
  185.  
  186.         ret
  187.  
  188. endMes  endp
  189.  
  190. makehex proc    near
  191.  
  192.         ;takes :    al : byte to be conv'ted to ascii (like FCh - 'FC')
  193.         ;        ds:bx : points to beginning of xlat table
  194.         ;        es:di : points to location where "XX" should come
  195.         ;destr : ax, di will point two bytes further
  196.         ;retur : ascii digits in locations es:di and es:di+1
  197.  
  198.         db      0D4h, 010h              ;adjust for ascii multip: ah->ax/16
  199.                                         ;                         al->rest
  200.  
  201.         xchg    al, ah                  ;high nibble first
  202.         xlat                            ;ds:bx must point to right dig
  203.         stosb                           ;store the string-byte
  204.  
  205.         xchg    al, ah
  206.         xlat                            ;low level
  207.         stosb
  208.  
  209.         ret
  210.  
  211.         digs    db      '0123456789ABCDEF'
  212.  
  213. makehex endp
  214.  
  215. cseg    ends
  216.         end
  217.  
  218.