flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Question about INT 13 (read sectors to RAM)

Author
Thread Post new topic Reply to topic
nkeck72



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
nkeck72 31 Dec 2015, 15:47
I have a simple question regarding INT 0x13. It came up when I was programming the preprocessor for a segmented program in NOS (e.g. different segments for CS,DS,ES,SS.)

Say we are reading the file into 9000:0000.
When running the read sectors function (ah=0x02), does the BIOS only read 64K (up to the end of segment 9000) or does it overflow into the next segment? Or does it depend on the BIOS manufacturer?

The only reason I worry about this is one of the reasons a programmer would write a segmented program instead of a flat one would be because they have more than 64K of combined code/data, making my (uncompressed) file with the formatting larger than 64K. Would this make me have to read the sectors in 64K at a time?

_________________
It may look hard, but it won't take long if you take it one byte at a time.

NOS: www.github.com/nkeck720/nos
Post 31 Dec 2015, 15:47
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 31 Dec 2015, 18:30
If you really need bullet proof code then you shouldn't ask the BIOS to read or write data that crosses a 64k boundary. The DMA system of the original PC could not do it.

However many modern BIOSes have "fixed" this limitation. But there is no guarantee that all BIOSes (in current systems) can do this.
Post 31 Dec 2015, 18:30
View user's profile Send private message Visit poster's website Reply with quote
nkeck72



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
nkeck72 31 Dec 2015, 18:39
So if I loaded and processed the file in 64K blocks, it would circumvent this issue? And is there a way to tell if the BIOS can or not short of testing it on the system itself?
Post 31 Dec 2015, 18:39
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 31 Dec 2015, 18:45
It is more than simply 64k blocks. You also have to align them to 0xZZZZ0000.

You can test for it by checking the error code returned. If you get an error then you can fall back to doing reads/writes that don't cross a boundary.

Although I can't see any advantage to having two code paths in boot code.
Post 31 Dec 2015, 18:45
View user's profile Send private message Visit poster's website Reply with quote
nkeck72



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
nkeck72 31 Dec 2015, 20:09
Figured that might work, there is no way I can find to query the BIOS of this information.

As for your second comment, this is for preprocessing a program, not boot code. I wouldnt make any boot files larger than 64K, that just seems a bit ridiculous. Smile
Post 31 Dec 2015, 20:09
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.