完成HLT

This commit is contained in:
Yourtion
2014-09-10 14:27:04 +08:00
parent 8fc2d2934e
commit c340174294
4 changed files with 35 additions and 4 deletions

View File

@@ -35,9 +35,12 @@ bootpack.nas : bootpack.gas Makefile
bootpack.obj : bootpack.nas Makefile
$(NASK) bootpack.nas bootpack.obj bootpack.lst
bootpack.bim : bootpack.obj Makefile
naskfunc.obj : naskfunc.nas Makefile
$(NASK) naskfunc.nas naskfunc.obj naskfunc.lst
bootpack.bim : bootpack.obj naskfunc.obj Makefile
$(OBJ2BIM) @$(RULEFILE) out:bootpack.bim stack:3136k map:bootpack.map \
bootpack.obj
bootpack.obj naskfunc.obj
# 3MB+64KB=3136KB
bootpack.hrb : bootpack.bim Makefile

View File

@@ -1,8 +1,15 @@
/* 告诉C编译器有一个函数在别的文件里 */
void io_hlt(void);
/* 是函数声明却不用{},而用;,这表示的意思是:
函数在别的文件中,你自己找一下 */
void HariMain(void)
{
fin:
/* 这里想写上HLT但是C语言中不能用HLT */
io_hlt(); /* 执行naskfunc.nas中的_io_hlt函数 */
goto fin;
}

View File

@@ -9,7 +9,7 @@ CYLS EQU 10 ; 声明CYLS=10
JMP entry
DB 0x90
DB "HELLOIPL" ; 启动扇区名称8字节
DB "HARIBOTE" ; 启动扇区名称8字节
DW 512 ; 每个扇区sector大小必须512字节
DB 1 ; 簇cluster大小必须为1个扇区
DW 1 ; FAT起始位置一般为第一个扇区

21
03_day/naskfunc.nas Normal file
View File

@@ -0,0 +1,21 @@
; naskfunc
; TAB=4
[FORMAT "WCOFF"] ; 制作目标文件的模式
[BITS 32] ; 制作32位模式用的机器语言
; 制作目标文件的信息
[FILE "naskfunc.nas"] ; 源文件名信息
GLOBAL _io_hlt ; 程序中包含的函数名
; 以下是实际的函数
[SECTION .text] ; 目标文件中写了这些后再写程序
_io_hlt: ; void io_hlt(void);
HLT
RET