■
今宵も遅くなりまひた。
今日は、寝ずに起きられている。。
体重は、72.1kg..
まぁ、変わっていないな。。
で、本の3日目最後へ。。
C言語のプログラムからアセンブラで記述した関数を呼び出す所まで。
これなら、この状況でも行けるのでは。。(今日はすんなり行く予感。)
同じく ipl10.nasのJMP先を変更(0xc200→0xc330)し、nasmで必要となる部分の
修正を各アセンブラコードへ修正し、Makefileを下記のような修正。
(基本、先人のパクリだけど、haribo00iで苦労した点は反映する。)
MAKE = make -r
DEL = rm -f
# デフォルト動作
default :
$(MAKE) img
# ファイル生成規則
ipl10.bin : ipl10.nas Makefile
nasm ipl10.nas -o ipl10.bin -l ipl10.lst
asmhead.bin : asmhead.nas Makefile
# nasm asmhead.nas -o asmhead.bin -l asmhead.lst
nasm -f elf32 asmhead.nas -o asmhead.bin -l asmhead.lst
naskfunc.o : naskfunc.nas Makefile # naskfunc.nasのバイナリファイル作成
# nasm -g -f elf naskfunc.nas -o naskfunc.o -l naskfunc.lst
nasm -f elf32 naskfunc.nas -o naskfunc.o -l naskfunc.lst
bootpack.hrb : bootpack.c hrb.ld naskfunc.o Makefile # リンク,コンパイル
# i386-elf-gcc -march=i486 -m32 -nostdlib -T hrb.ld -g bootpack.c naskfunc.o -o bootpack.hrb
x86_64-elf-gcc -c -march=i486 -m32 -nostdlib bootpack.c -o bootpack.o
x86_64-elf-ld -m elf_i386 -e HariMain -o bootpack.hrb -T hrb.ld bootpack.o naskfunc.o
haribote.sys : asmhead.bin bootpack.hrb Makefile
cat asmhead.bin bootpack.hrb > haribote.sys
haribote.img : ipl10.bin haribote.sys Makefile
mformat -f 1440 -C -B ipl10.bin -i haribote.img ::
mcopy -i haribote.img haribote.sys ::
# コマンド
img :
$(MAKE) haribote.img
run :
$(MAKE) img
qemu-system-i386 -drive file=haribote.img,format=raw,if=floppy -boot a
clean :
-$(DEL) *.bin
-$(DEL) *.lst
-$(DEL) *.o
-$(DEL) *.sys
-$(DEL) *.hrb
src_only :
$(MAKE) clean
-$(DEL) haribote.img
という事で、実行してみよう。
さて、結果は。。。
$ make run
make -r img
make -r haribote.img
nasm ipl10.nas -o ipl10.bin -l ipl10.lst
nasm -f elf32 asmhead.nas -o asmhead.bin -l asmhead.lst
nasm -f elf32 naskfunc.nas -o naskfunc.o -l naskfunc.lst
x86_64-elf-gcc -c -march=i486 -m32 -nostdlib bootpack.c -o bootpack.o
x86_64-elf-ld -m elf_i386 -e HariMain -o bootpack.hrb -T hrb.ld bootpack.o naskfunc.o
cat asmhead.bin bootpack.hrb > haribote.sys
mformat -f 1440 -C -B ipl10.bin -i haribote.img ::
mcopy -i haribote.img haribote.sys ::
qemu-system-i386 -drive file=haribote.img,format=raw,if=floppy -boot a
おっす!行ったぜぃ!!
という事で、今夜は無事に期待通りに3日目を完了。
(まぁ、騙し騙しだけど。。。)
続く。