OS(?) でHello worldしてみた
この記事を見てやりました。
OSを書く:初歩から一歩ずつ | プログラミング | POSTD
環境
Ubuntu Server 64bit
|
|
書いたソースコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; boot.asm | |
; setup segment register | |
mov ax, 0x07c0 | |
mov ds, ax | |
; setup display | |
mov ah, 0x0 ;setup video mode | |
mov al, 0x3 ;0x3 = text mode, color, 80x25 | |
int 0x10 ;0x10 = video service | |
mov si, msg ;target of lodsb | |
mov ah, 0x0E ;0x0E = tty | |
print_character_loop: | |
lodsb | |
or al, al | |
jz hang ;jump if zero | |
int 0x10 ;when ah is 0x0E, then print | |
jmp print_character_loop | |
msg: | |
db 'Hello World!', 13, 10, 0 ;13 = \r, 10 = \n, 0 = NULL | |
hang: | |
jmp hang | |
times 510-($-$$) db 0 | |
; this is a comment | |
db 0x55 | |
db 0xAA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boot.bin: boot.asm | |
nasm -f bin boot.asm -o boot.bin | |
qemu: boot.bin | |
qemu-system-x86_64 -curses boot.bin | |
clean: | |
rm *.bin |
※qemu実行時の引数について、ssh越しにターミナルで作業していたので、-cursesオプションを付けて起動しています。
作業中の様子
ブートローダーとか書くのは面倒くさそうだなぁ……といったところで、一旦ここまでで終了としました。
一応全部の命令の内容を確認できたので、若干勉強にはなったかなぁと。