This is the past DOS era of the compilation of source code, although has passed, but for the study of the assembly is still helpful, assembly language is just a basic programmer language, most people can grasp, not necessarily in-depth research.
; Absolute Disk read:getsec (uses BIOS interrupt 0x25)
;
; Interfaces to Computer innovations C-86 "C" Compiler V1.32 (& later)
; The DOS 2.10 Technical Reference page 5-10, and technical Reference
; Page A-32. This code is written by Mike Sirmans (05-25-84).
; --------------------------------------------------------------------
; This routine is powerful. (And as SUCH, is dangerous in the wrong
; Hands). Being careful how to use IT. I assume NO responsibility.
; --------------------------------------------------------------------
;
; Synopsis:int getsec (Drive,numsec,begsec,buffer)
; unsigned int drive; * * 0=a, 1=b, etc.
; unsigned int numsec; /* Number of sectors to read * *
; unsigned int begsec; /* Beginning Logical sector * *
; Char *buffer; /* Transfer Address * *
;
; Function:the number of sectors specified are transferred
; Between the given drive and the transfer address.
; LOGICAL sector NUMBERS are obtained by numbering
; Each sector sequentially starting from track 0, head 0,
; Sector 1 (logical sector 0) and continuing along the
; Same head, then to the next head until sector
; On the ' last head ' of the track is counted. Thus,
; Logical sector 1 is track 0, head 0, Sector 2,
; Logical Sector 2 is track 0, head 0, Sector 3, &.
;
; Returns:null If the operation is successful.
; Otherwise, error codes are as follows:
;
; Hex attachment failed to respond.
; Hex Seek operation failed.
; Hex Controller failure.
; Hex Bad CRC on diskette read.
; Hex the DMA overrun on operation.
; Hex requested sector not found.
; Hex Write attempt on write-protected diskette.
; Hex address mark not found.
; Hex FF Unspecified (Error other than those above).
;
code segment byte public; segment registers remain intact
Assume Cs:code all the other registers would be destroyed
Public getsec
Getsec:push BP; save Old frame pointer
mov bp,sp; get new frame pointer
MOV AX,4[BP];p ut drive number into AL
XOR Ah,ah
MOV cx,6[bp]; Number of sectors to fetch
MOV DX,8[BP]; logical record number of 1st sector
mov bx,10[bp];p ointer to transfer address
int 25h; BIOS Call
JC Error; Error has occurred if carry flag = 1
MOV al,00h; NULL to indicate sucessful completion
JMP Done
error:cmp al,00h;d etect Unspecified error code 00H
Jne done .... Change to 0FFh if found to
MOV al,0ffh; differentiate it from success code
Done:xor Ah,ah; return to AL only
Popf Remove Flags int 0x25 left on stack
Pop bp; restore original frame pointer
a ret;
Code ends
End