LSA Disk Sector Read - using int 13h ah 42 (extended read)



I'm just messing around here trying to learn how some of this low level
stuff works, and to my surprise I can not find a working example any
where...

Can someone please help. I'm about to pull my hair out!
I'm using visual studio 1.52 to compile my 16 bit code. I'm doing C
with inline ASM.
Note: I called check_extensions and extension are on my computer.

When i compile and run the following code bError prints out "0" so that
is no error i think? Yet when i print out my buffer the buffer is all
0's which i know is wrong because i have another functions that read
the MBR in with CHS format call and then it prints out the mbr just
fine. Any ideas?


struct disk_packet //needed for int13 42h
{
BYTE size_pack; //size of packet must be 16 or 16+
BYTE reserved1; //reserved
BYTE no_of_blocks; //no:of blocks for transfer
BYTE reserved2; //reserved
WORD offset; //offset address
WORD segment; //segment address
DWORD lba1;
DWORD lba2;
} disk_pack;

void LBASectorRead(void *buffer, unsigned long lba )
{
unsigned char bError = 0;
disk_pack.size_pack=16; //set size to 16
disk_pack.no_of_blocks=1; //1 block ie read one sector
disk_pack.reserved1=0; //reserved word
disk_pack.reserved2=0; //reserved word
disk_pack.segment=FP_SEG(buffer); //segment of buffer
disk_pack.offset=FP_OFF(buffer); //offset of buffer
disk_pack.lba1=0; //lba first 32 bits
disk_pack.lba2=0; //last 32 bit address

_asm
{
mov dl, 80h;
mov [disk_pack.segment], ds;
mov si, disk_pack;
mov ah, 42h;
int 13h
jc NoError ; //No error, ignore error code
mov bError, ah ; // Error, get the error code
NoError:
}

printf( "%d", bError);

}

int main(void)
{
static unsigned char currentMBR[SECTOR_SIZE] = {0};
printf("\n\n");
LBASectorRead(currentMBR );
PrintSector(currentMBR); //function to print buffer in hex
}

.



Relevant Pages

  • Re: pause simple but usefull
    ... See below my own full use of INT 16H to wait, ... mov ah,00h ... above clears the keyboard buffer ... ; print second prompt ...
    (alt.lang.asm)
  • Re: Make a string of Single chars
    ... The user can input some characters via ... > mov ah,02h ... Maybe it's worth noting that int 16h/0 and int 16h/1 are the XT ... valid characters into a buffer. ...
    (comp.lang.asm.x86)
  • Re: LSA Disk Sector Read - using int 13h ah 42 (extended read)
    ... When i compile and run the following code bError prints out "0" so that ... Yet when i print out my buffer the buffer is all ... int main ... Doors - Dont look at the future in a window. ...
    (comp.lang.asm.x86)
  • Re: Need Help.
    ... mov dh,1 ... int 10h ... buffer filled with user input ... number of characters actually read, ...
    (comp.lang.asm.x86)
  • Re: pause simple but usefull
    ... buffer when we want to pause... ... mov ah,00h ... above clears the keyboard buffer ...
    (alt.lang.asm)