home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / fileutil / dcopy12.arj / WSECM.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-09-12  |  1.6 KB  |  35 lines

  1. ; WSECM: Routine to write disk sectors directly using the DOS interrupt.
  2. ; Designed to be called from Microsoft C, using the medium model.
  3. ; int wsecm(char *data,unsigned drive,unsigned sector,unsigned numsec);
  4. ; The error value returned has the ROM BIOS error code in the low byte, and the
  5. ; critical error handler code in the high byte.  Bit 0 is 1 on error.
  6. ; Assemble with the /MX option for lower case: masm /MX wsecm;
  7. ; See Norton Page 251.
  8. .MODEL MEDIUM
  9. .CODE
  10.         PUBLIC  _wsecm
  11. _wsecm  PROC
  12.         PUSH    BP              ; Save old BP
  13.         MOV     BP,SP
  14.         PUSH    DI              ; C requires DI and SI to be saved
  15.         PUSH    SI              ; (and DS and SS)
  16.         MOV     BX,[BP+6]       ; Data address
  17.         MOV     AX,[BP+8]       ; Drive
  18.         MOV     DX,[BP+10]      ; Sector number
  19.         MOV     CX,[BP+12]      ; Number of sectors
  20.         INT     26H             ; DOS absolute disk write interrupt
  21.         JNB     OK              ; Carry clear?
  22.         MOV     BL,AH           ; Return with ROM BIOS error value
  23.         MOV     BH,AL           ; Return with critical error handler code
  24.         OR      BL,1            ; Ensure an error is signalled
  25.         MOV     AX,BX
  26.         JMP     FIN
  27. OK:     MOV     AX,0            ; Signal no error
  28. FIN:    POPF                    ; Discard extra word on stack
  29.         POP     SI              ; Restore DI and SI
  30.         POP     DI
  31.         POP     BP              ; Restore BP
  32.         RET                     ; C removes parameters on stack itself
  33. _wsecm  ENDP
  34.         END
  35.