home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ABSDISK.ASM < prev    next >
Assembly Source File  |  1997-07-05  |  2KB  |  75 lines

  1. ;  +++Date last modified: 05-Jul-1997
  2.  
  3.         page    55, 132
  4.  
  5. ;
  6. ;  ABSDISK.ASM
  7. ;
  8. ;  Originally published as part of The MicroFirm Function Library
  9. ;  This version released to the public domain by the author, Bob Stout
  10. ;
  11. ;  Requires MASM 5.1 or later or equivalent
  12. ;
  13. ;  Assemble with:       MASM /Mx /z ...
  14. ;                       TASM /jMASM /mx /z ...
  15. ;
  16.  
  17. %       .MODEL  memodel,C               ;Add model support via
  18.                                         ;command line macro,
  19.                                         ;e.g. MASM /Dmemodel=LARGE ...
  20.         extrn   _osmajor:BYTE
  21.         public  absdisk
  22.  
  23.         .DATA
  24. start   dw      ?
  25. fill    dw      0
  26. number  dw      ?
  27. buf     dw      ?,?
  28.  
  29.         .CODE
  30. absdisk PROC USES SI DI BP, func:BYTE, drive:WORD, num_sec:WORD, start_sec:WORD, buffer:PTR
  31.         mov     AX,drive        ;Get drive number in AL
  32.         mov     AH,_osmajor     ;Load OS version in AH
  33.         mov     CX,num_sec      ;Set up regs for DOS 3 call
  34.         mov     DX,start_sec
  35.     IF  @DataSize
  36.         push    DS              ;Save DS in L & C models
  37.         lds     BX,buffer
  38.     ELSE
  39.         mov     BX,buffer
  40.     ENDIF
  41.         cmp     AH,4            ;DOS 4+?
  42.         jb      doint           ;No, skip it
  43.         mov     start,DX        ;Yes, fill in DCB structure
  44.         mov     number,CX
  45.         mov     buf,BX
  46.         mov     buf+2,DS
  47.         mov     cx,-1
  48.     IF  @DataSize               ;Point to DCB
  49.         mov     BX,@Data
  50.         mov     DS,BX
  51.     ENDIF
  52.         mov     bx,OFFSET start
  53. doint:  mov     AH,func         ;Read or Write?
  54.         cmp     AH,25h
  55.         jne     skip_1
  56.         int     25h             ;Read sector
  57.         jmp     skip_3
  58. skip_1: cmp     AH,26h
  59.         jne     skip_2
  60.         int     26h             ;Write sector
  61.         jmp     skip_3
  62. skip_2: stc                     ;Invalid command
  63.         mov     AX,-1
  64. skip_3: jc      bye             ;Error?
  65.         mov     AX,0            ;No, return SUCCESS
  66. bye:    add     SP,2            ;Int 25h leave the flags on the stack
  67.     IF  @DataSize
  68.         pop     DS              ;Restore DS in L & C models
  69.     ENDIF
  70.         ret
  71.  
  72. absdisk ENDP  
  73.  
  74.         end
  75.