Page 1 of 2

Reading sectors FDC on CPU x86 in protected mode

Posted: Sun Jul 06, 2014 4:59 pm
by Neo92
Hi all, i post this code for reading sectors of the floppy. My question is... why the emulator Bochs show 'partial read() on floppy image returns 510/512' (usually when it does is OK) and doesn't read the next sector with 'call'? Through 'int 13h' is allowed, strange or something wrong? :?

The code

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Sun Jul 06, 2014 8:09 pm
by Brendan
Hi,
Neo92 wrote:Hi all, i post this code for reading sectors of the floppy. My question is... why the emulator Bochs show 'partial read() on floppy image returns 510/512' (usually when it does is OK) and doesn't read the next sector with 'call'? Through 'int 13h' is allowed, strange or something wrong? :?
How large if the floppy disk image you're using (and can I guess that the floppy image itself is 510 bytes, and not 1474560 bytes or any other multiple of 512 bytes)?


Cheers,

Brendan

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 5:23 am
by Neo92
Hi Brendan, i must to read the second sector's floppy by first. The image is large 1024 bytes (exactly 1022 bytes) divided into 512 bytes for sector. I wouldn't want that there are the mistakes into initialization ports or DMA, i don't know... i will try of read back functions, also if is strange that with interrupt 0x13 read it. :? :(

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 5:28 am
by Combuster
A floppy image must be exactly the 1.4M size of an actual floppy, anything else makes VMs trip - in different fashions depending on the emulator in question.

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 6:49 am
by Neo92
Hi Combuster, i know that the standard format floppy is 1.44 MB but my problem is reading sectors through ports in protected mode, don't work. Why?

The code

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 7:55 am
by Icee
You have already been given the answer -- not only is your image of invalid size, it's also even not sector (512 byte) granular.

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 10:25 am
by SpyderTL
Just add zeros to the end of your image until it is 1474560 bytes long, and see if the problem goes away. If not, let us know.

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 11:17 am
by Neo92
This is my code on FASM:

The code, 3rd revision
I use DMA and FDC. I don't believe that needs add the zeros, because otherwise, how does it work with interrupt 0x13?

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 11:32 am
by onlyonemac
The BIOSes in a lot of emulators don't implement int 13 through the standard FDC subsystem; they work through a "back door" route which may or may not be able to handle incorrectly sized images.

Now can you please increase the size of your image before posting again, and repeatedly posting the same (or very similar) code is not going to fix your problem.

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 11:49 am
by Neo92
I increase the size of my image (1474560 byte=1 Mbyte) but without reply.

The code, 4th revision

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 11:51 am
by onlyonemac
Neo92 wrote:I increase the size of my image (1474560 byte=1 Mbyte) but without reply.
Then let us know so we don't all criticise you :) .

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 12:04 pm
by SpyderTL
Neo92 wrote:I increase the size of my image (1474560 byte=1 Mbyte) but without reply.
So, to clarify, is it working now? Does Bochs give you the "Partial" error any more?

By the way, you could probably use the following code instead:

Code: Select all

times 1474560-$ db 0
Also, in your original code, the second sector should end with:

Code: Select all

times 512-($-start) db 0
since you don't have the 2 byte magic number (0xaa55) at the end of that sector. Only the first sector has that.

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Mon Jul 07, 2014 3:03 pm
by Neo92
Aaaaaac! #-o Works in Bochs! But with delay, i don't know why... :-s

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Tue Jul 08, 2014 12:26 am
by Candy
I moved the code out of your posts into Pastebin, so the thread is readable again. Please try to use some other code hosting site - can I suggest version control as well - when you want to paste something that's more than a few lines long?

Re: Reading sectors FDC on CPU x86 in protected mode

Posted: Tue Jul 08, 2014 7:19 am
by Neo92
Thanks Candy, i don't knowed this rule, in the future i'll try don't repeat this action and i'm sorry. But i still don't understand why the floppy reading into second sector is slow. I don't want to read the second sector with interrupt 0x13 (that works) but through ports with DMA, that's all. :?: