mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-02 17:49:01 +08:00
用C语言显示字符串(2)
This commit is contained in:
@@ -74,6 +74,12 @@ hello4.bim : hello4.obj a_nask.obj Makefile
|
||||
hello4.hrb : hello4.bim Makefile
|
||||
$(BIM2HRB) hello4.bim hello4.hrb 0
|
||||
|
||||
hello5.bim : hello5.obj Makefile
|
||||
$(OBJ2BIM) @$(RULEFILE) out:hello5.bim stack:1k map:hello5.map hello5.obj
|
||||
|
||||
hello5.hrb : hello5.bim Makefile
|
||||
$(BIM2HRB) hello5.bim hello5.hrb 0
|
||||
|
||||
bug1.bim : bug1.obj Makefile
|
||||
$(OBJ2BIM) @$(RULEFILE) out:bug1.bim map:bug1.map bug1.obj a_nask.obj
|
||||
|
||||
@@ -94,7 +100,7 @@ bug3.hrb : bug3.bim Makefile
|
||||
|
||||
haribote.img : ipl10.bin haribote.sys Makefile \
|
||||
hello.hrb hello2.hrb a.hrb hello3.hrb bug1.hrb bug2.hrb bug3.hrb \
|
||||
hello4.hrb
|
||||
hello4.hrb hello5.hrb
|
||||
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
||||
wbinimg src:ipl10.bin len:512 from:0 to:0 \
|
||||
copy from:haribote.sys to:@: \
|
||||
@@ -108,6 +114,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \
|
||||
copy from:bug2.hrb to:@: \
|
||||
copy from:bug3.hrb to:@: \
|
||||
copy from:hello4.hrb to:@: \
|
||||
copy from:hello5.hrb to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
# 其他指令
|
||||
|
||||
@@ -258,7 +258,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
|
||||
struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT;
|
||||
char name[18], *p, *q;
|
||||
struct TASK *task = task_now();
|
||||
int i;
|
||||
int i, segsiz, datsiz, esp, dathrb;
|
||||
|
||||
/*根据命令行生成文件名*/
|
||||
for (i = 0; i < 13; i++) {
|
||||
@@ -284,22 +284,25 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
|
||||
if (finfo != 0) {
|
||||
/*找到文件的情况*/
|
||||
p = (char *) memman_alloc_4k(memman, finfo->size);
|
||||
q = (char *) memman_alloc_4k(memman, 64 * 1024);
|
||||
*((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 + 0x60);
|
||||
set_segmdesc(gdt + 1004, 64 * 1024 - 1, (int) q, AR_DATA32_RW + 0x60);
|
||||
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;
|
||||
}
|
||||
start_app(0, 1003 * 8, 64 * 1024, 1004 * 8, &(task->tss.esp0));
|
||||
if (finfo->size >= 36 && strncmp(p + 4, "Hari", 4) == 0 && *p == 0x00) {
|
||||
segsiz = *((int *) (p + 0x0000));
|
||||
esp = *((int *) (p + 0x000c));
|
||||
datsiz = *((int *) (p + 0x0010));
|
||||
dathrb = *((int *) (p + 0x0014));
|
||||
q = (char *) memman_alloc_4k(memman, segsiz);
|
||||
*((int *) 0xfe8) = (int) q;
|
||||
set_segmdesc(gdt + 1003, finfo->size - 1, (int) p, AR_CODE32_ER + 0x60);
|
||||
set_segmdesc(gdt + 1004, segsiz - 1, (int) q, AR_DATA32_RW + 0x60);
|
||||
for (i = 0; i < datsiz; i++) {
|
||||
q[esp + i] = p[dathrb + i];
|
||||
}
|
||||
start_app(0x1b, 1003 * 8, esp, 1004 * 8, &(task->tss.esp0));
|
||||
memman_free_4k(memman, (int) q, segsiz);
|
||||
} else {
|
||||
cons_putstr0(cons, ".hrb file format error.\n");
|
||||
}
|
||||
memman_free_4k(memman, (int) p, finfo->size);
|
||||
memman_free_4k(memman, (int) q, 64 * 1024);
|
||||
cons_newline(cons);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
void api_putstr0(int c);
|
||||
void api_putstr0(char *s);
|
||||
void api_end(void);
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
api_putstr0('hello, world\n');
|
||||
api_putstr0("hello, world\n");
|
||||
api_end();
|
||||
}
|
||||
|
||||
20
22_day/hello5.nas
Normal file
20
22_day/hello5.nas
Normal file
@@ -0,0 +1,20 @@
|
||||
[FORMAT "WCOFF"]
|
||||
[INSTRSET "i486p"]
|
||||
[BITS 32]
|
||||
[FILE "hello5.nas"]
|
||||
|
||||
GLOBAL _HariMain
|
||||
|
||||
[SECTION .text]
|
||||
|
||||
_HariMain:
|
||||
MOV EDX,2
|
||||
MOV EBX,msg
|
||||
INT 0x40
|
||||
MOV EDX,4
|
||||
INT 0x40
|
||||
|
||||
[SECTION .data]
|
||||
|
||||
msg:
|
||||
DB "hello, world", 0x0a, 0
|
||||
Reference in New Issue
Block a user