I'm trying to write an "operating system" from scratch.
I use a floppy to boot.
Stage 1: - complete
I wrote a bootloader, which prints "Hello world". (BITS 16 - INT 0x10 - BIOS Print interrupt)
Stage 2: - in progress
There have to be 2 sectors on the floppy, both sectors have a size of 512 bytes:
- sector 1: bootloader
- sector 2: kernel
I want to let the bootloader load the kernel on the 2nd sector.
The kernel has to print "Hello world".
I just don't know how to start with "stage 2", because I have no idea how to load the 2nd sector on a floppy and how to call its main function.
My code is inserted on the bottom of the post.
I hope someone could help me with booting my OS.
Thanks in advance,
Sinned
Stage 1 - bootloader.asm:
[BITS 16] ;protected mode [ORG 0x7C00] ;Bootloader base - loaded by kernel ;Set DS to 0 MOV AX, 0x0000 MOV DS, AX ;init print colors MOV AH, 0x0E MOV BH, 0x00 MOV BL, 0x07 MOV SI, msg ;Set Hello World message in SI CALL PrintString JMP $ ;hang PrintString: .next_char: MOV AL, [SI] ;load current character in string OR AL, AL ;see if AL is zero JZ .char_done ;if AL is zero, jump to end (end of string reached) INT 0x10 ;call print character command INC SI ;increase SI, next character JMP .next_char .char_done: RET ;Data section - never reaced msg db 'Hello world', 13, 10, 0 TIMES 510 - ($ - $$) db 0 ;fill rest of file (needs a size of 512 bytes) DW 0xAA55 ;end
Stage2 (plan) - bootloader.asm:
[BITS 16] ;protected mode [ORG 0x7C00] ;these two calls still doesn't exist because I don't know how to make them CALL LoadKernel CALL CallKernelMain TIMES 510 - ($ - $$) db 0 ;fill rest of file (needs a size of 512 bytes) DW 0xAA55 ;end
Stage 2 (plan) - kernel.asm:
;don't know if headers are needed here kernelMain: ;Set DS to 0 MOV AX, 0x0000 MOV DS, AX ;init print colors MOV AH, 0x0E MOV BH, 0x00 MOV BL, 0x07 MOV SI, msg ;Set Hello World message in SI CALL PrintString JMP $ ;hang PrintString: .next_char: MOV AL, [SI] ;load current character in string OR AL, AL ;see if AL is zero JZ .char_done ;if AL is zero, jump to end (end of string reached) INT 0x10 ;call print character command INC SI ;increase SI, next character JMP .next_char .char_done: RET ;Data sector msg db 'Hello world', 13, 10, 0 TIMES 510 - ($ - $$) db 0 ;fill rest of file (needs a size of 512 bytes) DW 0xAA55 ;end - don't know if this is needed here

New Topic/Question
Reply



MultiQuote










|