(3045)  Sat 12 Mar 94 10:58a
By: James Vahn
To: Terry Carmen
Re: A20
St: Rcvd
---------------------------------------------------------------------------
@MSGID: 1:346/10.0 2d8210be
Comments appreciated. If appropriate, please include this in the
snippets file.

;--------------------
; a20.asm  toggles the A20 line in a timed loop.
; Purpose: To test for the optimum setting of the A20 handler.
; Example: Himem.Sys allows /M:<1-14> and this might help determine which.
; This BENCHMARK <ugh> is exactly that- only a benchmark.
; My 386SX/16, UMBDRVR.SYS, HIMEM.SYS and DOS=HIGH,UMB shows 13.6 seconds.
; 3 megs o' RAM.
;
;               By James Vahn - Email to:
;                       Fidonet 1:346/10.20
;                       WWIVnet #213 @5930
;                       Internet james_vahn@moonflower.spk.wa.us
;

cseg segment
assume cs:cseg, ds:cseg
org 100h                        ; .COM, of course.

Begin:
        mov ax,4300h
        int 2Fh                 ; A20 handler installed?
        cmp al,80h
        jne Exit

        mov ax,cs
        mov ds,ax
        mov dx,offset Msg       ; Prints the message.
        mov ah,09h
        int 21h

        mov ah,0h
        int 1Ah                 ; get low order word of clock counter
        push dx                 ; and save it.

        mov ax,4310h
        int 2Fh                 ; Get the address in ES:BX
        mov word ptr [xms],bx
        mov word ptr [xms+2],es

        mov tmp, 02h            ; increase this for faster machines.
        mov cx, 0FFFFh          ; make a loop FFFF x 2 times

   lo1: mov ah,05h
        call cs:[xms]           ; Enable A20
        mov ah,06h
        call cs:[xms]           ; Disable A20
        loop lo1
        dec tmp
        jnz lo1

        mov ah,0h
        int 1Ah                 ; Get current time
        pop bx                  ; Get starting time
        sub dx,bx               ; Find the difference
        mov ax,dx
        mov bx,10000d           ; tenths of a second.
        mul bx                  ; ticks / 18.207
        mov bx,18207d
        div bx                  ; Answer in AX, seconds elapsed.

;------------------------
; Convert AX to unsigned decimal ASCII output
; Uses AX, BX, CX, DX
; Thanks Mitch!

        mov cx,5                ; maximum of 5 decimal digits
        mov bx,10d              ; divisor
bin2a1: xor dx,dx               ; zero DX for 16 bit divide
        div bx                  ; leaves quotient in AX
        add dl,'0'              ; convert remainder to ASCII
        push dx                 ; put on stack
        loop bin2a1             ; repeat
        mov cx,5
        mov bl,'0'              ; suppress leading zeros
bin2a2: pop ax                  ; pop most significant digit first
        or bl,al                ; sets bits 0-4 after first non-zero digit
        test bl,0Fh             ; skip leading zeros
        jz bin2a4
        mov dl,al               ; Print results to screen.
        mov ah,2h
        int 21h
bin2a4: loop bin2a2
        mov ax,4C00h
        int 21h

Exit:   mov ax,cs
        mov ds,ax
        mov dx,offset Msg2      ; Prints the message.
        mov ah,09h
        int 21h
        mov ax,4C00h
        int 21h

  xms   dd ?
  tmp   db ?

  msg  db 'Tests the speed of the A20 handler.', 13,10
       db ' For reference, my 386SX/16 shows 136. Smaller is faster.',13,10
       db ' Testing- please wait. Tenths of a second: ',36

  msg2 db ' No A20 handler (like himem.sys) detected!',13,10,36

cseg ends
end Begin


 * SLMR 2.1a *

--- Maximus 2.01wb
 * Origin: Inland Empire Archive (1:346/10)

@PATH: 346/10 105/200 30 209/209 270/101 260/1 362
