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