Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't have a direct answer on where your error comes from. However, I do see a lot of things going wrong so I'll write these here:</p> <p><strong>nasm</strong></p> <pre><code>nasm -f aout -o kernelstart.asm -o kernelstart </code></pre> <p>Does that even work? That should be something like</p> <pre><code>nasm -f aout -o kernelstart kernelstart.asm </code></pre> <p><strong>ld</strong></p> <pre><code>ld -i -e _main -Ttext 0x1000 kernel.o kernelstart.o main.o </code></pre> <p>Since you said you wanted to make a bootloader and a kernel, I'm assuming your goal here is to make <code>ld</code> output something that can be put in the MBR. If that's the case, here are some things to keep in mind:</p> <ul> <li>You didn't specify the output format. If you want to make an MBR image, add <code>--oformat=binary</code> to the command line options. This makes sure a flat binary file is generated.</li> <li>You set the entry point to <code>_main</code>. I'm not sure where that symbol is defined, but I guess you want your entry point to be <code>start</code> because that's where you call your kernel.</li> <li>You link your <code>text</code> section starting at 0x1000. If you want to put your image in the MBR to be loaded by the BIOS, it should be linked at 0x7c00.</li> <li>As a side note: it seems your trying to link your bootloader and kernel together in one image. Just remember that the MBR is can only hold 512 bytes (well, actually 510 bytes since the last 2 should contain a magic value) so you won't be able to write much of a kernel there. What you should do is create a separate kernel image and load this from your bootloader.</li> </ul> <p>I hope these points will help you in solving your problem.</p> <p>Also, you'll find a lot of useful information as <a href="http://wiki.osdev.org/Main_Page" rel="nofollow">OSDev</a>. <a href="http://wiki.osdev.org/Real_mode_assembly_bare_bones" rel="nofollow">Here</a> is a tutorial on writing a real mode "kernel" that only uses the MBR. The tutorial contains working code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload