What would I have to change to boot this on a physical computer?

76 views Asked by At

I just wrote a pretty basic bootloader in assembly, and am now trying to write a kernel. This is what I have so far.

extern "C" void main() {
  int addr = 0xb8000;
  int i = 0x00;
  for (int i = 0x00; i < 0xff; i += 0x11) {
    *(char*)addr = 'A';
    addr++;
    *(char*)addr = i;
    addr++;
  }
  return;
}

All it really does is displays some colors. It does this by writing to video memory, which for QEMU is 0xb8000. If I wanted to flash this "OS" to a USB and boot it up on my laptop, would I need to change the address of video memory? Is there a way to automatically find that address?

1

There are 1 answers

0
puppydrum64 On

Honestly, that should be fine as-is. 0xB8000 is the hardcoded address of the video display in text mode. There's no address space layout randomization going on here, that's the literal address. If you have DOSBOX you could try it out there, it should work as written.