33 lines
418 B
NASM
33 lines
418 B
NASM
|
%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
|