![]() ![]() If there is a failure the code will print an appropriate error. The following code will check that Int 13h extensions are available in the BIOS and will also determine if the drive in DL supports Int 13h extensions. Run the command file disk.img and you may get this output:ĭisk.img: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "mkfs.fat", root entries 224, sectors 2880 (volumes <=32 MB), sectors/FAT 9, sectors/track 18, serial number 0x2d7e5a1a, unlabeled, FAT (12 bit)Ĭomplete Example with Int 13h Extension Checks If you were to modify your code to have the layout above the Unix/Linux file command may be able to dump out the BPB data that it thinks makes up your MBR in the disk image. OEMname: db "mkfs.fat" mkfs.fat is what OEMname mkdosfs uses TIMES 3-($-$$) DB 0x90 Support 2 or 3 byte encoded JMPs before BPB. You can create a fake one like this: org 0x7c00 If your BIOS is set to do USB FDD emulation (and not USB HDD or something else) you may need to add a Boot Parameter Block(BPB) to the beginning of your bootloader. If you are attempting to use USB to boot on real hardware then you may encounter another issue even if you get it working in BOCHS with the changes above. NASM would only support this directly: dw 1 Number of sectors to be loaded Normally this line would be a problem with the % symbol before 1: dw %1 Number of sectors to be loaded I'm not sure this line is a typo or you are using some type of pre-processor on your assembly files before passing them to NASM. Infinite loop so we don't have the CPU wander memory Print MDP to upper left of screen in white on light magenta To test out your code I added this after bootend: bootend: If you want DS and ES to be zero (which is what you'd need with org 0x7c00), you should modify the start of your code to be something like: org 0x7c00 See my General Bootloader Tips for more information. You can't assume the value of CS will be set to what you think when control is transferred from the BIOS to your bootloader. I have additional information on using DD to create disk images in this Stackoverflow answer.Īlthough the disk image is part of the issue with BOCHS you do have some coding issues. Place the boot sectors into the beginning of disk.img without truncating the file: dd if=main.bin of=disk.img conv=notrunc You can create it and place the sectors you generate into it with commands like: nasm -f bin main.asm -o main.binĬreate an image of 516096 bytes: dd if=/dev/zero of=disk.img count=1008 bs=512 You can modify your bochsrc.txt to be: megs: 32Īta0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14Īta0-master: type=disk, path="disk.img", mode=flat, cylinders=0, heads=0, spt=0, model="Generic 1234", biosdetect=auto, translation=auto The minimum size hard disk image size that BOCHS supports is one with CHS = 1/16/63 which is 512*16*63 = 516096 bytes or 1008 sectors of 512 bytes each. If you want to test your code on BOCHS using extended disk reads and LBA you will have to create a hard disk image and modify BOCHS to boot from it instead of floppy. This does an extended disk installation check. You can test whether extended disk functions are available on a drive via Int 13/AH=41h/BX=55AAh. Not all BIOSes support extended disk reads of floppies via Int 13h/AH=42h. Not all BIOSes support the extended disk read and write functions (although on modern hardware they almost all likely will). Keyboard: type=mf, serial_delay=200, paste_delay=100000 Vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest Romimage: file=/usr/share/bochs/BIOS-bochs-latest, address=0xfffe0000 ![]() Fill the rest of bootsector with zeroes and end it Then I tried to load my old PC from this flash drive, and it works! It loads program and executes it correctly. However, nothing had been loaded after int 13h executed. So I tried to debug it with Bochs and noticed that Bochs recognizes this binary file as bootable. Laptop loads Intel UNDI and gives me the following error: No bootable device - insert boot disk and press any key. I wrote bootloader to USB flash drive with dd if=main.bin of=/dev/sdb bs=512. It works correctly in QEMU, however, I have troubles running it with Bochs and my laptop. I changed my bootloader from CHS to LBA, so I replaced int 13h 02h with int 13h 42h. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |