Compare commits

..

4 Commits

Author SHA1 Message Date
Yourtion
ff3319e083 不随操作系统版本而改变的API 2016-05-03 11:47:17 +08:00
Yourtion
984b2886d0 不结束应用程序 2016-05-03 11:42:02 +08:00
Yourtion
a381fbedc3 显示单个字符的API(2) 2016-05-03 11:36:51 +08:00
Yourtion
4054ce43ab 显示单个字符的API(1) 2016-05-03 11:35:21 +08:00
5 changed files with 34 additions and 7 deletions

View File

@@ -30,6 +30,8 @@ void asm_inthandler27(void);
void asm_inthandler2c(void);
unsigned int memtest_sub(unsigned int start, unsigned int end);
void farjmp(int eip, int cs);
void farcall(int eip, int cs);
void asm_cons_putchar(void);
/* fifo.c */
struct FIFO32 {

View File

@@ -16,6 +16,7 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
cons.cur_x = 8;
cons.cur_y = 28;
cons.cur_c = -1;
*((int *) 0x0fec) = (int) &cons;
fifo32_init(&task->fifo, 128, fifobuf, task);
timer = timer_alloc();
@@ -255,7 +256,7 @@ void cmd_hlt(struct CONSOLE *cons, int *fat)
p = (char *) memman_alloc_4k(memman, finfo->size);
file_loadfile(finfo->clustno, finfo->size, p, fat, (char *) (ADR_DISKIMG + 0x003e00));
set_segmdesc(gdt + 1003, finfo->size - 1, (int) p, AR_CODE32_ER);
farjmp(0, 1003 * 8);
farcall(0, 1003 * 8);
memman_free_4k(memman, (int) p, finfo->size);
} else {
/*没有找到文件的情况*/

View File

@@ -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;
}

View File

@@ -1,5 +1,12 @@
[BITS 32]
CLI
fin:
HLT
JMP fin
MOV AL,'h'
INT 0x40
MOV AL,'e'
INT 0x40
MOV AL,'l'
INT 0x40
MOV AL,'l'
INT 0x40
MOV AL,'o'
INT 0x40
RETF

View File

@@ -16,9 +16,11 @@
GLOBAL _asm_inthandler20, _asm_inthandler21
GLOBAL _asm_inthandler27, _asm_inthandler2c
GLOBAL _memtest_sub
GLOBAL _farjmp
GLOBAL _farjmp, _farcall
GLOBAL _asm_cons_putchar
EXTERN _inthandler20, _inthandler21
EXTERN _inthandler27, _inthandler2c
EXTERN _cons_putchar
[SECTION .text]
@@ -209,4 +211,18 @@ mts_fin:
_farjmp: ; void farjmp(int eip, int cs);
JMP FAR [ESP+4] ; eip, cs
RET
RET
_farcall: ; void farcall(int eip, int cs);
CALL FAR [ESP+4] ; eip, 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 ; 将栈中的数据丢弃
IRETD