From c718be8fd394ec23f608a7b4d6727a3b953401e8 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Mon, 9 May 2016 13:48:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8C=E8=AF=AD=E8=A8=80=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=EF=BC=881=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 22_day/Makefile | 11 ++++++++++- 22_day/a_nask.nas | 10 ++++++++++ 22_day/hello4.c | 8 ++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 22_day/hello4.c diff --git a/22_day/Makefile b/22_day/Makefile index 4f9d08d..a0f187d 100644 --- a/22_day/Makefile +++ b/22_day/Makefile @@ -67,6 +67,13 @@ hello3.bim : hello3.obj a_nask.obj Makefile hello3.hrb : hello3.bim Makefile $(BIM2HRB) hello3.bim hello3.hrb 0 +hello4.bim : hello4.obj a_nask.obj Makefile + $(OBJ2BIM) @$(RULEFILE) out:hello4.bim stack:1k map:hello4.map \ + hello4.obj a_nask.obj + +hello4.hrb : hello4.bim Makefile + $(BIM2HRB) hello4.bim hello4.hrb 0 + bug1.bim : bug1.obj Makefile $(OBJ2BIM) @$(RULEFILE) out:bug1.bim map:bug1.map bug1.obj a_nask.obj @@ -86,7 +93,8 @@ bug3.hrb : bug3.bim Makefile $(BIM2HRB) bug3.bim bug3.hrb 0 haribote.img : ipl10.bin haribote.sys Makefile \ - hello.hrb hello2.hrb a.hrb hello3.hrb bug1.hrb bug2.hrb bug3.hrb + hello.hrb hello2.hrb a.hrb hello3.hrb bug1.hrb bug2.hrb bug3.hrb \ + hello4.hrb $(EDIMG) imgin:../z_tools/fdimg0at.tek \ wbinimg src:ipl10.bin len:512 from:0 to:0 \ copy from:haribote.sys to:@: \ @@ -99,6 +107,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \ copy from:bug1.hrb to:@: \ copy from:bug2.hrb to:@: \ copy from:bug3.hrb to:@: \ + copy from:hello4.hrb to:@: \ imgout:haribote.img # 其他指令 diff --git a/22_day/a_nask.nas b/22_day/a_nask.nas index 28b00f5..7a71f20 100644 --- a/22_day/a_nask.nas +++ b/22_day/a_nask.nas @@ -4,6 +4,7 @@ [FILE "a_nask.nas"] ; 源文件名信息 GLOBAL _api_putchar + GLOBAL _api_putstr0 GLOBAL _api_end [SECTION .text] @@ -13,6 +14,15 @@ _api_putchar: ; void api_putchar(int c); MOV AL,[ESP+4] ; c INT 0x40 RET + +_api_putstr0: ; void api_putstr0(char *s); + PUSH EBX + MOV EDX,2 + MOV EBX,[ESP+8] ; s + INT 0x40 + POP EBX + RET + _api_end: ; void api_end(void); MOV EDX,4 INT 0x40 diff --git a/22_day/hello4.c b/22_day/hello4.c new file mode 100644 index 0000000..269cb9d --- /dev/null +++ b/22_day/hello4.c @@ -0,0 +1,8 @@ +void api_putstr0(int c); +void api_end(void); + +void HariMain(void) +{ + api_putstr0('hello, world\n'); + api_end(); +}