read floppy problem

May 24, 2008 1 Replies

Hi , I am writting a program which read a sector from floppy to memroy.here is the code:



SubRoutine_ReadSector: push bp mov bp, sp push ax push bx push cx push dx



mov ax, [bp + 6] ;Sector Number push bx ; mov bl, [BPB_SecPerTrk] ; div bl inc ah mov cl, ah mov dh, al shr al, 1 mov ch, al and dh, 1 pop bx mov dl, [BS_DrvNum] =2EGoOnReading: mov ah, 2 mov al, byte [bp + 4] ; How many sectors. int 13h jc .GoOnReading ;if any problem happend, continue to read.



pop dx pop cx pop bx pop ax pop bp ret 4



After I call this routine, I always get wrong answer. The correct datas on the floppy is:



4C 4F 41 44 45 52 20 20 42 49 4E 20 00 00 00 00 00 00 00 00 00 00 DD B5 35 =85=85 But the actual datas in memory is:
4C 4F 41 44 45 52 42 49 4E 20 00 00 00 00 00 00 00 00 35=85=85

After compare these datas, I found there are some datas lost:



4C 4F 41 44 45 52 20 20 42 49 4E 20 00 00 00 00 00 00 00 00 00 00 DD B5 35
4C 4F 41 44 45 52 42 49 4E 20 00 00 00 00 00 00 00
00 35

Can anyone give me some help?why some datas lost, some not.


Nothing jumps out at me as being wrong.

Run debug.com and enter a very simple program to read the sector in question:

A100

mov al,1 ; sector count mov ah,2 ; read sector function mov bx,1000 ; buffer at 1000h mov cl,1 ; sector 1 mov ch,0 ; cyl 0 mov dl,0 ; drive A mov dh,0 ; head 0 int 13 ; do the read int 3 ; break to debug

Now look at 1000 and see if the sector is good. If so, work your way backwards to fix the problem.

Note that you have to be sure not to cross a 64k dma boundary with your transfer. This means that ES must be equal to or less than

0xFFE0 before the transfer.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required