0

I write the following bytes into a file named disk.img

FA 8D 36 1B 7C E8 01 00 F4 AC 3C 00 74 0C B4 0E 
BB 07 00 B9 01 00 CD 10 EB EF C3 4D 61 79 20 74 
68 65 20 66 6F 72 63 65 20 62 65 20 77 69 74 68 
20 79 6F 75 21 0D 0A 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
..enough zero to make the size of file 512bytes.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

The above bytes are proper instructions and magic number that should work when loading into the boot sector. But after I executed "qemu-X86_64 disk.img", error happens.

Error -13 while loading disk.img

Does anyone know how to solve the problem or what is the reason that might lead to this error?

Thank you!

id_morpheus
  • 1
  • 1
  • 5

1 Answers1

0

I don't know if you can fill an image with just anything and expect it to work just because you have 55 AA in the correct place. Since you seem to be writing a bootloader make sure your code thinks it is executing at the correct place. It should be in offset 0x7C00 (if I remember this correctly, double check that). You set it by writing the line [org 0x7C00] at the top of your assembly file.

Also I'm not sure you can have only a 512 byte file. Try to make the disk image bigger than that using something like dd if=/dev/zero of=disk.img bs=512 count=2000 and then just copy your bootloader to the first part of the disk using dd again.

Also, you should use the -hda or -fda tags, so it would be qemu -hda disk.img. -hda means hard drive image, and -fda means floppy disk image.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
origamicoder
  • 121
  • 7