0
votes

I'm trying to run a sample bootloader from a blog post:

[BITS 16]
[ORG 0x7c00]

jmp boot

boot:
  mov ah, 0x0e
  mov bh, 0x00
  mov bl, 0x07
  mov al, '!'

  int 0x10
  jmp $

times 510-($-$$) db 0
db 0xaa
db 0x55

nasm -f bin boot.nasm produces a 512 byte boot file with the following contents:

0000000: eb00 b40e b700 b307 b021 cd10 ebfe 0000
0000010: 0000 0000 0000 0000 0000 0000 0000 0000
0000020: 0000 0000 0000 0000 0000 0000 0000 0000
0000030: 0000 0000 0000 0000 0000 0000 0000 0000
0000040: 0000 0000 0000 0000 0000 0000 0000 0000
0000050: 0000 0000 0000 0000 0000 0000 0000 0000
0000060: 0000 0000 0000 0000 0000 0000 0000 0000
0000070: 0000 0000 0000 0000 0000 0000 0000 0000
0000080: 0000 0000 0000 0000 0000 0000 0000 0000
0000090: 0000 0000 0000 0000 0000 0000 0000 0000
00000a0: 0000 0000 0000 0000 0000 0000 0000 0000
00000b0: 0000 0000 0000 0000 0000 0000 0000 0000
00000c0: 0000 0000 0000 0000 0000 0000 0000 0000
00000d0: 0000 0000 0000 0000 0000 0000 0000 0000
00000e0: 0000 0000 0000 0000 0000 0000 0000 0000
00000f0: 0000 0000 0000 0000 0000 0000 0000 0000
0000100: 0000 0000 0000 0000 0000 0000 0000 0000
0000110: 0000 0000 0000 0000 0000 0000 0000 0000
0000120: 0000 0000 0000 0000 0000 0000 0000 0000
0000130: 0000 0000 0000 0000 0000 0000 0000 0000
0000140: 0000 0000 0000 0000 0000 0000 0000 0000
0000150: 0000 0000 0000 0000 0000 0000 0000 0000
0000160: 0000 0000 0000 0000 0000 0000 0000 0000
0000170: 0000 0000 0000 0000 0000 0000 0000 0000
0000180: 0000 0000 0000 0000 0000 0000 0000 0000
0000190: 0000 0000 0000 0000 0000 0000 0000 0000
00001a0: 0000 0000 0000 0000 0000 0000 0000 0000
00001b0: 0000 0000 0000 0000 0000 0000 0000 0000
00001c0: 0000 0000 0000 0000 0000 0000 0000 0000
00001d0: 0000 0000 0000 0000 0000 0000 0000 0000
00001e0: 0000 0000 0000 0000 0000 0000 0000 0000
00001f0: 0000 0000 0000 0000 0000 0000 0000 aa55

I would now expect qemu-system-x86_64 boot to use the boot file as raw disk image, recognise the last two bytes as boot sector marker and execute the instructions. Instead it fails to recognise the bootloader:

Booting from Hard Disk...
Boot failed: not a bootable disk

What am I doing wrong?

Software versions:

$ nasm -v
NASM version 2.11 compiled on Apr 26 2014
$ qemu-system-x86_64 --version
QEMU emulator version 2.1.0 (Debian 2.1+dfsg-4ubuntu6.3), Copyright (c) 2003-2008 Fabrice Bellard
1
[BITS 16] [ORG 0x7c00] what do these line mean? - Faiz Halde

1 Answers

1
votes

You should change the order of the boot flag values:

db 0x55
db 0xaa