I'm stuck on one of brokenthorn's tutorial on bootloaders. My question is why reference byte 26?
Bytes 26-27 : First Cluster
You might have some more luck if you try searching the OSDev forums, or read their wiki. There aren't many os-devers on Daniweb AFAICT, and I expect that this question (or ones like it) has been addressed there in the past. You absolutely should read the Introduction, Required Knowledge, Beginner's Mistakes and How To Ask Questions entries, if you haven't already.
I should add that the BT tutorial - and pretty much every supposed 'tutorial' on OS dev - has a number of flaws in it, even setting aside the atrocious spelling errors. It is better than most others, but you should still take what it says with a grain of salt. Also, most hobby OS devs agree that the bootloader isn't really a good place to start an OS project - especially one which uses anything resembling a conventional filesystem and executable format (e.g., one that GRUB or a similar existing boot manager can work with). While understanding the boot sequence is of considerable importance, actually writing one yourself is more of a distraction than a necessity. That's not to say you shouldn't read through the tutorial and follow through its code examples, but basing your OS work on it is not going to lead you very far.
Now, regarding the question itself, I am not entirely certain what it is you are asking. The answer depends on if you mean:
'Why does it need to be read?' - the reason is that bytes 26 and 27 of the FAT entry contains the cluster number of the first cluster in the file (and on a floppy the cluster size is generally one 512-byte sector, meaning that the cluster number is the same as the sector number), which you will need in order to read the file (specifically the file STAGE2.SYS, in this case).
'Why is it being read at that point in the boot loader?' - it is to let the boot loader copy the second stage loader file into memory. Because STAGE2.SYS is an actual file, rather than a fixed set of sectors/clusters in a pre-determined location on the disk, the disk location of the file needs to be looked up in the FAT for the root directory. What you need to understand is that a) what John described in the preceeding section is the format for a single entry in the File Allocation Table, b) in FAT12 the FAT Root Directory holds exactly 4096 entries, the majority of which are unused in most cases, c) a file may span multiple entries (to allow for files which span two or more non-contiguous regions of the disk), and d) the file STAGE2.SYS is not going to be at a fixed cluster location, is not necessarily the first entry in the root directory, and (in principle) may span more than one part of the disk, hence the need to look it up in the FAT.
'why is the cluster location in those two positions in the FAT entry?' - well, I can't answer that, other than to say that this was the design originally chosen by Seattle Computer Products in the original version of what would become MS-DOS (back before Microsoft purchased the rights to it). If I had to guess, they chose to have a 32-byte entry because it was a nice round power of 2 that was large enough to accomodate later enhancements while still being small enough to be reasonably sized for the disks of the time. I imagine that they put the sector (now cluster) location and file size at the end of the entry so that the fields bracketed what was originally reserved space in the entry, as this is a common practice when designing file structures, but that's speculation on my part.
'Why do we need to read in STAGE2.SYS?' - that's an easy one: the BIOS bootstrap loader only reads a single sector into memory when the system starts, so if the OS is larger than 478 bytes (512 - 34 for the BPB and the boot signature), you will need to use your boot sector to load the rest of the kernel into memory.
If your real question is not one of those four, then I dunno. In that case you would need to clarify your question.
Edited by Schol-R-LEA
Wow, I didn't know that there wasn't very many OS dever's on daniweb. Thank you for addressing that fact. Yes, my question is in one of those four questions.
Why does it need to be read?' - the reason is that bytes 26 and 27 of the FAT entry contains the cluster number of the first cluster in the file (and on a floppy the cluster size is generally one 512-byte sector, meaning that the cluster number is the same as the sector number), which you will need in order to read the file (specifically the file STAGE2.SYS, in this case).
I'm trying to build a client and a server in the same program. For example, user 1 sends a packet of data to user 2, user 2 after receiving the ...
I ussually dont post anything here often, just get everything off of everyone elses questions,
but I'm having a strange problem that im scratching my head over,