■
同日に、早速投稿する事に!!!
いやいやいや。。。。。
Day1の作業実施してみたら。。。
../../z_tools/nask helloos.nas helloos.img
make: ../../z_tools/nask: Bad CPU type in executable
make: *** [run] Error 1
涙(終わた。。。)
調べた所、Catalinaでは、32bitアプリが動作しなくなった為、従来の macOS向けの
ブログ記事にあるような各種条件では動かなくなった模様。。。
でも、そんな所にやはり先人がいた!!
『30日でできる!OS自作入門』を macOS Catalina で実行する - Qiita
っほ。。(ありがとうー!!いきなり死なずに済んだ。。)
Githubにもコード上げてくれてる。。(涙)
GitHub - noanoa07/myHariboteOS: 『30日でできる!OS自作入門』 for macOS Catalina
という訳で、Day1作業をとりあえず試してみた。。
おぉぉぉー!!!!
よかた。。。
これで、初日で終わらずに済んだ。。。
という訳で、元々の32bit用環境のMakefileをちょっとだけ変更して実行!
(なるべく元ファイル変えない様に、nasmをz_tools下へ配置(しなくても良いけど。。)
$ make run
../../z_tools/nasm helloos.nas -o helloos.img
helloos.nas:9: warning: uninitialized space declared in .text section: zeroing [-w+other]
helloos.nas:17: warning: uninitialized space declared in .text section: zeroing [-w+other]
helloos.nas:20: warning: uninitialized space declared in .text section: zeroing [-w+other]
helloos.nas:22: warning: uninitialized space declared in .text section: zeroing [-w+other]
cp helloos.img ../../z_tools/qemu/fdimage0.bin
make -C ../../z_tools/qemu
qemu-system-i386 -L . -m 32 -rtc base=localtime -vga std -drive file=fdimage0.bin,index=0,if=floppy,format=raw
よかた。。。。(warningは出てるけど。。。)
これで、初日の作業が終わた。(セーフ。。)
先人の皆様ありがとう!!って事で、ついに実際にアセンブラ記述スタート!!
って思って次のステップ始めたら、更に。。。
make run
nasm helloos.nas -o helloos.img
helloos.nas:41: error: attempt to reserve non-constant quantity of BSS space
make: *** [run] Error 1
Orz ....(涙)
こりゃ、先が思いやられる。。。
調べてみた所、やはりここにも先人が!
Ubuntu 18.04で30日OS自作入門をやりたい[1日目] - free(malloc(sizeof(MRM)));
hellos.nasの41行目にある " RESB 0x1fe-$ " って行がまずいらしい。。。
Web情報によると510( = 0x1fe)バイトまで0で埋め尽くすための命令との事。
RESB 0x1fe-($-$$)とするべきみたいです。nasmでは$はその行の最初、$$は現在のセクションの最初を表すみたいなのでセクション内でどれぐらい離れてるか知るには$ - $$とすればいいという事らしい。(まぁ、詳細はともかく、これで良いらしい。。)
で、やってみると。。
make run
nasm helloos.nas -o helloos.img
helloos.nas:24: warning: uninitialized space declared in .text section: zeroing [-w+other]
helloos.nas:41: warning: uninitialized space declared in .text section: zeroing [-w+other]
helloos.nas:48: warning: uninitialized space declared in .text section: zeroing [-w+other]
helloos.nas:50: warning: uninitialized space declared in .text section: zeroing [-w+other]
cp helloos.img ../../z_tools/qemu/fdimage0.bin
make -C ../../z_tools/qemu
qemu-system-i386 -L . -m 32 -rtc base=localtime -vga std -drive file=fdimage0.bin,index=0,if=floppy,format=raw
う〜ん。。。
エラーは無くなったけど、やはりまだ残っているwarningが嫌だなぁ〜って思い始めたので
調べた所、このRESB 18っていう所が関連しているそうで、TIMESって命令を使って下記の
ようにwarningが出ている各行を書き直さなくてはならないみたい。
RESB 18 → TIMES 18 DB 0
make run
nasm helloos.nas -o helloos.img
cp helloos.img ../../z_tools/qemu/fdimage0.bin
make -C ../../z_tools/qemu
qemu-system-i386 -L . -m 32 -rtc base=localtime -vga std -drive file=fdimage0.bin,index=0,if=floppy,format=raw
おぉぉぉ!! warningも無くなり、すっきり!!
やった!!
長い1日目になってしまった。
先が思いやられる。。。
p.s
一つ文字コードの変換しないとソースのコメントが文字化けしてた。。
これでOK!!
ちなみに、下記はメモ(上書きしなくない場合は、overwriteオプション使わずファイル出力)
Shift-JISをEUC-JPへ変換: nkf -eLu --overwrite filename
EUC-JPをShift-JISへ変換: nkf -sLw --overwrite filename
UTF-8へ変換: nkf -w8Lu --overwrite filename