diff --git a/kernel/intr.asm b/kernel/intr.asm index 8da59e2..666c3c3 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -1,23 +1,15 @@ -; out ds:si copy of interrupt table ivt_backup: - push ax - push cx - push di ; backup original value push ds - mov ax, 0x80 - call malloc - push di - mov cx, 0x80 - mov ax, cs + push es + xor ax, ax + mov ds, ax mov es, ax - mov si, 0x0000 - mov ds, si - rep movsb - pop si ; this was di after malloc + mov si, ax + mov di, 0x0100 ; int 0x40 address + mov cx, 0x0040 ; 0x20 interrupts * 2 words + repe movsw + pop es pop ds - pop di ; restore original di - pop cx - pop ax ret ; set item in interrupt vector table @@ -34,7 +26,7 @@ ivt_set: sal bx,1 mov [es:bx], dx - mov [es:bx+2], ds + mov [es:bx+2], cs pop ax pop es diff --git a/kernel/main.asm b/kernel/main.asm index 30640e6..bfe8dd7 100644 --- a/kernel/main.asm +++ b/kernel/main.asm @@ -4,18 +4,51 @@ org 0x0000 _startup: mov ax, cs + mov ds, ax + mov es, ax mov ss, ax mov sp, 0x0000 main: - mov ax, cs + xor ax, ax mov ds, ax + mov si, ax + mov cx, ax - call heap_init - call ivt_backup call debug_init - int 0x2E + call ivt_backup + + xor ax, ax + mov ds, ax + mov es, ax + xor cx, cx + mov si, ax +.loop: + mov ax, cx + call kprint8 + mov al, '=' + call kputc + lodsw + xchg ax, dx + lodsw + call kprint16 + mov al, ':' + call kputc + xchg ax, dx + call kprint16 + mov al, ' ' + call kputc + inc cx + test cx, 0x0003 + jnz .loop + mov al, 0x0A + call kputc + mov al, 0x0D + call kputc + cmp cx, 0x0060 + jl .loop + .halt: hlt jmp .halt