Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with reading and writing to floppy

Status
Not open for further replies.

Nightsoft

Programmer
Aug 23, 2001
50
0
0
DK
HI.!
My problem is that i can't find out if Im writing to the floppy or not, my code looks like this :

CS:0000 mov bx , 0800
mov cl , 04h
mov ch , 00h
mov dl , 00h
mov dh , 00h
mov ah , 03h
mov al , 01h
int 13h

The floppy drive get's active but when i then try to read from the floppy, (changing the bx and ah value), It do get active, but when i look in memory at cs:bx I don't see the data that i have put out on my floppy.?

The data that I throw down to my floppy starts with 55h AAh and then some other stuff. Is it correct that these to values are nessecary for the PC to boot from it?

Hope some one smart out there could help me. :)

Nightsoft.dk
 
The code should have looked like this:

mov bx,0800h
mov cl,00h
mov ch,00h
mov dl,00h
mov dh,00h
mov ah,03h
mov al,01h
int 13h

:-}
Real programmers use direct machine code :)
 
Direct machine code looks like this:
BB 00 08 B1 00 B5 00 B2 00 B6 00 B4 03 B0 01 CD 13

And optimized:
BB 00 08 B9 00 00 BA 00 00 B8 01 03 CD 13

Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.
 
Hi there.!

I'm a bit confused. When I use the code above, where does the data come from, that I write out to the floppy? Is it at 0000:0800 or at cs:0800?

And Vica-Versa when i Read from Disc, setting AH=02, where are the data being placed in memory??

Hope some can help

Thnxs Nightsoft
Real programmers use machine code :)
 
DISK - WRITE DISK SECTOR(S)
AH = 03h
AL = number of sectors to write (must be nonzero)
CH = low eight bits of cylinder number
CL = sector number 1-63 (bits 0-5)
high two bits of cylinder (bits 6-7, hard disk only)
DH = head number
DL = drive number (bit 7 set for hard disk)
ES:BX -> data buffer

Return:
CF set on error
CF clear if successful
AH = status (see #00234)
AL = number of sectors transferred
(only valid if CF set for some BIOSes)

Notes: Errors on a floppy may be due to the motor failing to spin up quickly enough; the write should be retried at least three times, resetting the disk with AH=00h between attempts. Most BIOSes support "multitrack" writes, where the value in AL exceeds the number of sectors remaining on the track, in which case any additional sectors are written beginning at sector 1 on the following head in the same cylinder; the CONFIG.SYS command MULTITRACK can be used to force DOS to split disk accesses which would wrap across a track boundary into two separate calls. The IBM AT BIOS and many other BIOSes use only the low four bits of DH (head number) since the WD-1003 controller which is the standard AT controller (and the controller that IDE emulates) only supports 16 heads. AWARD AT BIOS and AMI 386sx BIOS have been extended to handle more than 1024 cylinders by placing bits 10 and 11 of the cylinder number into bits 6 and 7 of DH. Under Windows95, an application must issue a physical volume lock on the drive via INT 21/AX=440Dh before it can successfully write to the disk with this function

Noed more info? check out RB's Interrupt List:
(online)
(download)
Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.
 
Ok. I think I know it know, but I have some problem.
For starters i start with:

xx:0100 mov bx,0110 /* load code from xx:0110
xx:0103 mov cx,0000 /* to sector 0 & cylinder 0
xx:0106 mov dx,0000 /* & head 0 device 0 (floppy)
xx:0109 mov ax,0301 /* write 1 sector of disc.
xx:010c int 13 /* interrupt! and write

xx:0110 AA /* The code that Bios looks for
xx:0111 55 /* when determing bootdevice
xx:0112 mov ax,0013 /* testcode_for_floppy
xx:0115 int 10 /* testcode_for_floppy

ok I think this works cuz I can see that the floppy get's active, but now I'll try to load the 7 bytes data from floppy and I do it with this :

xx:0100 mov bx,0110 /* code will be put at xx:0110
xx:0103 mov cx,0000 /* from sector 0 & cylinder 0
xx:0106 mov dx,0000 /* & head 0 device 0 (floppy)
xx:0109 mov ax,0201 /* read 1 sector of disc.
xx:010c int 13 /* interrupt! Read and put in
/* memory.

I think that this works too cuz I see the floppy goes active.
My problem now, is that if I look at address xx:0110, after reading the floppy, the 7 bytes of code is not being put in memory, anyway not at xx:0110.
So where did my bytes go?!! I wan't my Data.! I can't boot from the floppy either, so something went wrong.! But what.

If anyone an answer to my question and perhaps a solution, I would be gratefull. :)
Real programmers use machine code :)
 
Check status AH after completion:


You should also check if the data is actually written to the disk (you can do that with e.g. Norton Disk Editor) because CL should contain values 1-63 according to RBs Int List.
Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.
 
Thanks Bertv100!

After setting the cl=1 it just works :)

I can even make a bootable disk now. :)

Nightsoft.dk Real programmers use machine code :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top