forked from backup/30dayMakeOS
用C语言编写应用程序
This commit is contained in:
@@ -52,10 +52,23 @@ hello.hrb : hello.nas Makefile
|
||||
hello2.hrb : hello2.nas Makefile
|
||||
$(NASK) hello2.nas hello2.hrb hello2.lst
|
||||
|
||||
a.bim : a.obj a_nask.obj Makefile
|
||||
$(OBJ2BIM) @$(RULEFILE) out:a.bim map:a.map a.obj a_nask.obj
|
||||
|
||||
a.hrb : a.bim Makefile
|
||||
$(BIM2HRB) a.bim a.hrb 0
|
||||
|
||||
hello3.bim : hello3.obj a_nask.obj Makefile
|
||||
$(OBJ2BIM) @$(RULEFILE) out:hello3.bim map:hello3.map hello3.obj a_nask.obj
|
||||
|
||||
hello3.hrb : hello3.bim Makefile
|
||||
$(BIM2HRB) hello3.bim hello3.hrb 0
|
||||
|
||||
haribote.sys : asmhead.bin bootpack.hrb Makefile
|
||||
copy /B asmhead.bin+bootpack.hrb haribote.sys
|
||||
|
||||
haribote.img : ipl10.bin haribote.sys hello.hrb hello2.hrb Makefile
|
||||
haribote.img : ipl10.bin haribote.sys Makefile \
|
||||
hello.hrb hello2.hrb a.hrb hello3.hrb
|
||||
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
||||
wbinimg src:ipl10.bin len:512 from:0 to:0 \
|
||||
copy from:haribote.sys to:@: \
|
||||
@@ -63,6 +76,8 @@ haribote.img : ipl10.bin haribote.sys hello.hrb hello2.hrb Makefile
|
||||
copy from:make.bat to:@: \
|
||||
copy from:hello.hrb to:@: \
|
||||
copy from:hello2.hrb to:@: \
|
||||
copy from:a.hrb to:@: \
|
||||
copy from:hello3.hrb to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
# 其他指令
|
||||
|
||||
7
21_day/a.c
Normal file
7
21_day/a.c
Normal file
@@ -0,0 +1,7 @@
|
||||
void api_putchar(int c);
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
api_putchar('A');
|
||||
return;
|
||||
}
|
||||
14
21_day/a_nask.nas
Normal file
14
21_day/a_nask.nas
Normal file
@@ -0,0 +1,14 @@
|
||||
[FORMAT "WCOFF"] ; 生成对象文件的模式
|
||||
[INSTRSET "i486p"] ; 表示使用486兼容指令集
|
||||
[BITS 32] ; 生成32位模式机器语言
|
||||
[FILE "a_nask.nas"] ; 源文件名信息
|
||||
|
||||
GLOBAL _api_putchar
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_api_putchar: ; void api_putchar(int c);
|
||||
MOV EDX,1
|
||||
MOV AL,[ESP+4] ; c
|
||||
INT 0x40
|
||||
RET
|
||||
@@ -287,6 +287,14 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
|
||||
*((int *) 0xfe8) = (int) p;
|
||||
file_loadfile(finfo->clustno, finfo->size, p, fat, (char *) (ADR_DISKIMG + 0x003e00));
|
||||
set_segmdesc(gdt + 1003, finfo->size - 1, (int) p, AR_CODE32_ER);
|
||||
if (finfo->size >= 8 && strncmp(p + 4, "Hari", 4) == 0) {
|
||||
p[0] = 0xe8;
|
||||
p[1] = 0x16;
|
||||
p[2] = 0x00;
|
||||
p[3] = 0x00;
|
||||
p[4] = 0x00;
|
||||
p[5] = 0xcb;
|
||||
}
|
||||
farcall(0, 1003 * 8);
|
||||
memman_free_4k(memman, (int) p, finfo->size);
|
||||
cons_newline(cons);
|
||||
|
||||
11
21_day/hello3.c
Normal file
11
21_day/hello3.c
Normal file
@@ -0,0 +1,11 @@
|
||||
void api_putchar(int c);
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
api_putchar('h');
|
||||
api_putchar('e');
|
||||
api_putchar('l');
|
||||
api_putchar('l');
|
||||
api_putchar('o');
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user