home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / MISC / BBENCH21.ZIP / SOURCE.ZIP / MISCSUBS.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-08-09  |  15.4 KB  |  991 lines

  1. ; miscellaneous asm subroutines for the byte benchmarks
  2. ;
  3. ; BYTE Magazine, Spring 1990
  4. ;
  5. ; Modified 8/9/90 -- put  in extra check for overflow in Getmhz - Steve.
  6. ;
  7. ;
  8.  
  9. _data    segment word public 'DATA'
  10.     control        dw    ?    ;For floating-point control word
  11.     cap_reqd    dw    ?    ; disk capacity required
  12.             dw    ?
  13.     extrn    video_seg: WORD
  14.  
  15. _data    ends
  16.  
  17. dgroup    group    _data
  18. assume    cs:_text, ds:dgroup
  19. public     _strip0s, _machine_detect, _disk_check, _set_default, _get_default
  20. public  _getpath, _cdir, _click
  21.  
  22. _text    segment byte public 'CODE'
  23.  
  24. _strip0s    proc    near
  25.  
  26. ; void strip0s(char *buffer, unsigned int buflen);
  27. ; strips (turns into spaces) zeros from a char buffer.
  28. ;
  29.  
  30.     strip0sframe    struc
  31.     s0bptr        dw    ?
  32.     s0raddr        dw    ?
  33.     s0bufptr    dw    ?
  34.     s0buflen    dw    ?
  35.     strip0sframe    ends
  36.  
  37. s0sframe        equ    [bp-s0bptr]
  38.  
  39.     push     bp        ; Stack frame manipulations
  40.     mov     bp,sp
  41.     sub    sp,s0bptr
  42.     push    di
  43.     push    es
  44.  
  45.     mov    cx, s0sframe.s0buflen
  46.     jcxz    S0EXIT
  47.     push    ds
  48.     pop    es
  49.     mov    ax, s0sframe.s0bufptr
  50.     mov    di, ax
  51.     xor    al, al
  52. S0S0:
  53.  
  54. repne    scasb
  55.     jne    S0EXIT
  56.     dec    di
  57.     inc    cx
  58.     mov    byte ptr [di], ' '
  59.     jmp    short    S0S0
  60.  
  61. S0EXIT:
  62.  
  63.     pop    es
  64.     pop    di
  65.         pop    bp
  66.            ret
  67.  
  68. _strip0s    ENDP
  69.  
  70. ;-----------------------------------------------------------
  71.  
  72. getproc    proc    near
  73.  
  74. ; detects processor type
  75. ; returns value in ax
  76. ; This routine is adapted from Michael Young's _MS-DOS_Advanced_
  77. ; Programming_
  78.  
  79.     push    di
  80.     push    es
  81.     pushf
  82.  
  83. ; 808x test
  84. ; Attempt to zero flag register. If four high-order bits still
  85. ; set, its an 808x.
  86. ;
  87.  
  88.     xor    ax, ax
  89.     push    ax
  90.     popf
  91.     pushf
  92.     pop    ax
  93.     and    ax, 0f000h
  94.     cmp    ax, 0f000h
  95.     jne    GP186TEST
  96.     mov    ax, 86
  97.     jmp    short    GPEXIT
  98.  
  99. GP186TEST:
  100. ; 186 test
  101. ; Push SP. 80186 decrements SP before pushing, so popped SP will
  102. ; not be equal. 286 and 386 decrement after push.
  103.  
  104.     push    sp
  105.     pop    ax
  106.     cmp    ax, sp
  107.     je    GP286TEST
  108.     mov    ax, 186
  109.     jmp    short    GPEXIT
  110.  
  111. GP286TEST:
  112. ; 286 test
  113. ; Attempt to set bits 15-12 of the flags register. If they don't set,
  114. ; it's a 286.
  115.  
  116.     mov    ax, 0f000h
  117.     push    ax
  118.     popf
  119.     pushf
  120.     pop    ax
  121.     and    ax, 0f000h
  122.     jnz    GP386
  123.     mov    ax, 286
  124.     jmp    short    GPEXIT
  125.  
  126. GP386:
  127. ; all that's left. 486s and sxes are not considered.
  128.  
  129.     mov    ax, 386
  130. GPEXIT:
  131.     popf
  132.     pop    es
  133.     pop    di
  134.     ret
  135.  
  136. getproc    ENDP
  137.  
  138. ;-----------------------------------------------------------
  139.  
  140. getfpu        proc        near
  141.  
  142. ; detects fpu type
  143. ; returns value in ax
  144.  
  145.     push    di
  146.     push    es
  147.  
  148.     mov    bx, ax
  149.     int    11h
  150.     and    ax, 02h
  151.     jz    FPUEXIT            ; no fpu installed
  152.  
  153.     cmp    bx, 286
  154.     jle    FNOT386
  155.  
  156. ; Test for 287 or 387.  This code adapted from the defunct but 
  157. ; fondly remembered PC Tech Journal.
  158.  
  159.     finit
  160.     fld1
  161.     fldz
  162.     fdiv                ;Create infinity
  163.     fld    st
  164.     fchs                ;Create negative infinity
  165.     fcompp                ;Compare
  166.     fstsw    control            ;Save control word
  167.     fwait                ;Just in case...
  168.     mov    ax,control
  169.     sahf                ;Control word in flags
  170.     mov    ax,287            ;Assume 80287
  171.     jz    FIS287
  172.     mov    ax,387            ;Nope, 80387
  173. FIS287:
  174.     jmp    short    FPUEXIT
  175. FNOT386:
  176.     mov    ax, bx
  177.     inc    ax
  178. FPUEXIT:
  179.     pop    es
  180.     pop    di
  181.     ret
  182.  
  183. getfpu    ENDP
  184.  
  185. ;-----------------------------------------------------------
  186.  
  187. getmhz        proc        near
  188.  
  189. ; this routine determines machine approximate speed for use in later
  190. ; estimates. while it uses as few memory accesses as possible, it will
  191. ; be affected by memory speed.
  192. ; On entry -- ax= proc type, 88=8088, etc.
  193. ; On exit -- ax = approx megahertz.
  194.  
  195.     jmp    short    GMHREALSTART
  196.  
  197.     checkval    db    0
  198.     convfact    dw    0
  199.  
  200. ; checkval == 1 if main routine has initialized and counter is 
  201. ; ready to run, 0 otherwise
  202. ; bl is the pass counter
  203.  
  204. FACT88        equ    7002
  205. FACT286        equ    4091
  206. FACT386        equ    3210
  207.  
  208. GMH1CHANDLER:
  209.  
  210.     push    ax
  211.  
  212.     push    cs
  213.     pop    ds
  214.  
  215.     mov    al, 1
  216.     cmp    al, checkval
  217.     jne    GMHCHAIN
  218.  
  219. ; now initialize routine has zeroed bx if this is the first pass
  220.  
  221.     inc    bl
  222.     cmp    al, bl
  223.     je    ONETWOEXIT    ; its the first pass
  224.  
  225.     mov    checkval, 0    ; clear checkval so we're done
  226.  
  227. ONETWOEXIT:
  228.  
  229.     pop    ax
  230.     iret
  231.  
  232. GMHCHAIN:
  233.  
  234.     pop    ax
  235.             db    0eah    ; sleazy far jump trick
  236.     gmhovo        dw    0
  237.     gmhovs        dw    0
  238.  
  239. GMHREALSTART:
  240.  
  241.     push    di
  242.     push    es
  243.     push    ds
  244.  
  245.     push    cs
  246.     pop    ds
  247.  
  248.  
  249. ; store conversion factor
  250.  
  251.     cmp    ax, 386
  252.     jl    GMH28
  253.     mov    convfact, FACT386
  254.     jmp    short    GMFACTDONE
  255. GMH28:
  256.     cmp    ax, 286
  257.     jl    GMH88
  258.     mov    convfact, FACT286
  259.     jmp    short    GMFACTDONE
  260. GMH88:
  261.     mov    convfact, FACT88
  262. GMFACTDONE:
  263.  
  264. ; install new int 1c handler
  265. ; get old owner's address and install
  266.  
  267.     mov    ax,351ch    ; prepare for function call
  268.     int    21h        ; get address of int 1c handler in es:bx
  269.     mov    gmhovo, bx
  270.     mov    gmhovs, es
  271.     mov    dx, offset GMH1CHANDLER
  272.     mov    ax, 251ch
  273.     int    21h
  274.  
  275.     mov    al, 1
  276.     xor    cx, cx
  277.     xor    dx, dx
  278.     xor    bx, bx
  279.  
  280. ; turn on interrupt
  281.  
  282.     cli
  283.     mov    checkval, al
  284.     sti
  285.  
  286. GML0:
  287.     cmp    al, bl
  288.     jg    GML0
  289.  
  290. GML1:
  291.     cmp    al, bl
  292.     jl     DONE
  293.     loop    GML1
  294.     dec    dx
  295.     jmp    short    GML1
  296.  
  297. DONE:
  298. ; now hibits are in dx, lobits are in cx
  299.  
  300.     push    dx
  301.     push    cx
  302.  
  303. ; uninstall the nasty handler
  304.  
  305.     mov    dx, gmhovo
  306.     mov    ax, gmhovs
  307.     mov    ds, ax
  308.     mov    ax, 251ch
  309.     int    21h
  310.  
  311. ; mov numbers to dx:ax
  312.  
  313.     pop    ax
  314.     pop    dx
  315.  
  316.     neg    dx
  317.     neg    ax
  318.  
  319. ; compensate for time spent in interrupts
  320.  
  321.     add    ax, 15
  322.     adc    dx, 0
  323.  
  324. ; multiply by conversion factor to get thousands of cycles per second --
  325.  
  326.     push    dx        ; save high order
  327.     mov    bx, convfact
  328.     mul    bx
  329.  
  330.     pop    cx        ; old high order
  331.     push    ax        ; new low order
  332.     push    dx        ; new high order
  333.  
  334.     mov    ax, cx
  335.     mul    bx
  336.  
  337. ; if dx is not clear we're going to overflow
  338.  
  339.     cmp    dx, 0
  340.     je    GMNOOFLOW
  341.     pop    ax
  342.     pop    ax
  343.     pop    ds
  344.     mov    ax, 0ffffh
  345.     ret
  346.  
  347. GMNOOFLOW:
  348.  
  349.     pop    dx
  350.     add    dx, ax        ; multiplied result
  351.     pop    ax
  352.  
  353. ; divide by 10000
  354.  
  355.     mov    bx, 10000
  356.     cmp    bx, dx
  357.     jle    GMOFLOW2
  358.     div    bx
  359.     jmp    short  GMNOOFLOW2
  360.  
  361. GMOFLOW2:
  362.     mov    ax, 0ffffh    ; fastest machine there is 
  363.  
  364. GMNOOFLOW2:
  365. ; further divide by 1000 to convert to MHz
  366.  
  367.     xor    dx, dx
  368.     mov    bx, 1000
  369.     div    bx
  370.  
  371.     sar    bx,1
  372.     cmp    dx, bx
  373.     jl    GMNOROUNDUP
  374.     inc    ax
  375.  
  376. GMNOROUNDUP:
  377.  
  378.     pop    ds
  379.     pop    es
  380.     pop    di
  381.     ret
  382.  
  383. getmhz    ENDP
  384.  
  385. ;-----------------------------------------------------------
  386.  
  387. getga        proc        near
  388.  
  389. ; detects graphics adapter
  390. ; returns value in ax
  391. ; sets up the proper video segment for windowing routines.
  392. ; Adapted from routines in _Programmer's_Guide_to_PC_and_PS/2_
  393. ; _Video_Systems_, by Richard Wilton
  394. ;
  395. ;    Function returns the following values:
  396. ;    MDA - 6            CGA, - 3            None - 0
  397. ;    HERC - 5        EGA, Enhanced color - 2
  398. ;    EGA, Mono - 4       VGA - 1
  399. ;
  400.  
  401.     push    di
  402.     push    es
  403.  
  404.     xor      ax,ax        ;PS/2
  405.     mov     ax,1A00h
  406.     int     10h
  407.     xor     bh,bh        ;Discard inactive
  408.     mov     cl,bl
  409.     xor     bl,bl
  410.     cmp     cl,7        ;7 and 8 are VGA
  411.     jne     DUMMY
  412.     jmp     VGAFND
  413. DUMMY:    cmp     cl,8
  414.     jne      DUM1
  415.     jmp    VGAFND
  416. DUM1:    mov     bl,10h
  417.     mov     ah,12h
  418.     int     10h
  419.     cmp     bl,10h
  420.     je     CGATST
  421.     xor     bx,bx
  422.     mov     ax,40h        ;EGA maybe
  423.     mov     es,ax
  424.     mov     al,es:[87h]
  425.     test     al,08h        ;Test if EGA present but inactive
  426.     jnz     CGATST
  427.     test     al,02h        ;Test if EGA has mono display
  428.     jnz     EGMFND
  429.     jmp     EGAFND
  430. CGATST:    mov     ah,0Fh        ;Determine if any monochrome displays active
  431.     int     10h        ;    before continuing
  432.     cmp    al,7
  433.     je     MDATST
  434.            xor     bx,bx
  435.     mov     dx,3D4h
  436.     mov     al,0Fh
  437.     out     dx,al
  438.     inc     dx
  439.     in      al,dx
  440.     mov     ah,al
  441.     mov     al,77h        ;Arbitrary write value to test for 6845
  442.     out     dx,al
  443.     mov     cx,100h
  444. STALL1:    loop     STALL1
  445.     in      al,dx
  446.     xchg     ah,al
  447.     out     dx,al        ;Put it back
  448.     cmp     ah,77h
  449.     je      CGAFND 
  450. MDATST:    xor     bx,bx
  451.     mov     dx,3b4h        ;Same test, new address, for MDA, Herc
  452.     mov     al,0Fh
  453.     out     dx,al
  454.     inc     dx
  455.     in      al,dx
  456.     mov     ah,al
  457.     mov     al,77h        ;Arbitrary write value to test for 6845
  458.     out     dx,al
  459.     mov     cx,100h
  460. STALL2:    loop     STALL2
  461.     in      al,dx
  462.     xchg     ah,al
  463.     out     dx,al        ;Put it back
  464.     cmp     ah,77h
  465.     jne     LOST        ;Out of possibilities
  466.     mov     dx,3BAh        ;Differentiate between MDA, Herc
  467.     in      al,dx
  468.     and     al,80h
  469.     mov     ah,al
  470.     mov    cx,8000h    ;Wait 32 768 tries
  471. STALL3:    in    al,dx        ;Keep checking if bit changes
  472.     and     al,80h
  473.     cmp     ah,al
  474.     loope     STALL3
  475.     je     MDAFND
  476.     inc    bx
  477.     cmp    bx, 50        ; make it change over and over
  478.     jb     STALL3
  479.     xor    bx, bx
  480.     jmp    HRCFND
  481. MDAFND:    mov     bx,1    ;MDA start incrementing
  482. HRCFND: inc     bx    ;Different increments for different cards
  483. EGMFND: inc     bx
  484. CGAFND: inc     bx
  485. EGAFND: inc     bx
  486. VGAFND: inc     bx
  487. LOST:   mov    ax,bx
  488.  
  489.     cmp    ax, 3
  490.     jg    VIDEOFOUND
  491.  
  492.     push    ax
  493.     mov    ah, 0fh
  494.     int    10h
  495.     cmp    al, 07h
  496.     pop    ax
  497.     je    VIDEOFOUND
  498.  
  499. ;    vga, ega, or cga display found
  500.  
  501.     push    ax
  502.     mov    ah, 0fh
  503.     int    10h
  504.  
  505. ;    now current page is in bh
  506.  
  507.     mov    ax, 100h
  508.     mul    bh
  509.     add    ax, 0b800h
  510.     mov    video_seg, ax
  511.     pop    ax
  512.  
  513. VIDEOFOUND:
  514.  
  515.     pop    es
  516.     pop    di
  517.  
  518.            ret
  519.  
  520. getga    ENDP
  521.  
  522. ;-----------------------------------------------------------
  523.  
  524. getnumh        proc        near
  525.  
  526. ; detects number of hard disks 
  527. ; returns value in ax
  528.  
  529.     push    di
  530.     push    es
  531.  
  532.     mov    ah, 8
  533.     mov    dl, 80h
  534.     int    13h
  535.  
  536.     jnc    NHOKAY
  537.     xor    ax, ax
  538.     jmp    short    NHEXIT
  539. NHOKAY:
  540.     mov    al, dl
  541.     xor    ah, ah
  542.  
  543. NHEXIT:
  544.     pop    es
  545.     pop    di
  546.     ret
  547.  
  548. getnumh    ENDP
  549.  
  550. ;-----------------------------------------------------------
  551. _machine_detect    proc    near
  552.  
  553. ; void machine_detect (struct mcfig*);
  554. ; Detects processor speed and type, fpu, and graphics type, number
  555. ; of hard disks.
  556.  
  557.     mac_d        struc
  558.     mdbptr        dw    ?
  559.     mdraddr        dw    ?
  560.     mdhandle    dw    ?
  561.     mac_d        ends
  562.  
  563.  
  564. ; structure equates
  565.  
  566. graphics_type    equ    word ptr [di+15]
  567. proc_type    equ    word ptr [di+17]
  568. fpu_type    equ    word ptr [di+19]
  569. MHz        equ    word ptr [di+21]
  570. num_hard    equ    word ptr [di+23]
  571.  
  572. mdframe        equ    [bp-mdbptr]
  573.  
  574.     push     bp        ; Stack frame manipulations
  575.     mov     bp,sp
  576.     sub    sp,mdbptr
  577.     push    di
  578.     push    es
  579.  
  580.     push    ds
  581.     pop    es
  582.     mov    ax, mdframe.mdhandle
  583.     mov    di, ax
  584.  
  585. ; call detector routines
  586. ; all routines but getmhz and getfpu take no arguments and return value in ax
  587.  
  588.  
  589.     call    getga
  590.     mov    graphics_type, ax
  591.  
  592.     call    getproc
  593.     mov    proc_type, ax
  594.  
  595.     push    ax
  596.  
  597. ; getfpu and getmhz take proc_type in ax, so must follow getproc
  598.  
  599.     call    getfpu
  600.     mov    fpu_type, ax
  601.  
  602.     pop    ax
  603.  
  604.     call    getmhz
  605.     mov    MHz, ax
  606.  
  607.     call    getnumh
  608.     mov    num_hard, ax
  609.  
  610.     pop    es
  611.     pop    di
  612.         pop    bp
  613.            ret
  614.  
  615. _machine_detect    ENDP
  616.  
  617. ;-----------------------------------------------------------
  618.  
  619. _disk_check    proc    near
  620.  
  621. ; int disk_check (int drive number, int capcheckflag);
  622. ;
  623. ; given 1-based drive number returns 1 or zero based on the following:
  624. ; If the drive is not ready or invalid, return -1.
  625. ; If the drive is a floppy, return FLOPPY_KBYTES_REQD if 
  626. ; space is available; 0 if not.
  627. ; If the drive is a hard drive, return HD_KBYTES_REQD if space is 
  628. ; available; 0 if not.
  629. ;
  630. ; if capcheckflag == 0, do not ready or invalid check only.
  631. ;
  632. ;
  633.  
  634. FLOPPY_BYTES_REQD    equ    500
  635. HD_BYTES_REQD        equ    2000
  636.  
  637.     driv_ck        struc
  638.     dcbptr        dw    ?
  639.     dcraddr        dw    ?
  640.     drivnum        dw    ?
  641.     dcapflag    dw    ?
  642.     driv_ck        ends
  643.  
  644. ; structure equates
  645.  
  646. dcframe        equ    [bp-dcbptr]
  647.  
  648.     push     bp        ; Stack frame manipulations
  649.     mov     bp,sp
  650.     sub    sp,dcbptr
  651.     push    ds
  652.     push    es
  653.     push    di
  654.  
  655. ; determine if fixed or floppy using dos-free ioctl
  656.  
  657.     mov    ax, 4408h
  658.     mov    bx, dcframe.drivnum
  659.     int    21h
  660.  
  661.     jc    DCNOTRMV
  662.     cmp    al, 1
  663.     je    DCNOTRMV
  664.  
  665. ; check for drive not ready errors using bios, so no Abort,... message
  666. ; first get a buffer
  667.  
  668.     mov    bx, 33    ; paranoia
  669.     mov    ah, 48h
  670.     int    21h
  671.     jnc    DC_GOT_MEMORY
  672.     mov    ax, -1
  673.     jmp    DCEXIT
  674.  
  675. DC_GOT_MEMORY:
  676.  
  677.     mov    es, ax
  678.     mov    cx, 3
  679.  
  680. DC_TRYAGAIN:
  681.     xor    bx, bx
  682.     mov    dx, dcframe.drivnum
  683.     xor    dh, dh
  684.     dec    dl
  685.     push    cx
  686.     mov    cx, 1
  687.     mov    ax, 0401h        ; verify sector 0, cyl 0, head 0
  688.     int    13h
  689.     pop    cx
  690.     jnc    DCDRIVEREADY
  691.     xor    ah, ah
  692.      int    13h            ; reset before trying again
  693.     loop    DC_TRYAGAIN
  694.  
  695. ; lose
  696.     mov    ah, 49h
  697.     int     21h
  698.     mov    ax, -1
  699.     jmp     short    DCEXIT
  700.  
  701. DCDRIVEREADY:
  702.  
  703.     mov    ah, 49h    ; deallocate memory
  704.     int     21h
  705.  
  706. DCNOTRMV:
  707.  
  708. ; stop here if you don't care about capacity
  709.  
  710.     mov    ax, dcframe.dcapflag
  711.     cmp    ax, 0
  712.     jne    DCCONTINUE
  713.     mov    ax, 1
  714.     jmp    short    DCEXIT
  715.  
  716. DCCONTINUE:
  717. ; dos check
  718.  
  719.     push    ds
  720.     mov    ah, 1ch
  721.     mov    dx, dcframe.drivnum
  722.     int    21h
  723.  
  724. ; return -1 on error
  725.  
  726.     cmp    al, 0ffh
  727.     jne    DCNOERR
  728.     cbw
  729.     pop    ds
  730.     jmp    short    DCEXIT
  731. DCNOERR:
  732.  
  733. ; is this is a floppy?
  734.  
  735.     mov    bl, [ds:bx]
  736.     pop    ds
  737.  
  738.     cmp    bl, 0f8h
  739.     je    DCHARD
  740.  
  741. ; is it a 360k or non-standard (720k 5.25) drive?
  742.  
  743.     cmp    bl, 0fch
  744.     jl    DCFLOPOK
  745.     xor    ax, ax
  746.     jmp    short    DCEXIT
  747.  
  748. DCFLOPOK:
  749.     mov    bx, FLOPPY_BYTES_REQD
  750.     jmp    short CAPCHECK
  751. DCHARD:
  752.     mov    bx, HD_BYTES_REQD
  753. CAPCHECK:
  754.     push    bx    ; return value, eventually
  755.  
  756.     mov    ax, 1024
  757.     mul    bx
  758.  
  759.     mov    cap_reqd, ax
  760.     mov    cap_reqd+2, dx    ; save required bytes
  761.  
  762.     mov    ah, 36h
  763.     mov    dx, dcframe.drivnum
  764.     int    21h
  765.  
  766. ; determine if space is available
  767.  
  768.     push    bx    ; clusters available
  769.     push    ax    ; sectors per cluster
  770.     push    cx    ; bytes per sector
  771.  
  772.     mov    dx, cap_reqd+2
  773.     mov    ax, cap_reqd
  774.  
  775.     pop    bx    ; bytes per sector
  776.     div    bx    ; should leave the result a word for all reasonable 
  777.             ; space required (up to 32 megs at 512 bytes/sec)
  778.     xor    dx,dx
  779.     pop    bx    ; sectors per cluster
  780.     div    bx
  781.  
  782.     xor    dx, dx
  783.     pop    bx    ; clusters available
  784.     cmp    bx, 0
  785.     je    DCLOSER
  786.     div    bx
  787.  
  788. ; as long as ax is zero, we're fine
  789.  
  790.     cmp    ax, 0
  791.     jne    DCLOSER
  792.  
  793.     pop    ax
  794.     jmp    short    DCEXIT
  795.  
  796. DCLOSER:
  797.     pop    ax        ; bytes reqd - don't need now
  798.     xor    ax, ax
  799. DCEXIT:
  800.  
  801.     pop    di
  802.     pop    es
  803.     pop    ds
  804.     pop    bp
  805.            ret
  806. _disk_check    ENDP
  807.  
  808. ;___________________________________________________________________
  809.  
  810.  
  811. _get_default    proc    near
  812.  
  813. ; int get_default (void);
  814. ;
  815. ; Get default drive
  816.  
  817.     def_drive    struc
  818.     ddbptr        dw    ?
  819.     ddraddr        dw    ?
  820.     def_drive    ends
  821.  
  822. ; structure equates
  823.  
  824. ddframe        equ    [bp-ddbptr]
  825.  
  826.     push     bp        ; Stack frame manipulations
  827.     mov     bp,sp
  828.     sub    sp,ddbptr
  829.  
  830.     mov    ah, 19h
  831.     int    21h
  832.  
  833.     xor    ah, ah
  834.  
  835.     pop    bp
  836.            ret
  837. _get_default    ENDP
  838.  
  839. ;___________________________________________________________________
  840.  
  841.  
  842. _set_default    proc    near
  843.  
  844. ; void set_default (int);
  845. ;
  846. ; Get default drive
  847.  
  848.     sdef_drive    struc
  849.     sdbptr        dw    ?
  850.     sdraddr        dw    ?
  851.     sddrive        dw    ?
  852.     sdef_drive    ends
  853.  
  854. ; structure equates
  855.  
  856. sdframe        equ    [bp-sdbptr]
  857.  
  858.     push     bp        ; Stack frame manipulations
  859.     mov     bp,sp
  860.     sub    sp,sdbptr
  861.  
  862.     mov    ah, 0eh
  863.     mov    dx, sdframe.sddrive
  864.     int    21h
  865.  
  866.     pop    bp
  867.            ret
  868. _set_default    ENDP
  869.  
  870.  
  871. ;-----------------------------------------------------------
  872. _getpath    proc    near
  873.  
  874. ; void getpath (int drive, char * bufptr);
  875. ;
  876. ; Get current path
  877.  
  878.     g_path        struc
  879.     gpbptr        dw    ?
  880.     gpraddr        dw    ?
  881.     gpdrive        dw    ?
  882.     gp_pptr        dw    ?
  883.     g_path        ends
  884.  
  885. ; structure equates
  886.  
  887. gpframe        equ    [bp-gpbptr]
  888.  
  889.     push     bp        ; Stack frame manipulations
  890.     mov     bp,sp
  891.     sub    sp,gpbptr
  892.     push    si
  893.  
  894.     mov    dx, gpframe.gpdrive
  895.     inc    dl        ; make it 1-based
  896.     mov    ax, gpframe.gp_pptr
  897.     mov    si, ax
  898.  
  899.     mov    ah, 47h
  900.     int    21h
  901.  
  902.     pop    si
  903.     pop    bp
  904.            ret
  905. _getpath    ENDP
  906.  
  907. ;-----------------------------------------------------------
  908. _cdir    proc    near
  909.  
  910. ; int cdir (char * path);
  911. ;
  912. ; Change directories
  913.  
  914.     c_dir        struc
  915.     chdbptr        dw    ?
  916.     chdraddr    dw    ?
  917.     chd_pptr    dw    ?
  918.     c_dir        ends
  919.  
  920. ; structure equates
  921.  
  922. chdframe        equ    [bp-chdbptr]
  923.  
  924.     push     bp        ; Stack frame manipulations
  925.     mov     bp,sp
  926.     sub    sp,chdbptr
  927.  
  928.     mov    dx, chdframe.chd_pptr
  929.     xor    bx, bx
  930.  
  931.     mov    ah, 3bh
  932.     int    21h
  933.     adc    bx, 0
  934.     not    bl
  935.     and    bl, 1
  936.     mov    ax, bx
  937.  
  938.     pop    bp
  939.            ret
  940. _cdir    ENDP
  941.  
  942. ;-----------------------------------------------------------------
  943. _click    proc    near
  944.  
  945. PPI_61        equ    61h        ; -enable keyboard or
  946.                     ; +clear keyboard (bit 7)
  947. ;
  948. ; void click( void);
  949. ;
  950.     clik        struc
  951.     clkbptr        dw    ?
  952.     clkraddr    dw    ?
  953.     clik        ends
  954.  
  955. ; structure equates
  956.  
  957. clkframe        equ    [bp-clkbptr]
  958.  
  959.     push     bp        ; Stack frame manipulations
  960.     mov     bp,sp
  961.     sub    sp,clkbptr
  962.  
  963. ; Make a keyclick
  964.  
  965.     mov    bx,08
  966.  
  967. click_loop:
  968.     in    al,PPI_61
  969.     or    al,2            ; Speaker on
  970.     out    PPI_61,al
  971.     mov    cx,0060
  972. click1:
  973.     loop    click1
  974.     and    al,0fdh            ; Speaker off
  975.     out    PPI_61,al
  976.     mov    cx,0060
  977. click2:
  978.     loop    click2
  979.     dec    bx
  980.     jnz    click_loop
  981. click_out:
  982.     pop    bp
  983.     ret
  984.  
  985. _click    endp
  986. ;-----------------------------------------------------------
  987.  
  988. _text    ends
  989.     END
  990.  
  991.