Skip to main content

Absolute Disk Read


Absolute Disk Read
;
; 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 the last 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,  & so on.
;

; Returns: NULL if the operation is successful.
; otherwise, error codes are as follows:
;
; hex 80 Attachment failed to respond.
; hex 40 SEEK operation failed.
; hex 20 Controller failure.
; hex 10  Bad CRC on diskette read.
; hex 08 DMA overrun on operation.
; hex 04 Requested sector not found.
; hex 03 Write attempt on write-protected diskette.
; hex 02 Address mark not found.
; hex FF Unspecified (error other than those above).
;
code segment byte public ;segment registers remain intact
assume cs:code ;all other registers will be destroyed
public getsec

getsec: push bp ;save old frame pointer
mov bp,sp ;get new frame pointer
mov ax,4[bp] ;put 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] ;pointer 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 ;detect 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 AL only
popf ;remove flags int 0x25 left on stack
pop bp ;restore original frame pointer
ret ;all done

code ends
end

Popular posts from this blog

What is iostream.h in C++ Programing Language ?

In C++ programing language, all header files end with .H extension. In standard C++, all devices are accessed and used as a file.  One such header file is iostream.h in C++ programming language. In this, all input and output devices are treated as files.  Let's quickly look at what are the input and output devices mean in C++ program.  Standard Input Device - Keyboard  Standard Output Device   - Monitor  Standard Error Device - Screen or monitor In C++, input and output are not defined within, and are implemented with the help of a component of the C++ standard library which is I/O library.  A file is read simply as a stream of bytes at the lowest level. But at a user level, a file consists of possibly mixed data types which can be characters, arithmetic values class, objects etc.  What are the predefined streams in I/O Library? As discussed above there are input, output and error library in c++, they have some predefined streams objects as well w...

C++ Program to find the sum, difference, product and quotient of two integers

#include <iostream.h> #include <conio.h> void main() {   clrscr();   int x = 10;   int y = 2;   int sum, difference, product, quotient;   sum = x + y;   difference = x - y;   product = x * y;   quotient = x / y;   cout << "The sum of " << x << " & " << y << " is " << sum << "." << endl;   cout << "The difference of " << x << " & " << "y <<  is " << difference << "." << endl;   cout << "The product of " << x << " & " << y << " is " << product << "." << endl;   cout << "The quotient of " << x << " & " << y << " is " << quotient << "." << endl;   getch(); }

What is Dynamic Memory Allocation in C++ Program

In the computer world, anything that is processed be it an instruction or any data first needs to be loaded and located in internal memory.  In C++ programs also any data that is processed while executing the program is held in the internal memory.  What is Dynamic Memory Allocation? Dynamic Memory allocation means that the memory that will be used during the program is not known beforehand and is allocated dynamically and on the go. It is allocated during the runtime as and when required by the program. In C++ there are two operators used in dynamic memory allocation  1. New  2. Delete New operator in dynamic memory allocation The new operator in C++ is used to create objects of all types. The new operator will allocate memory of the size of the data type specified in the program.  For Example iptr = new int ;  Storing initial values will allocate needed amount of memory from the free store to hold the value of the specified data-type and store the startin...