home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / directry / mv / func32h.asm < prev    next >
Encoding:
Assembly Source File  |  1994-06-05  |  2.8 KB  |  80 lines

  1.  
  2. ; 8-Sep-86 16:13:30-PDT,2449;000000000000
  3. ; Return-Path: <pwu@unix.macc.wisc.edu>
  4. ; Received: FROM UNIX.MACC.WISC.EDU BY B.ISI.EDU WITH TCP ; 8 Sep 86 16:09:00 PDT
  5. ; Received: by unix.macc.wisc.edu;
  6. ;          id AA04966; 4.12/5; Mon, 8 Sep 86 17:31:32 cdt
  7. ; Date: Mon, 8 Sep 86 17:31:32 cdt
  8. ; From: Peter Wu <pwu@unix.macc.wisc.edu>
  9. ; Message-Id: <8609082231.AA04966@unix.macc.wisc.edu>
  10. ; To: info-ibmpc-request@mosis
  11. ; Subject: func32h.asm
  12. ;
  13. ; Call DOS 32H from C. This is an undocumented function call documented in
  14. ; PC Tech. Journal May 1986. This function returns a pointer to a disk
  15. ; description table that contains the following:
  16. ;
  17. ;   offset  length  what
  18. ;   ------  ------  ----
  19. ;      0     byte   assigned physical disk (A=0, B=1, ...)
  20. ;      1     byte   same as above but 0 for RAM disk
  21. ;      2     word   bytes per sector
  22. ;      4     byte   sectors per cluster minus 1
  23. ;      5     byte   #heads minus 1
  24. ;      6     word   reserved sectors
  25. ;      8     byte   #copies of FAT (normally 2 for real disks, 1 for RAM disks)
  26. ;      9     word   max directory entries
  27. ;     11     word   first usable sector (i.e. data area)
  28. ;     13     word   total cluster count plus 1
  29. ;     15     byte   #sectors occupied by each FAT
  30. ;     16     word   first sector of the root's directory
  31. ;     18    dword   device driver address
  32. ;     22     word   media descriptor
  33. ;     24    dword   chain to next disk table
  34. ;     28     word   cluster of current working directory
  35. ;
  36. ; in C, use
  37. ;   unsigned char drv,  /* drive number: 1=A, 2=B, ...; 0=current drive */
  38. ;                 status;  /* if 0xFF means invalid drive */
  39. ;   unsigned short tabseg,  /* disk description table segment */
  40. ;                  taboff;  /* disk description table offset */
  41. ;
  42. ;   status = func32h(drv, &tabseg, &taboff);
  43. ;
  44. ; The reason for writing this procedure in assembly is because the
  45. ; function returns the description table segment address in DS which
  46. ; cannot be accessed by using intdosx() function in C.
  47. ;
  48. ; Written by Peter Wu 6/27/86
  49. ;
  50. _text   segment public byte 'code'
  51.         assume cs:_text
  52.  
  53.         public  _func32h
  54. _func32h proc    near
  55.         push    bp
  56.         mov     bp,sp
  57.         push    ds              ; save DS
  58.  
  59.         mov     dl,[bp+4]       ; drive number
  60.         mov     ah,32h
  61.         int     21h
  62.  
  63.         mov     cx,bx           ; stupid move, but I need bx
  64.         mov     si,ds
  65.         pop     ds
  66.  
  67.         mov     bx,[bp+6]       ; &tabseg
  68.         mov     [bx],si         ; store tabseg
  69.         mov     bx,[bp+8]       ; &taboff
  70.         mov     [bx],cx         ; store taboff
  71.         mov     ah,0            ; al contains ffh if error
  72.  
  73.         pop     bp
  74.         ret
  75. _func32h endp
  76.  
  77. _text   ends
  78.         end
  79.  
  80. ; -------------------------------------------------------------