From e1d760124cdba9f6bf876b7803c2f24237be401a Mon Sep 17 00:00:00 2001 From: Yourtion Date: Wed, 4 May 2016 16:59:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8C=E8=AF=AD=E8=A8=80=E7=BC=96=E5=86=99?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 21_day/Makefile | 17 ++++++++++++++++- 21_day/a.c | 7 +++++++ 21_day/a_nask.nas | 14 ++++++++++++++ 21_day/console.c | 8 ++++++++ 21_day/hello3.c | 11 +++++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 21_day/a.c create mode 100644 21_day/a_nask.nas create mode 100644 21_day/hello3.c diff --git a/21_day/Makefile b/21_day/Makefile index 502df1c..efd8cfe 100644 --- a/21_day/Makefile +++ b/21_day/Makefile @@ -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 # 其他指令 diff --git a/21_day/a.c b/21_day/a.c new file mode 100644 index 0000000..0afb794 --- /dev/null +++ b/21_day/a.c @@ -0,0 +1,7 @@ +void api_putchar(int c); + +void HariMain(void) +{ + api_putchar('A'); + return; +} diff --git a/21_day/a_nask.nas b/21_day/a_nask.nas new file mode 100644 index 0000000..68f3c03 --- /dev/null +++ b/21_day/a_nask.nas @@ -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 diff --git a/21_day/console.c b/21_day/console.c index 051ed8a..bf8a05d 100644 --- a/21_day/console.c +++ b/21_day/console.c @@ -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); diff --git a/21_day/hello3.c b/21_day/hello3.c new file mode 100644 index 0000000..17a53ad --- /dev/null +++ b/21_day/hello3.c @@ -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; +}