home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progbas / qbnws103.arj / ASMREQ.ZIP / DOSVER.ASM next >
Encoding:
Assembly Source File  |  1990-02-16  |  2.5 KB  |  55 lines

  1. ; DOSVER.ASM  example routine for linking assembler routines to QuickBASIC
  2.  
  3. ; Calling syntax: CALL DOSVER(VERSION$, MAJORV%, MINORV%)
  4. ;   location on the stack:        10       8       6
  5.  
  6.  
  7. public DOSVER       ; this makes the routine name callable from QuickBASIC
  8.  
  9. .model medium       ; this sets things up properly for use with QuickBASIC
  10. .CODE
  11.  
  12.  
  13. DOSVER        proc           far
  14.               push           bp             ; save old BP value
  15.               mov            bp,sp          ; BP now points to the parameters
  16.  
  17.               mov            ah,30h         ; function to get the DOS version
  18.               int            21h            ; execute the function
  19.  
  20. ; we now have the major version number in AL
  21. ; ...and the minor version number in AH
  22.  
  23.               mov            cl,ah          ; put minor version # in CL
  24.               mov            ch,0           ; convert from a byte to a word
  25.               mov            ah,0           ; convert AL from byte to word
  26.  
  27.               mov            bx,6[bp]       ; get the address of MINORV%
  28.               mov            [bx],cx        ; return the minor version number
  29.  
  30.               mov            bx,8[bp]       ; get the address of MAJORV%
  31.               mov            [bx],ax        ; return the major version number
  32.  
  33.               mov            bx,10[bp]      ; get address of the string info
  34.               cmp word ptr   [bx],4         ; is VERSION$ long enough?
  35.               jb             Done           ;   no, it's too short-- exit
  36.  
  37.               mov            bx,2[bx]       ; get address of VERSION$ itself
  38.  
  39.               add            al,"0"         ; convert major version # to ASCII
  40.               mov            [bx],al        ; store it in VERSION$
  41.               inc            bx             ; move to the next character
  42.               mov byte ptr   [bx],"."       ; store decimal point in VERSION$
  43.               inc            bx             ; move to the next character
  44.               mov            al,cl          ; put the minor version in AL
  45.               aam                           ; convert to digits in AL and AH
  46.               xchg           al,ah          ; put digits in correct order
  47.               add            ax,"00"        ; convert minor version # to ASCII
  48.               mov            [bx],ax        ; store it in VERSION$
  49.  
  50. Done:         pop            bp             ; restore old BP value
  51.               ret            6              ; return (2 * three parameters)
  52. DOSVER        endp
  53.  
  54.               end
  55.