Reading from a floppy
Posted: Sat Apr 17, 2010 5:29 pm
I'm having trouble doing it. Here is my code:
Its meant to in a very simple manner read FAT12 floppies. However when Int13/AH=02h executes I get error code 20h "controller failure". What is going on here?
Thanks
Code: Select all
start:
mov ax, 0x07C0
mov ds, ax
mov es, ax
mov si,fat ;method of checking if floppy is a FAT
mov al,[si]
cmp al,'F'
jne notfat
inc si
mov al,[si]
cmp al,'A'
jne notfat
inc si
mov al,[si]
cmp al,'T'
jne notfat
read: ;Read first directory table (spfat = sectors per fat table, reserved = # of reserved sectors)
mov cl,[spfat]
add cl,[spfat]
add cl,[reserved]
mov ah,02h
mov al,01h
mov ch,00h
mov dh,01h
mov dl,00h
mov bx,200h
int 13h
cmp ah,80h ;if the floppy is simply busy try again until it isnt
je read
cmp ah,00
jne readerr
mov si,read1
call int_print
mov si,0x7E00
call int_print
jmp final
int_print: ;interrupt based printing
mov AH,0Eh
mov BH,01h
mov AL,[si]
int 10h
inc si
cmp byte [si],0
jne int_print
ret
notfat: ;print nofat error
mov si,nofat
call int_print
jmp final
readerr: ;print read error
mov cl,ah
mov ch,0
mov si,troublereading
call int_print
ror ax,8
mov ah,0Eh
mov bh,01h
ror cx,4
mov al,cl
add al,48
ror cx,8
int 10h
mov cl,0
rol cx,4
mov al,cl
add al,48
int 10h
jmp final
read1 db 'Read1',0Dh,0Ah,0
nofat db 'Err_1',0
troublereading db 'Err_2 Code:',0
Thanks