So anyway, the first piece is obviously the bootloader, and getting the PC to boot from USB using my code. Stage 1 bootloader works, it displays a nice welcome message. Problems arise when I try to load the stage 2 bootloader. It doesn't display the stage-2 message, only a character of garbage.
This is the stage 1:
Code: Select all
[BITS 16] ;16-bits real mode
[ORG 0x7C00] ;Origin, tell the assembler that where the code will be in memory after it is been loaded
jmp main
;Included functions
%include "PrintScreen.inc"
;Data
LoadString db 'Stage 1 Bootloader Starting...', 10, 13, 0 ;HelloWorld string ending with 0
main:
MOV AX, CS
MOV DS, AX
MOV ES, AX
MOV SI, LoadString ;Store string pointer to SI
CALL PrintString ;Call print string procedure
reset: ; Reset the floppy drive
mov ax, 0 ;
mov dl, 81h ; Drive: 0=first floppy, 80h = first HDD
int 13h ;
jc reset ; ERROR => reset again
read:
mov ax, 1000h ; ES:BX = 1000:0000
mov es, ax ;
mov bx, 0 ;
mov ah, 2 ; Load disk data to ES:BX
mov al, 1 ; Load 1 sectors
mov ch, 0 ; Cylinder=0
mov cl, 2 ; Sector=2
mov dh, 0 ; Head=0
mov dl, 81h ; Drive
int 13h ; Read!
jc read ; ERROR => Try again
jmp 1000h:0000 ; Jump to the program
TIMES 510 - ($ - $$) db 0 ;Fill the rest of sector with 0
DW 0xAA55 ;Add boot signature at the end of bootloader
Code: Select all
[BITS 16] ;16-bits real mode
[ORG 0x0000] ;Origin, tell the assembler that where the code will be in memory after it is been loaded
jmp main
;Included functions
%include "PrintScreen.inc"
;Data
HelloString db "Hello World",10,13,0
main:
MOV AX, CS
MOV DS, AX
MOV ES, AX
MOV BX, 0
MOV SI, HelloString ;Store string pointer to SI
CALL PrintString ;Call print string procedure
JMP $ ;Infinite loop
I've copied both files on with DD:
Code: Select all
dd if=part1.bin of=\\.\d: bs=512 count=1
dd if=part2.bin of=\\.\d: seek=1 bs=512 count=1
Like I said, all the code worked on the floppy, and here I just changed the drive number in Stage 1 from 0 to 81h.
My best guesses for the problems are something wrong in my using int 13h or not copying correctly with DD. But I've read over all the documentation I could find for each of these and find nothing wrong. It could be a third problem I do not suspect, but then how would I find it.
Can anyone help? See something wrong somewhere that I'm missing?