home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / modem / byepc300.arc / BYEXLIB.ARC / CHKBYE.ASM < prev    next >
Assembly Source File  |  1987-10-25  |  3KB  |  90 lines

  1.            INCLUDE MODEL.INC
  2. ;
  3. ;---------------------------------------------------------------------------
  4. ;   Function:    int _bye_check(ver, rev)
  5. ;
  6. ;   Parms:    int ver = lowest version# acceptable
  7. ;        int rev = lowest revison# acceptable
  8. ;
  9. ;   Purpose:    Test to see if BYE-PC is loaded before executing
  10. ;        any other functions. Prevents a system crash!!!
  11. ;        If you call any other functions that call BYE-PC
  12. ;        interrupt 66h, before '_bye_check() == 1' the system
  13. ;        will crash. The interrupt vectors are uninitialized
  14. ;        and contain null or garbage data. This checks to
  15. ;        make sure that BYE-PC has been loaded.
  16. ;
  17. ;   Return:    0 = BYE-PC loaded and is acceptable version/revision
  18. ;        1 = BYE-PC is not loaded yet
  19. ;        2 = BYE-PC is loaded but, invalid version#
  20. ;        3 = BYE-PC is loaded but, invalid revision#
  21. ;---------------------------------------------------------------------------
  22. ;
  23.            PUBLIC __bye_check
  24.  
  25. __bye_check    PROC
  26.  
  27.            push bp            ;standard 'C' function entry
  28.            mov  bp,sp
  29.            push si            ;save index regs
  30.            push di
  31.            push ds            ;save seg regs
  32.            push es
  33. ;
  34. ; Attempt to locate the resident portion using INT16's segment.
  35. ;
  36.            mov  ax,3516h        ;dos get INT16 vector
  37.            int  21h
  38.            mov  bx,0103H        ;.COM file offset
  39.            cmp  BYTE PTR es:[bx], 'B'
  40.            jne  chk_ld
  41.            inc  bx
  42.            cmp  BYTE PTR es:[bx], 'Y'
  43.            jne  chk_ld
  44.            inc  bx
  45.            cmp  BYTE PTR es:[bx], 'E'
  46.            jne  chk_ld
  47. ;
  48. ; Check version version number of BYE-PC already loaded.
  49. ;
  50.            mov  ax,ARG1        ;BH=lowest ver#
  51.            mov  bh,al
  52.            mov  ax,ARG2        ;BL=lowest rev#
  53.            mov  bl,al
  54.  
  55.            push bx
  56.            push cx
  57.            mov  ah,11        ;AH=11 BYE-PC get version
  58.            int  BYE_VECT        ;AH=ver, AL=rev
  59.            pop  cx
  60.            pop  bx
  61.  
  62.            cmp  ah,bh        ;if (bye_ver > ver)
  63.            jg   chk_ok        ;  return(0);
  64.            cmp  ah,bh        ;if (bye_ver < ver)
  65.            jl   chk_ver        ;  return(2);
  66.            cmp  al,bl        ;if (bye_rev < rev)
  67.            jl   chk_ver        ;  return(3);
  68. ;
  69. ; Set the appropriate return code, restore registers, and exit
  70. ;
  71. chk_ok:        xor  ax,ax        ;0 = no error
  72.            jmp  SHORT chk_exit
  73. chk_ld:        mov  ax,1        ;1 = BYE-PC not loaded
  74.            jmp  SHORT chk_exit
  75. chk_ver:       mov  ax,2        ;2 = bad ver number
  76.            jmp  SHORT chk_exit
  77. chk_rev:       mov  ax,3        ;3 = bad rev number
  78.  
  79. chk_exit:      pop  es            ;restore seg regs
  80.            pop  ds
  81.            pop  di            ;restore index regs
  82.            pop  si
  83.            mov  sp,bp        ;standard 'C' exit
  84.            pop  bp
  85.            ret
  86.  
  87. __bye_check    ENDP
  88.            END
  89.  
  90.