Implement file descriptor table and CON as file descriptor
This commit is contained in:
parent
65564b78af
commit
f9b180ea57
3 changed files with 63 additions and 6 deletions
22
kernel/con.asm
Normal file
22
kernel/con.asm
Normal file
|
@ -0,0 +1,22 @@
|
|||
con_ftab: dw con_read
|
||||
dw con_write
|
||||
|
||||
con_read: stc
|
||||
ret
|
||||
|
||||
con_write: push si
|
||||
push bx
|
||||
push cx
|
||||
test cx, cx
|
||||
jz .end
|
||||
mov si, dx
|
||||
mov ah, 0x0E
|
||||
xor bx, bx
|
||||
.loop: lodsb
|
||||
int 0x10
|
||||
loop .loop
|
||||
pop cx
|
||||
.end: pop bx
|
||||
pop si
|
||||
ret
|
||||
|
32
kernel/fd.asm
Normal file
32
kernel/fd.asm
Normal file
|
@ -0,0 +1,32 @@
|
|||
%define fd_num 32
|
||||
|
||||
section .bss
|
||||
|
||||
fd_table: resb (0x10 * fd_num)
|
||||
|
||||
section .text
|
||||
|
||||
fd_to_ptr: push cx
|
||||
mov cl, 4
|
||||
sal bx, cl
|
||||
add bx, fd_table
|
||||
pop cx
|
||||
ret
|
||||
|
||||
fd_read: cmp bx, fd_num
|
||||
jnc fd_inv_hnd
|
||||
call fd_to_ptr
|
||||
; read ptr to ftab
|
||||
mov bx, [bx]
|
||||
; jmp to addr in ftab[0]
|
||||
jmp [bx]
|
||||
|
||||
fd_write: cmp bx, fd_num
|
||||
jnc fd_inv_hnd
|
||||
call fd_to_ptr
|
||||
mov bx, [bx]
|
||||
jmp [bx+2]
|
||||
|
||||
fd_inv_hnd: mov ax, 6
|
||||
stc
|
||||
ret
|
Loading…
Add table
Add a link
Reference in a new issue