From ff3319e083d6b32bd34aca8f5f2146cc5fe21ebe Mon Sep 17 00:00:00 2001 From: Yourtion Date: Tue, 3 May 2016 11:47:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E9=9A=8F=E6=93=8D=E4=BD=9C=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=89=88=E6=9C=AC=E8=80=8C=E6=94=B9=E5=8F=98=E7=9A=84?= =?UTF-8?q?API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 20_day/dsctbl.c | 1 + 20_day/hlt.nas | 10 +++++----- 20_day/naskfunc.nas | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/20_day/dsctbl.c b/20_day/dsctbl.c index ae81655..8714625 100644 --- a/20_day/dsctbl.c +++ b/20_day/dsctbl.c @@ -27,6 +27,7 @@ void init_gdtidt(void) set_gatedesc(idt + 0x21, (int) asm_inthandler21, 2 * 8, AR_INTGATE32); set_gatedesc(idt + 0x27, (int) asm_inthandler27, 2 * 8, AR_INTGATE32); set_gatedesc(idt + 0x2c, (int) asm_inthandler2c, 2 * 8, AR_INTGATE32); + set_gatedesc(idt + 0x40, (int) asm_cons_putchar, 2 * 8, AR_INTGATE32); return; } diff --git a/20_day/hlt.nas b/20_day/hlt.nas index 44a1079..99d8d83 100644 --- a/20_day/hlt.nas +++ b/20_day/hlt.nas @@ -1,12 +1,12 @@ [BITS 32] MOV AL,'h' - CALL 2*8:0xbe8 + INT 0x40 MOV AL,'e' - CALL 2*8:0xbe8 + INT 0x40 MOV AL,'l' - CALL 2*8:0xbe8 + INT 0x40 MOV AL,'l' - CALL 2*8:0xbe8 + INT 0x40 MOV AL,'o' - CALL 2*8:0xbe8 + INT 0x40 RETF diff --git a/20_day/naskfunc.nas b/20_day/naskfunc.nas index b6ed01e..5e4e000 100644 --- a/20_day/naskfunc.nas +++ b/20_day/naskfunc.nas @@ -218,10 +218,11 @@ _farcall: ; void farcall(int eip, int cs); RET _asm_cons_putchar: + STI PUSH 1 AND EAX,0xff ; 将AH和EAX的高位置0,将EAX置为已存入字符编码的状态 PUSH EAX PUSH DWORD [0x0fec] ; 读取内存并PUSH该值 CALL _cons_putchar ADD ESP,12 ; 将栈中的数据丢弃 - RETF + IRETD