Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I'm trying to write a bootloader that prints a character to the screen and then sits there. I'm working with the following code and since it's 512 bytes after assembly I think that part is working right. I've got it to the point that when the USB is selected as the boot medium it will crash with "Error loading operating system" instead of "Could not Find Operating System".
[BITS 16] ;Tells the assembler that its a 16 bit code
[ORG 0x9000] ;0x7C00 and 0x9000 are equally ineffective values to put here.
mov ax, 0x0000
mov ds, ax ;Set ds to 0
MOV AL, 65
CALL PrintCharacter
JMP $ ;Infinite loop, hang it here.
PrintCharacter: ;Procedure to print character on screen
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
INT 0x10 ;Call video interrupt
RET ;Return to calling procedure
TIMES 510 - ($ - $$) db 0 ;Pad the code with zeros.
DW 0xAA55 ;Put the boot signature in bytes 510 and 511.
I expect that the problem is how I'm copying the program to the USB. Since I'm working on a 64 bit windows machine, I originally tried typing "partcopy boot.bin 0 200 -f0" which runs without printing an error message but doesn't work, I tried typing " dd if=C:/boot.bin bs=512 of=E:/" in cygwin but that told me that E was a directory and did nothing, I also tried "cp C:/boot.bin E:/" which runs without an error message, but doesn't work. Any other ideas?
Read that thread again and you will see where you went wrong. You have to dd to the device, not the root folder of the drive.
From what you have said so far I would advise you to not try this as there is a real danger of overwriting important parts of your hard disk. Why not use a virtual machine and a virtual floppy disk instead? You will find that much safer (and much easier).
iansjack wrote:Read that thread again and you will see where you went wrong. You have to dd to the device, not the root folder of the drive.
Oh. I tried that before but it gave me an "Operation not permitted" error message, trying it again as an administrator fixes the error message but doesn't get it to boot.
From what you have said so far I would advise you to not try this as there is a real danger of overwriting important parts of your hard disk. Why not use a virtual machine and a virtual floppy disk instead? You will find that much safer (and much easier).
I'll probably give a virtual machine a try. Anything wrong with using this tutorial as a guide?
Anyway if your "code" was written correctly to the device it will boot but likely triple fault and reset the machine because of the insufficiencies that turdus pointed out.