home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / Geneve / 9640news / CAT09 / TIEXE.ZIP / SECTOR.ASM < prev    next >
Assembly Source File  |  1987-02-03  |  2KB  |  65 lines

  1. title    DISK SECTOR FUNCTIONS
  2. subttl   by Jerome Gobuyan
  3. name     sector
  4. include  dos.mac
  5.          if    lprog
  6. x        equ   6
  7.          else
  8. x        equ   4
  9.          endif
  10.          pseg
  11. ;
  12. ; name         sectread -- read a sector from disk
  13. ;
  14. ; synopsis     ret = sectread(d,c,h,r,buffer);
  15. ;              int ret;
  16. ;              int d,c,h,r;
  17. ;              struct byte *buffer;
  18. ;
  19. ; description  This function reads one sector from the disk.
  20. ;              D is the drive number
  21. ;              C is the cylinder number
  22. ;              H is the head number
  23. ;              R is the sector number
  24. ;              ret = 0 if successful
  25. ;                    disk error code if not
  26. ;
  27.          public sectread
  28.          if lprog
  29. sectread proc  far
  30.          else
  31. sectread proc  near
  32.          endif
  33.          push  bp
  34.          mov   bp,sp
  35.          push  es
  36.          mov   ax,[bp+x]     ;get drive number
  37.          mov   dl,al
  38.          mov   ax,[bp+x+2]   ;get cylinder number
  39.          mov   ch,al
  40.          mov   ax,[bp+x+4]   ;get head number
  41.          mov   dh,al
  42.          mov   ax,[bp+x+6]   ;get sector number
  43.          mov   cl,al
  44.          mov   bx,[bp+x+8]   ;get buffer offset
  45.                              ;get buffer segment
  46.          if    ldata
  47.          mov   ax,[bp+x+10]
  48.          mov   es,ax
  49.          else
  50.          push  ds
  51.          pop   es
  52.          endif
  53.          xor   ax,ax
  54.          int   13H
  55.  
  56.          mov   ax,0201H      ;get ready for read
  57.          int   13H
  58.          xchg  ah,al
  59.          pop   es
  60.          pop   bp
  61.          ret
  62. sectread endp
  63.          endps
  64.          end
  65.