Help on Sectors and Copying to a floppy using partcopy
Posted: Thu Mar 31, 2005 3:25 pm
If anyone can help I'd be very happy. Smile Razz
I'm using partcopy to write data to specific sectors on a floppy in order to create a bootable floppy using my boot loader and put other instructions where I need them on the floppy so that they can be called by the boot loader/kernel etc.
I wrote my boot loader, compiled it using NASM and using partcopy, copied it to the first sector of the floppy so that the BIOS picks it up and uses it to boot. In case you're wondering I used:
I then wrote my kernel (which is called from the boot loader) which is meant to go into the second sector of the floppy. So I compile and attempt to copy it to the second sector of the floppy. The file is 264 bytes in size - as you can see by the byte range to copy being 0 - 108 (it uses hex not decimal).
Unfortunately, when I do that, the floppy shows up as not formatted in windows (indicating, I'm guessing, that I over wrote the DOS boot record). When I boot from it (I've tested this on a virtual machine - Bochs - and on a real computer), I get my boot loader message (the boot loader just prints the name then loads the kernel into memory and jumps to it), but the message in my kernel doesn't print (the kernel prints a welcome message then loops infinitely). Bochs doesn't throw an error, and everything seems normal (including the number of times that the floppy is read from) except that the message in the kernel doesn't display.
I added a bit after where the boot loader jumps to the kernel, to see if it was actually jumping. If it didn't jump, I'd get a message about it (because it kept executing code in the boot loader and not jump to the kernel), but I didn't get the message - so it does actually jump to the kernel. The problem seems to be with the kernel - either in the code, compiling or the copying to the disk.
Can anyone help?
http://www.angusenterprises.co.uk/boot.asm
http://www.angusenterprises.co.uk/kernel.asm
makeboot.bat
-------------
nasm boot.asm -f bin -o output/bootsec.bin
partcopy output/bootsec.bin 0 200 -f0
nasm kernel.asm -f bin -o output/kernel.bin
partcopy output/kernel.bin 0 108 -f0 201
Sorry if this is something of a newbie-esque question. Also, sorry, this free hosting seems to try to add it's wee thing to everything possible. At some point I must buy myself free hosting, or sort out the PHP on my shell account.
EDIT: Finished merging together various posts I've made which had variations and inconsistencies, particularly with the code)
I'm using partcopy to write data to specific sectors on a floppy in order to create a bootable floppy using my boot loader and put other instructions where I need them on the floppy so that they can be called by the boot loader/kernel etc.
I wrote my boot loader, compiled it using NASM and using partcopy, copied it to the first sector of the floppy so that the BIOS picks it up and uses it to boot. In case you're wondering I used:
I then wrote my kernel (which is called from the boot loader) which is meant to go into the second sector of the floppy. So I compile and attempt to copy it to the second sector of the floppy. The file is 264 bytes in size - as you can see by the byte range to copy being 0 - 108 (it uses hex not decimal).
Unfortunately, when I do that, the floppy shows up as not formatted in windows (indicating, I'm guessing, that I over wrote the DOS boot record). When I boot from it (I've tested this on a virtual machine - Bochs - and on a real computer), I get my boot loader message (the boot loader just prints the name then loads the kernel into memory and jumps to it), but the message in my kernel doesn't print (the kernel prints a welcome message then loops infinitely). Bochs doesn't throw an error, and everything seems normal (including the number of times that the floppy is read from) except that the message in the kernel doesn't display.
I added a bit after where the boot loader jumps to the kernel, to see if it was actually jumping. If it didn't jump, I'd get a message about it (because it kept executing code in the boot loader and not jump to the kernel), but I didn't get the message - so it does actually jump to the kernel. The problem seems to be with the kernel - either in the code, compiling or the copying to the disk.
Can anyone help?
http://www.angusenterprises.co.uk/boot.asm
http://www.angusenterprises.co.uk/kernel.asm
makeboot.bat
-------------
nasm boot.asm -f bin -o output/bootsec.bin
partcopy output/bootsec.bin 0 200 -f0
nasm kernel.asm -f bin -o output/kernel.bin
partcopy output/kernel.bin 0 108 -f0 201
Sorry if this is something of a newbie-esque question. Also, sorry, this free hosting seems to try to add it's wee thing to everything possible. At some point I must buy myself free hosting, or sort out the PHP on my shell account.
EDIT: Finished merging together various posts I've made which had variations and inconsistencies, particularly with the code)