home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / SOURCE / IBMLIB / SY_DRIVE.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-09-25  |  3.9 KB  |  202 lines

  1. ;
  2. ;  sy_drive.asm
  3. ;
  4. ;  Purpose:
  5. ;
  6. ;  Sterling Castle Library Functions
  7. ;  (c) Copyright 1985,1989 Sterling Castle Software
  8. ;
  9.  
  10.     include model
  11.     include blackstr.mac
  12.  
  13.     extrnf free
  14.     extrnf malloc
  15.  
  16.  
  17.     dseg    'DATA'
  18.  
  19.     public _doserr_
  20.  
  21.     SECSIZE equ     512             ;disk sectore size
  22.     msdosf    equ    21h        ;msdos function call
  23.  
  24.     ifdef   asm_386
  25.     alias           doserr_,DWORD
  26.     _doserr_        dd 00           ;dos fatal error code
  27.  
  28.     else
  29.     alias           doserr_,WORD
  30.     _doserr_        dw 00           ;dos fatal error code
  31.     endif
  32.  
  33.     enddseg
  34.  
  35.  
  36.     cseg    sy_getint_
  37.  
  38. ;-------------------------
  39. ;       sy_getint_(vec,ptr)     get interrupt vec to vector ptr
  40. ;--------------------------
  41. ;                               vector address in ebx:ecx
  42. ;                               Usage: sy_getint_(vec,p);
  43. ;
  44. ;                               int sy_getint_(int vec, int *p);
  45.  
  46.     public  sy_getint_
  47.  
  48. sy_getint_ proc
  49.     parm386<<vec,dword>,<p,ptr>>
  50.     parm86<<vec,word>,<p,ptr>>
  51.     prolog
  52.     push    es
  53.  
  54.     mov     eax,vec         ;get vector number to get
  55.     mov     ah,35h
  56.     int     21h
  57.  
  58.     loadptr lds,esi,p
  59.  
  60.     ifdef   asm_386
  61.     mov     dword ptr[esi],ebx
  62.     mov     [esi+4],es
  63.  
  64.     else
  65.     mov     [si],bx
  66.     mov     [si+2],es
  67.     endif
  68.  
  69.     pop     es
  70.  
  71.     ifdef    asm_386
  72.     movsx    eax,ax
  73.     endif
  74.  
  75.     epilog
  76. sy_getint_ endp
  77.  
  78.  
  79. ;-------------------------
  80. ;       sy_setint_(int,vect)    set interrupt int to vector vect
  81. ;--------------------------
  82. ;                               int number in al
  83. ;                               vector address in ebx:ecx
  84. ;                               Usage: sy_setint_(vec,off,seg);
  85. ;
  86. ;                               int sy_setint_(int vec, int off, int seg);
  87.  
  88.     public  sy_setint_
  89.  
  90. sy_setint_ proc
  91.     parm386<<vect,dword>,<off,dword>,<segm,word>>
  92.     parm86<<vect,word>,<off,word>,<segm,word>>
  93.     prolog
  94.     push    ds
  95.  
  96.     mov     eax,vect        ;get interrupt number to set
  97.     mov     edx,off         ;vector offset
  98.     mov     cx,segm         ;get segment
  99.     mov     ds,cx           ;vector segment
  100.  
  101.     mov     ah,25h          ;set int command
  102.     int     msdosf          ;do function interrupt
  103.  
  104.     pop     ds
  105.  
  106.     ifdef    asm_386
  107.     movsx    eax,ax
  108.     endif
  109.  
  110.     epilog
  111. sy_setint_ endp
  112.  
  113.  
  114. ;------------------------
  115. ;       sy_isdrive_(drno)       check for drive available
  116. ;-----------------------
  117. ;                               Usage: sy_isdrive_(drno);
  118. ;
  119. ;                               int sy_isdrive_(int drno);
  120. ;
  121.  
  122.     public  sy_isdrive_
  123.  
  124. sy_isdrive_ proc
  125.     parm386<<drno,dword>>
  126.     parm86<<drno,word>>
  127.     prolog
  128.  
  129.     ifdef   Large_data
  130.     push    es
  131.     endif
  132.  
  133.     mov     eax,SECSIZE     ;sector size
  134.     push    eax
  135.     call    malloc
  136.     add     esp,Word_size
  137.  
  138.     ifdef   Large_data
  139.     mov     es,dx           ;get segment
  140.     endif
  141.  
  142.     mov     ebx,eax         ;buffer pointer
  143.     mov     eax,drno        ;drive number
  144.     mov     ecx,1           ;read 1 sector
  145.     mov     edx,0           ;start at sector 0
  146.  
  147.     ifdef   Large_data
  148.     push    es              ;segment onto stack
  149.     endif
  150.  
  151.     push    ebx             ;save buffer pointer
  152.     push    ds
  153.     mov     ds,dx           ;segment from malloc
  154.  
  155.     int     25h             ;absolute read
  156.     pop     ds
  157.     mov     esi,01          ;assume it is there
  158.     jnc     isdr_x
  159.  
  160.     mov     esi,0           ;drive is not there
  161.  
  162. isdr_x: pop     edx             ;adjust for dos
  163.     call    free
  164.     add     esp,Word_size
  165.     mov     eax,esi         ;drive flag back
  166.  
  167.     ifdef   Large_data
  168.     pop     es
  169.     endif
  170.  
  171.     epilog
  172. sy_isdrive_ endp
  173.  
  174.  
  175. ;--------------
  176. ;   _dummyi24_        fatal error routine to return only
  177. ;---------------
  178.  
  179.     public  _dummyi24_
  180.  
  181. _dummyi24_ proc
  182.     ifdef   Large_data
  183.     push    ds
  184.     mov     ax,seg _doserr_
  185.     mov     ds,ax
  186.     endif
  187.  
  188.     mov     _doserr_,edi    ;save the error #
  189.     and     _doserr_,0fh    ;mask it
  190.     mov     al,0            ;ignore the error
  191.  
  192.     ifdef   Large_data
  193.     pop     ds
  194.     endif
  195.  
  196.     iret                    ;and return
  197. _dummyi24_ endp
  198.  
  199.     endcseg sy_getint_
  200.     end
  201.  
  202.