引き続き、頑張る。。。
朝活!!
昨日は気力無く寝てしまった。。(涙)
一応、体重は測っていたので書いておく。
71.8kg...
さて、すげー基本的な事が分かるのに時間がかかる。。
Web見ても、本見ても、どこにも悩んだようなコメントがないって事は
先人は悩む事なく理解ができたんであろう。。。。
セグメントレジスタ。。
確かに、ES:BXなんかは、MOV AL,[ES:BX]って書いて使うそうですな。。
(昔アセンブラ勉強してた時に、もっとちゃんとやっておけばよかった。。
そもそも、ちゃんとやってないし、忘れてしまってるし。。)
この場合、ES x 16 + BXで計算するって事になっていると。。
ふむ。
next:
MOV AX,ES ; アドレスを0x200進める
ADD AX,0x0020
MOV ES,AX ; ADD ES,0x020 という命令がないのでこうしている
ADD CL,1 ; CLに1を足す
CMP CL,18 ; CLと18を比較
JBE readloop ; CL <= 18 だったらreadloopへ
この赤字部分ね。。
何で、こうなっているのか?
これが、きちんと分かるのに時間が掛かっちまった。(涙)
ようするに、ES = 0x20 x 16 → ES += 0x200 って事になるのね。。。
頭良くなりたい。。。(もうおっさんだから厳しいけど。。)
確かに、きちんと本に説明してある通りなんだよな。。
(理解力低いって、悲しい。。。)
さて、そのまま進んでいくと次にはバイナリエディタ使ってみる所。
先人の方のお勧めに従い、Hex Friendを利用。
Hex Fiend on the Mac App Store
Macでやるのにnasm使ったりしているからなのか、アドレスとかが
本と違うけど、何故だろう。。。
って、オィ!!!(アドレスの表記が、Hexじゃないのね。。)
なんか、情けない。。
という事で、ここで今まで流していたけど、ちょっとMakefile内の下記記述が
気になったのでちゃんと調べてみた。
haribote.img : ipl.bin haribote.sys Makefile
mformat -f 1440 -C -B ipl.bin -i haribote.img ::
mcopy -i haribote.img haribote.sys ::
〜 man mformat 〜
mformat(1)
Name
mformat - add an MSDOS filesystem to a low-level formatted floppy disk
Note of warning
This manpage has been automatically generated from mtools's texinfo documentation, and may not be entirely accurate or complete.
See the end of this man page for details.
Description
The mformat command is used to add an MS-DOS file system to a low-level formatted diskette. Its syntax is:
mformat [-t cylinders|-T tot_sectors] [-h heads] [-s sectors]
[-f size] [-1] [-4] [-8]
[-v volume_label]
[-F] [-S sizecode]
[-M software_sector_size]
[-N serial_number] [-a]
[-C] [-H hidden_sectors] [-I fsVersion]
[-r root_sectors] [-L fat_len]
[-B boot_sector] [-k]
[-m media_descriptor]
[-K backup_boot]
[-R nb_reserved_sectors]
[-c clusters_per_sector]
[-d fat_copies]
[-X] [-2 sectors_on_track_0] [-3]
[-0 rate_on_track_0] [-A rate_on_other_tracks]
drive:
ふむ。。。(-f OK, -C OK, -B OK, -i ?, :: ????????(:はドライブって事なのか?))
オプションの意味が。。。(Orz...)
でも、ここでも先人がいた!!!(ありがとう!)
OS自作入門 on Linux [day 2] - Caronte
ここによると、
-i : 書き出すイメージファイルを指定するオプション
:: は、多分ドライブ: の事だろうと。。。
という事で、mformatはクリア!!
mcopyも同様に man!!
〜 man mcopy 〜
mcopy(1) mcopy(1)
Name
mcopy - copy MSDOS files to/from Unix
Note of warning
This manpage has been automatically generated from mtools's texinfo documentation, and may not be entirely accurate or complete.
See the end of this man page for details.
Description
The mcopy command is used to copy MS-DOS files to and from Unix. It uses the following syntax:
mcopy [-bspanvmQT] [-D clash_option] sourcefile targetfile
mcopy [-bspanvmQT] [-D clash_option] sourcefile [ sourcefiles... ] targetdirectory
mcopy [-tnvm] MSDOSsourcefile
Mcopy copies the specified file to the named file, or copies multiple files to the named directory. The source and target can be
また、オプション無いし。。
まぁ、でも -i はイメージファイルで、後ろのharibote.sysをくっつけているんだろうって
事で調べてみたら、やっぱりそうだった。。
通常通りだと(mcopy使って、haribote.imgにharibote.sysをくっつける)
これは、本に書いてある通り!(当然だ。)
Makefileでmcopy部分を除いて実行してみた。
make img
make -r haribote.img
nasm ipl.nas -o ipl.bin -l ipl.lst
nasm haribote.nas -o haribote.sys -l haribote.lst
mformat -f 1440 -C -B ipl.bin -i haribote.img ::
当たり前の結果だけど、私的にはちゃんと確認できたので嬉しい。
という事で、mcopyによってharibote.imgとharibote.sysがくっ付けられた。
その先頭アドレスが、0x4200って事。
ふむ。よかた。。。
理解が深まった気がする。。(普通の人は、こんなに苦労しないんだろうな。。)
つづく。