Skip to content

Commit

Permalink
Add day2 code
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed Sep 5, 2014
1 parent 0286c39 commit 5c10d16
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions 02_day/!cons_9x.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
command
1 change: 1 addition & 0 deletions 02_day/!cons_nt.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmd.exe
39 changes: 39 additions & 0 deletions 02_day/Makefile
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions 02_day/ipl.nas
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions 02_day/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

0 comments on commit 5c10d16

Please sign in to comment.