Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6038607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:14:47+00:00 2026-05-23T06:14:47+00:00

I’m working on making my own boot loader and kernel in D, and I’ve

  • 0

I’m working on making my own boot loader and kernel in D, and I’ve come across a stumbling block.

Background:

  • I’m writing everything from scratch. So the boot sector is in assembly. And I’m not using GRUB.
  • I’m using Qemu for testing.
  • The boot sector reads the kernel from the "disk" (which is currently just a flat binary file, whose first sector is the boot loader and the rest of which is the kernel code) into virtual address 0xC0000000, and calls kmain(), the entrypoint of my kernel.
  • I’m using the PE file format for my kernel. (Please don’t tell me to use Elf — my choice is PE.)

The Problem

It’s part of the kernel’s job to be able to load PE files. So how do I load the kernel itself into memory in the first place, so that it can actually execute correctly?

I can’t do this from the boot sector because (1) it doesn’t fit in 512 bytes, and (2) it’s painful to do in assembly. Obviously, I can’t do it in the kernel itself either. So how should I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:14:48+00:00Added an answer on May 23, 2026 at 6:14 am

    How does GRUB do it?

    In GRUB, the 512 byte boot sector does not load the kernel. Instead, it loads the rest of the bootloader, which is much larger than 512 bytes. It is this second-stage bootloader that loads the kernel. You will have to do something similar.

    The code for loading this second stage can be much simpler than the code for loading the full kernel – it basically loads a few sectors directly into a fixed memory address (in low memory – it is still in real mode by this point) and jumps to a fixed memory address.

    This second stage can be mostly written in C. You only need a bit of setup in assembly (entering protected mode, setting up the stack, and few other bits of low-level processor stuff) before jumping to a C function to do the rest of the setup.

    The Linux kernel did something like this in the past. You could copy the raw kernel directly into a floppy disk. Its first 512 bytes were a floppy disk boot sector, which loaded the next few sectors (still in real mode) into a fixed address in low memory. These next few sectors had the code (still in assembly) to load the rest of the kernel into a fixed memory address, and jump to its real entry point. Nowadays, IIRC most of this code was ripped out and the Linux kernel now depends on external bootloaders.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I am writing an app with both english and french support. The app requests
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.