MEMTEST などの将来のテスト アプリケーション用に単純なカーネルを構築しています。
だから、私が今持っているのはブートローダーです。私がする必要があるのは、フロッピー ディスクの 2 番目のセクターに入れ、コンパイルする別のファイルをロードして実行することです。
では、残りのフロッピーを RAM にロードして実行するにはどうすればよいでしょうか?
100% 正確である必要はありません。必要な割り込みと「関数」を知り、学習する必要があるだけです :)
ブートローダーを共有するためだけに:
[BITS 16] ;set 16bit mode
[ORG 0x7C00] ; address location where the program will run
jmp main ;start on main
main:
mov si,hstr ; put the pointer into si register
call printstr ;print hstr
;call load_kernel
;here we gonna load kernel into memory and then we will run it.
mov si,mstr ; put the pointer into si register
call printstr ;print mstr
jmp hold ;idle the CPU
hold:
hlt ;idle CPU
printstr:
;This will write in TTY char that will be loaded into al 8bit register.
lodsb ;load into al
cmp al,0 ; set flag if al is 0
jnz print ; if isnt equal to 0 then jump to print
ret ;else return to main
print: ;print the char
mov ah,0x0E ;set the ah before calling the video interrupt
int 10h ;here we go
jmp printstr ;jump back
;
hstr db "Loading ...",13,10,0 ;define the strings. 13 is ASCII, 10 for new line, 0 is the null terminator
mstr db "CPU is now idle!",13,10,0
times 510 - ($-$$) db 0 ;fill the rest of the sector(less 2 last bytes) with 0's. 510-(here-start)=free space with 0's
dw 0xAA55 ;the last 2 bytes of the sector with AA55 signature. means that is the bootloader.