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

  • Home
  • SEARCH
  • 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 8800603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:37:58+00:00 2026-06-14T00:37:58+00:00

I’m writing a basic bootloader just to the point where I have some sort

  • 0

I’m writing a basic bootloader just to the point where I have some sort of environment where I can write a simple C program, write it to a hard disk (no file system), and run it. That’s all I want to do.

Here is what I’ve done so far.

Stage 1:

  1. Set up stack and segment registers
  2. Change video mode to 640x480x8
  3. Read the next sector to memory
  4. far jump to it

Stage 2:

  1. Set up the stack and segment again (do I need to do this again?)
  2. Set up the GDT (this part confuses the heck out of me – TBH I just copy/paste)
  3. Enable A20 gate
  4. Enter protected mode

I have entered protected mode successfully before, but for some reason now I can’t. Bochs goes into a boot loop when I try, but as far as I can tell the code is identical to the old code that worked.

I’ve tried commenting out the call to enable A20 and GDT, but that didn’t prevent the boot loop.

I have my entire bootloader code here on PasteBin, but I’ll put some stuff here also:


Setting up the stack:

CLI           ;Disable interrupts while setting up the stack
XOR AX,AX     ;Real mode flat memory model
MOV DS,AX
MOV ES,AX
MOV FS,AX
MOV GS,AX
MOV SS,AX
MOV SP,0xFFFF
STI           ;Enable interrupts

Enabling A20:

MOV AX,0x2401
INT 0x15
RET

Entering protected mode:

MOV EAX,CR0
OR  EAX,1
MOV CR0,EAX

The GDT code is a bit long-winded and I didn’t write it myself. But, as I said, not loading the GDT doesn’t prevent the boot loop later.

By the way… if you have any general comments about my bootloader (it’s my first), feel free to mention them.

  • 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-06-14T00:37:59+00:00Added an answer on June 14, 2026 at 12:37 am

    A “boot loop” probably means that your code is triple-faulting.

    Since you’re running in a virtual machine anyway, I’d suggest trying qemu, for two reasons. First, that Wikipedia article says, “In QEMU, a triple fault produces a dump of the virtual machine in the console, with the instruction pointer set to the instruction that triggered the first exception.” Having the emulator point you at the exact instruction that’s failing will make your debugging so much faster.

    Second, if that isn’t enough, QEMU supports attaching gdb to the virtual CPU, which allows you to single-step through your code, print register contents, and all the usual things. See the qemu manual page for the -gdb option.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
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
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.