From 5c10d16cd171d7992c5afffbda05401c780499d4 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Fri, 5 Sep 2014 14:49:14 +0800 Subject: [PATCH] Add day2 code --- 02_day/!cons_9x.bat | 1 + 02_day/!cons_nt.bat | 1 + 02_day/Makefile | 39 +++++++++++++++++++++++++++++ 02_day/ipl.nas | 60 +++++++++++++++++++++++++++++++++++++++++++++ 02_day/make.bat | 1 + 5 files changed, 102 insertions(+) create mode 100644 02_day/!cons_9x.bat create mode 100644 02_day/!cons_nt.bat create mode 100644 02_day/Makefile create mode 100644 02_day/ipl.nas create mode 100644 02_day/make.bat diff --git a/02_day/!cons_9x.bat b/02_day/!cons_9x.bat new file mode 100644 index 0000000..e42252a --- /dev/null +++ b/02_day/!cons_9x.bat @@ -0,0 +1 @@ +command \ No newline at end of file diff --git a/02_day/!cons_nt.bat b/02_day/!cons_nt.bat new file mode 100644 index 0000000..6e07473 --- /dev/null +++ b/02_day/!cons_nt.bat @@ -0,0 +1 @@ +cmd.exe \ No newline at end of file diff --git a/02_day/Makefile b/02_day/Makefile new file mode 100644 index 0000000..c595bc8 --- /dev/null +++ b/02_day/Makefile @@ -0,0 +1,39 @@ + +# デフォルト動作 + +default : + ../z_tools/make.exe img + +# ファイル生成規則 + +ipl.bin : ipl.nas Makefile + ../z_tools/nask.exe ipl.nas ipl.bin ipl.lst + +helloos.img : ipl.bin Makefile + ../z_tools/edimg.exe imgin:../z_tools/fdimg0at.tek \ + wbinimg src:ipl.bin len:512 from:0 to:0 imgout:helloos.img + +# コマンド + +asm : + ../z_tools/make.exe -r ipl.bin + +img : + ../z_tools/make.exe -r helloos.img + +run : + ../z_tools/make.exe img + copy helloos.img ..\z_tools\qemu\fdimage0.bin + ../z_tools/make.exe -C ../z_tools/qemu + +install : + ../z_tools/make.exe img + ../z_tools/imgtol.com w a: helloos.img + +clean : + -del ipl.bin + -del ipl.lst + +src_only : + ../z_tools/make.exe clean + -del helloos.img diff --git a/02_day/ipl.nas b/02_day/ipl.nas new file mode 100644 index 0000000..d7b1981 --- /dev/null +++ b/02_day/ipl.nas @@ -0,0 +1,60 @@ +; hello-os +; TAB=4 + + ORG 0x7c00 ; このプログラムがどこに読み込まれるのか + +; 以下は標準的なFAT12フォーマットフロッピーディスクのための記述 + + JMP entry + DB 0x90 + DB "HELLOIPL" ; ブートセクタの名前を自由に書いてよい(8バイト) + DW 512 ; 1セクタの大きさ(512にしなければいけない) + DB 1 ; クラスタの大きさ(1セクタにしなければいけない) + DW 1 ; FATがどこから始まるか(普通は1セクタ目からにする) + DB 2 ; FATの個数(2にしなければいけない) + DW 224 ; ルートディレクトリ領域の大きさ(普通は224エントリにする) + DW 2880 ; このドライブの大きさ(2880セクタにしなければいけない) + DB 0xf0 ; メディアのタイプ(0xf0にしなければいけない) + DW 9 ; FAT領域の長さ(9セクタにしなければいけない) + DW 18 ; 1トラックにいくつのセクタがあるか(18にしなければいけない) + DW 2 ; ヘッドの数(2にしなければいけない) + DD 0 ; パーティションを使ってないのでここは必ず0 + DD 2880 ; このドライブ大きさをもう一度書く + DB 0,0,0x29 ; よくわからないけどこの値にしておくといいらしい + DD 0xffffffff ; たぶんボリュームシリアル番号 + DB "HELLO-OS " ; ディスクの名前(11バイト) + DB "FAT12 " ; フォーマットの名前(8バイト) + RESB 18 ; とりあえず18バイトあけておく + +; プログラム本体 + +entry: + MOV AX,0 ; レジスタ初期化 + MOV SS,AX + MOV SP,0x7c00 + MOV DS,AX + MOV ES,AX + + MOV SI,msg +putloop: + MOV AL,[SI] + ADD SI,1 ; SIに1を足す + CMP AL,0 + JE fin + MOV AH,0x0e ; 一文字表示ファンクション + MOV BX,15 ; カラーコード + INT 0x10 ; ビデオBIOS呼び出し + JMP putloop +fin: + HLT ; 何かあるまでCPUを停止させる + JMP fin ; 無限ループ + +msg: + DB 0x0a, 0x0a ; 改行を2つ + DB "hello, world" + DB 0x0a ; 改行 + DB 0 + + RESB 0x7dfe-$ ; 0x7dfeまでを0x00で埋める命令 + + DB 0x55, 0xaa diff --git a/02_day/make.bat b/02_day/make.bat new file mode 100644 index 0000000..e489766 --- /dev/null +++ b/02_day/make.bat @@ -0,0 +1 @@ +..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 \ No newline at end of file