Page 1 of 1

Problem with reading floppy sectors

Posted: Tue Aug 09, 2005 11:00 pm
by seejohnrun
hey everyone,
the following code i'm using to read a sector from a floppy drive in ASM to load a table of contents for a simple file system. for some reason i just can't get it work right. this is one of the least complex things i've been doing lately, i must just be missing something really stupid.

thanks in advance for any help getting my code to operate properly

what it does:
reads the second sector from the floppy drive
stores it in memory
reads those values out from memory to the screen one by one

thanks!

Code: Select all

  mov si, readingTOC      ;just display a message
  call DisplayMessage  

  mov ah, 02h  ;read the sector i want off the floppy disk
  mov al, 1
  mov ch, 0
  mov cl, 2
  mov dh, 0
  mov dl, 0
  
  mov bx, 0A00h
  mov es, bx
  mov bx, 0
  
  int 13h
  
  mov dx, bx

  startdisplay:

   cmp dx, '?'     ;try to display the contents of that sector which was loaded into memory  
   jz donedisplaying
 
   push bx

   mov ah, 0x0E
   mov bh, 0x00
   mov bl, 0x07
   int 10h
   
   pop bx


   inc dx
   jmp startdisplay
 
   donedisplaying:
    jmp _cmd_done   ;wrap it up

Re: Problem with reading floppy sectors

Posted: Thu Aug 11, 2005 11:00 pm
by Osbios

Code: Select all

;read sector's from disk to 0x500 (using bios int.)
mov ah,0  ;floppy reset
mov dl,0
int 13h

mov ah,02h ;read floppy a:
mov al,((boot_size+511)/512);Number of sectors
mov ch,0   ;?Bottom 8 bits of track number (0-based)
mov cl,2h  ;?ttssssss
           ; tt       = top two bits of 10-bit track number,
           ;   ssssss = 6-bit sector number (1-based).
mov dh,0   ;?Head number (0-based).
mov dl,0   ;Driver number

;adress ES:BX
mov bx,0x50  ;<--Segment
mov es,bx
mov bx,0     ;<--offset = 0
int 13h
^^

Re: Problem with reading floppy sectors

Posted: Thu Aug 11, 2005 11:00 pm
by seejohnrun
I see no difference between that and my code...

Re: Problem with reading floppy sectors

Posted: Thu Aug 11, 2005 11:00 pm
by seejohnrun
I see you did the floppy reset beforehand, but i've been doing that beforehand as well... AHHH

Re: Problem with reading floppy sectors

Posted: Thu Aug 11, 2005 11:00 pm
by seejohnrun
Just for a point of reference and update, here's my latest attempt, which still fails

Code: Select all

	
        call readdisk   ;read the disk a couple times to allow spin-up time
	call readdisk
	call readdisk
	call readdisk
	call readdisk

	DisplayTOC:


	MOV AL, [bx]       ;read into memory and display
	CMP AL, 0x3f
	JZ EndDisplay

	push BX          ;save bx (memory address)

	MOV AL, [BX]
	mov ah, 0x0A
	mov bl, 0x07
	int 10h

	pop BX

	INC BX

	jmp DisplayTOC 
	
	EndDisplay:  THE END!   
is the main code
AND THE readdisk function is:

Code: Select all

     

readdisk:            ;code to read the sectors from the disk
     	
     	mov ah, 00h
	int 13h
     
	mov ah, 02h
	mov al, 1
	mov ch, 0
	mov cl, 2
	mov dh, 0
	mov dl, 0
	mov bx, 0a00h
	mov es, bx
	mov bx, 0
	int 13h

	RET

Re: Problem with reading floppy sectors

Posted: Thu Aug 11, 2005 11:00 pm
by seejohnrun
Someone please help, I need to implement this thing soon, so that the programs that depend on it can run