2019-04-20 23:02:35 +02:00
|
|
|
cpu 8086
|
2019-09-08 03:04:01 +02:00
|
|
|
org 0x0100
|
2019-09-06 00:24:39 +02:00
|
|
|
push cs
|
|
|
|
pop es
|
|
|
|
mov di, isr_dos_main
|
|
|
|
mov ax, 0x21
|
|
|
|
call intr_register
|
|
|
|
|
2019-09-08 17:18:37 +02:00
|
|
|
int3
|
2019-09-03 12:58:06 +02:00
|
|
|
|
2019-08-31 00:18:05 +02:00
|
|
|
cli
|
2019-04-29 00:01:30 +02:00
|
|
|
.halt:
|
|
|
|
hlt
|
|
|
|
jmp .halt
|
2019-04-20 23:02:35 +02:00
|
|
|
|
2019-09-06 00:24:39 +02:00
|
|
|
isr_dos_main:
|
2019-09-08 17:18:37 +02:00
|
|
|
; Bail out if subfunction number too high
|
|
|
|
cmp ah, 0x0F
|
|
|
|
jnc isr_invalid
|
|
|
|
|
|
|
|
; allocate our return address
|
|
|
|
push bx
|
|
|
|
; actual BX backup
|
|
|
|
push bx
|
|
|
|
|
|
|
|
; transfer subfunction number into BX
|
|
|
|
xor bx, bx
|
|
|
|
mov bl, ah
|
|
|
|
; table offset = AH * 2
|
|
|
|
shl bx, 1
|
|
|
|
; fetch from table
|
|
|
|
mov bx, [dos_functions+bx]
|
|
|
|
|
|
|
|
; inject our address into the stack
|
|
|
|
add sp, 4
|
|
|
|
push bx
|
|
|
|
sub sp, 2
|
|
|
|
|
|
|
|
; restore BX
|
|
|
|
pop bx
|
|
|
|
; reads our address from the stack and jumps there
|
|
|
|
ret
|
|
|
|
|
|
|
|
; ISR for invalid subfunctions or unimplemented
|
|
|
|
isr_invalid:
|
|
|
|
mov bp, 0xFEFE
|
|
|
|
int3
|
|
|
|
.hlt:
|
|
|
|
hlt
|
|
|
|
jmp .hlt
|
|
|
|
; ISR tail to set carry flag to signal error
|
2019-09-06 00:24:39 +02:00
|
|
|
isr_error:
|
|
|
|
push bp
|
|
|
|
mov bp, sp
|
|
|
|
; set carry flag
|
|
|
|
or WORD [SS:BP+6], 1
|
|
|
|
pop bp
|
|
|
|
isr_return:
|
|
|
|
iret
|
|
|
|
|
2019-09-08 17:18:37 +02:00
|
|
|
; Table for DOS subfunctions
|
|
|
|
dos_functions:
|
|
|
|
; AH 00-03
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_getc_echo
|
|
|
|
dw isr_putc
|
|
|
|
dw isr_invalid
|
|
|
|
; AH 04-07
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
; AH 08-0B
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
; AH 0C-0F
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
dw isr_invalid
|
|
|
|
|
2019-09-03 12:58:06 +02:00
|
|
|
%include "intr.asm"
|
|
|
|
|
2019-09-06 00:24:39 +02:00
|
|
|
%include "chario.asm"
|
|
|
|
|
2019-09-08 17:18:37 +02:00
|
|
|
kernel_end:
|