Page 6 of 6

Re: How do I load my sector with if it's more than 512 bytes

Posted: Thu Aug 17, 2017 8:55 am
by Schol-R-LEA
stevewoods1986 wrote:
Schol-R-LEA wrote:And if you pardon my need for external validation, I was specifically wondering what, if anything, you thought of my explanation of x86 segmented memory here. I don't know if it was something you were actually having trouble with or not, but it was clear that I and most of the other posters were having some :roll:
Well, the post suggesting C and GRUB.
In other words... none of my posts.

At no point in this thread did I tell you to use GRUB - I explained, later on, why the others were recommending it, but I never told you to use it. And at no point did I mention C. Unless it was in a previous thread, I can't find anything that even resembles telling you to use C (I never would - I don't intend to use C myself, why would I recommend it to others?). I may have said that you need to be able to read C code, as most of the examples are in C, but that's it.

Unless you mean this post, but that wasn't in C - it was in Fast Assembler, because I had you mixed up with another poster who was using that. The equivalent struc in NASM would be:

Code: Select all

struc text_cell
    .char db 1
    .attrib db 1
end struc
I can see why you would think the FASM directive was C code, though.

I also gave a recommendation on which C compiler for real mode you could use, but that was in the thread actually discussing mixing C and assembly language for your printing test.

The specific post I was linking to? Didn't even discuss boot loaders. It was on how memory works in the x86. Now, you might, as I said, know the subject well enough already, but I wasn't sure, which is why I wrote that post. The fact that others - including myself - were getting turned around when discussing how to set up the segments for the loaded sectors gave me reason to think you could use the refresher, too.

Seriously, this is honestly looking like you are trolling. I am pretty sure that's not your intent, but there's some real communication problems if you aren't, and if nothing else I'd like to know what I am doing wrong so I can fix the problem.
stevewoods1986 wrote:I think what Mike is saying could be worth a try. Now my next problem is integers :)
Mike? confused I don't know which poster you are talking about.

Re: How do I load my sector with if it's more than 512 bytes

Posted: Fri Aug 18, 2017 2:47 am
by onlyonemac
iansjack wrote:It seems to be a common misconception amongst beginners that it's easier to write your own bootloader than to use GRUB. This is incorrect. As we've already seen here, writing your own bootloader involves not simply reading sectors from a disk, but being able to parse the filesystem, find the location of the kernel, and then load the code. Plus you then have to set up the GDT and switch to protected mode. (You have to so that first if you want to load your code above the 1MB point.) And then you have to determine how much RAM you have and where it is located.
I have to disagree. Writing your own bootloader can be easier/simpler. Personally I wrote my own bootloader that simply loads a fixed size from a fixed location on disk to a fixed address in memory. Before that it gets a memory from the BIOS and dumps that somewhere else in memory, to be read by the kernel while it's initialising. Not that hard, probably took me about three hours to write the bootloader (to be fair I had some experience with small bootloaders before) and another day later on to add the support for reading the memory map in the bootloader and parsing it in the kernel.

Why did I do this? Because I wanted to get onto writing the kernel, not fussing with multiboot headers and configuring GRUB. If necessary, I can always replace the boot code later on. I'm pretty sure that GRUB won't work with the design of my OS anyway, because I use a custom filesystem to support some of the important features of my kernel/OS (although I have plans to make it compatible with standard filesystems by storing extra metadata in special files, but this isn't particularly desirable for the boot media itself).