Rename kernel to bdos
This commit is contained in:
parent
d789131eb6
commit
f81de2bfe8
11 changed files with 12 additions and 11 deletions
|
@ -1,56 +0,0 @@
|
|||
console_hide_cursor:
|
||||
push ax
|
||||
push cx
|
||||
mov ah, 1
|
||||
mov cx, 0x1F1F
|
||||
int 0x10
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
console_show_cursor:
|
||||
push ax
|
||||
push cx
|
||||
mov ah, 1
|
||||
mov cx, 0x001F
|
||||
int 0x10
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
; Raw console i/o without echo
|
||||
; IN DL character to output or FF
|
||||
; OUT ZF if DL=FF: zero if character input
|
||||
; AL if not ZF: ascii char, otherwise corrupt
|
||||
console_io:
|
||||
cmp dl, 0xFF
|
||||
je .read
|
||||
push ax
|
||||
push bx
|
||||
mov al, dl
|
||||
mov ah, 0x0e
|
||||
xor bx, bx
|
||||
int 0x10
|
||||
pop bx
|
||||
pop ax
|
||||
ret
|
||||
.read:
|
||||
call console_show_cursor
|
||||
|
||||
; if no character avail, exit with leaving
|
||||
; cursor displayed
|
||||
mov ah, 1
|
||||
int 0x16
|
||||
jz .end
|
||||
pushf
|
||||
|
||||
; actually read character
|
||||
xor ax, ax
|
||||
int 0x16
|
||||
|
||||
call console_hide_cursor
|
||||
|
||||
; restore zero flag
|
||||
popf
|
||||
.end:
|
||||
ret
|
168
kernel/disk.asm
168
kernel/disk.asm
|
@ -1,168 +0,0 @@
|
|||
disk_num: equ 0x40 ; BYTE drive number (A=0)
|
||||
disk_heads: equ 0x41 ; BYTE number of heads/sides
|
||||
disk_parm: equ 0x42 ; 11 BYTES for int 0x1E
|
||||
disk_spt: equ 0x46 ; - BYTE
|
||||
|
||||
disk_parm_init:
|
||||
push ax
|
||||
push si
|
||||
push di
|
||||
push ds
|
||||
|
||||
; invalidate existing data
|
||||
mov byte [disk_num], 0xFF
|
||||
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
|
||||
; if int 0x1E is already pointing to us,
|
||||
; we have nothing to copy
|
||||
mov di, disk_parm
|
||||
lds si, [0x1E*4]
|
||||
cmp si, di
|
||||
je .correctparm
|
||||
|
||||
; copy bios table into our location
|
||||
mov cx, 11
|
||||
rep movsb
|
||||
|
||||
; make the interrupt vector point to our address
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
mov [0x1E*4], di
|
||||
mov ax, cs
|
||||
mov [0x1E*4+2], ax
|
||||
|
||||
.correctparm:
|
||||
pop ds
|
||||
pop di
|
||||
pop si
|
||||
pop ax
|
||||
ret
|
||||
|
||||
disk_load_bpb:
|
||||
mov ax, 0x0201
|
||||
mov cx, 0x0001
|
||||
xor dh, dh
|
||||
mov bx, diskbuf
|
||||
stc
|
||||
|
||||
int 0x13
|
||||
jnc .end
|
||||
|
||||
; try a second time
|
||||
mov ax, 0x0201
|
||||
int 0x13
|
||||
jnc .end
|
||||
|
||||
; try a third time
|
||||
mov ax, 0x0201
|
||||
int 0x13
|
||||
.end:
|
||||
ret
|
||||
|
||||
disk_select:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push bx
|
||||
|
||||
cmp byte [disk_num], dl
|
||||
je .end
|
||||
mov byte [disk_num], dl
|
||||
call disk_load_bpb
|
||||
jc .end
|
||||
|
||||
; Validate and apply sector size
|
||||
mov ax, [diskbuf+fdc_ss]
|
||||
; test ax, 0xF87F
|
||||
; jnz .nobpd
|
||||
call log2
|
||||
sub al, 7
|
||||
mov [disk_parm+3], al
|
||||
|
||||
; fetch sectors per track
|
||||
mov al, [diskbuf+fdc_spt]
|
||||
mov [disk_parm+4], al
|
||||
|
||||
; fetch number of sides/heads
|
||||
mov ax, [diskbuf+fdc_nos]
|
||||
mov [disk_heads], al
|
||||
|
||||
xor ah, ah
|
||||
int 0x13
|
||||
.end:
|
||||
pop bx
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
; Setup CX, DX and BX for int 13h transfer
|
||||
; IN BX ptr to 32-bit number
|
||||
; OUT CL Sector number
|
||||
; CH Cylinder number
|
||||
; DL Drive number
|
||||
; DH Head number
|
||||
; BX Sector buffer
|
||||
disk_prepare_chs:
|
||||
mov ax, word [bx]
|
||||
mov dx, word [bx+2]
|
||||
|
||||
xor bh, bh
|
||||
mov bl, byte [disk_spt]
|
||||
|
||||
div word bx ; ax:temp = (lba / spt)
|
||||
inc dx ; dx:sector = (lba % spt) + 1
|
||||
mov cl, dl ; sector number
|
||||
|
||||
xor bx, bx
|
||||
mov bl, byte [disk_heads]
|
||||
|
||||
xor dx, dx
|
||||
div word bx ; ax:cylinder = (temp / nos)
|
||||
; dx:head = (temp % nos)
|
||||
mov ch, al ; cylinder number
|
||||
mov dh, dl ; head number
|
||||
|
||||
mov dl, byte [disk_num]
|
||||
mov bx, diskbuf
|
||||
ret
|
||||
|
||||
; Read a sector into diskbuf
|
||||
; IN BX ptr to DWORD giving sector number
|
||||
disk_read:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push bx
|
||||
|
||||
call disk_prepare_chs
|
||||
|
||||
mov ax, 0x0201
|
||||
int 0x13
|
||||
|
||||
pop bx
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
; Write a sector from diskbuf
|
||||
; IN BX ptr to DWORD giving sector number
|
||||
disk_write:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push bx
|
||||
|
||||
call disk_prepare_chs
|
||||
|
||||
mov ax, 0x0301
|
||||
int 0x13
|
||||
|
||||
pop bx
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
|
@ -1,85 +0,0 @@
|
|||
; print a word
|
||||
; in: ax
|
||||
print16:
|
||||
xchg ah,al
|
||||
call print8
|
||||
xchg ah,al
|
||||
|
||||
; print a byte
|
||||
; in: al
|
||||
print8:
|
||||
push ax ; avoid destroying ah
|
||||
push bx
|
||||
xor bx, bx
|
||||
aam 16 ; high nibble moved into ah, low nibble into al
|
||||
add ax, 0x3030
|
||||
push ax
|
||||
xchg al, ah
|
||||
call .nib
|
||||
pop ax
|
||||
call .nib
|
||||
pop bx
|
||||
pop ax
|
||||
ret
|
||||
.nib:
|
||||
cmp al, 0x3a
|
||||
jl .out
|
||||
add al, 0x07
|
||||
.out:
|
||||
mov dl, al
|
||||
call console_output
|
||||
ret
|
||||
|
||||
dump:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push bx
|
||||
mov dl, 0x0A
|
||||
call console_output
|
||||
mov dl, 0x0D
|
||||
call console_output
|
||||
mov cx, 4
|
||||
.loop_line:
|
||||
push cx
|
||||
push bx
|
||||
mov ax, bx
|
||||
call print16
|
||||
mov dl, ':'
|
||||
call console_output
|
||||
mov dl, ' '
|
||||
call console_output
|
||||
mov cx, 0x8
|
||||
.loop_bin:
|
||||
mov ax, [bx]
|
||||
xchg al, ah
|
||||
inc bx
|
||||
inc bx
|
||||
call print16
|
||||
mov dl, ' '
|
||||
call console_output
|
||||
loop .loop_bin
|
||||
pop bx
|
||||
mov cx, 0x10
|
||||
.loop_ascii:
|
||||
mov dl, '.'
|
||||
cmp byte [bx], 0x20
|
||||
jc .print
|
||||
cmp byte [bx], 0x80
|
||||
jnc .print
|
||||
mov dl, [bx]
|
||||
.print:
|
||||
inc bx
|
||||
call console_output
|
||||
loop .loop_ascii
|
||||
pop cx
|
||||
mov dl, 0x0A
|
||||
call console_output
|
||||
mov dl, 0x0D
|
||||
call console_output
|
||||
loop .loop_line
|
||||
pop bx
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
|
@ -1,13 +0,0 @@
|
|||
; Exec the cmdline at SI or 0x81
|
||||
exec_chain:
|
||||
mov si, 0x81
|
||||
exec:
|
||||
push bx
|
||||
sub sp, 0x20
|
||||
mov bx, sp
|
||||
|
||||
call fcb_parse
|
||||
|
||||
add sp, 0x20
|
||||
pop bx
|
||||
ret
|
|
@ -1,8 +0,0 @@
|
|||
; diskbuf needs to be defined
|
||||
|
||||
; User-accessible part of FCB (12 bytes)
|
||||
fcb_drv: equ 0 ; 1 byte, 1=A: 2=B: 3=C:
|
||||
fcb_fn: equ 1 ; 8 bytes
|
||||
fcb_ext: equ 9 ; 3 bytes
|
||||
|
||||
fcb_type: equ 12 ; BYTE type identifier
|
|
@ -1,62 +0,0 @@
|
|||
cpu 8086
|
||||
|
||||
self: equ 0xF000
|
||||
diskbuf: equ (self-0x200) ; deblocking
|
||||
stack: equ (diskbuf) ; grows down
|
||||
defdrv: equ 4
|
||||
|
||||
org self
|
||||
jmp init
|
||||
pad 3
|
||||
|
||||
self_offset:
|
||||
db (self >> 8)
|
||||
|
||||
banner:
|
||||
db "RDOS 2019-09", 0x0A, 0x0D, '$', 0
|
||||
|
||||
init:
|
||||
mov sp, stack
|
||||
mov byte [defdrv], 0x01
|
||||
|
||||
mov dx, banner
|
||||
call print_string
|
||||
|
||||
call disk_parm_init
|
||||
|
||||
mov dx, 0x7F
|
||||
mov byte [0x7F], 0x7F
|
||||
mov byte [0x80], 2
|
||||
call read_buffer
|
||||
|
||||
int3
|
||||
|
||||
cli
|
||||
.halt:
|
||||
hlt
|
||||
jmp .halt
|
||||
|
||||
init_program:
|
||||
db "HELLO.COM", 0
|
||||
|
||||
; helper function for idle loops
|
||||
idle:
|
||||
pushf
|
||||
sti
|
||||
hlt
|
||||
popf
|
||||
ret
|
||||
|
||||
%include "syscall.asm"
|
||||
|
||||
%include "con86.asm"
|
||||
|
||||
%include "exec.asm"
|
||||
%include "fdc.asm"
|
||||
%include "fcb.asm"
|
||||
%include "fcbparse.asm"
|
||||
|
||||
%include "disk.asm"
|
||||
|
||||
%include "log2.asm"
|
||||
%include "dump.asm"
|
|
@ -1,31 +0,0 @@
|
|||
; IN DS:SI offset of needle
|
||||
; ES:DI offset to haystack table
|
||||
; OUT ES:DI found offset in table
|
||||
; ZF zero flag set if match
|
||||
|
||||
string_search_token:
|
||||
push bp
|
||||
push cx
|
||||
.loop:
|
||||
cmp BYTE [es:di], 0
|
||||
je .fail
|
||||
push si
|
||||
push di
|
||||
mov bp, di
|
||||
xor ch, ch
|
||||
mov cl, [es:di]
|
||||
inc di
|
||||
add bp, cx
|
||||
inc bp
|
||||
repe cmpsb
|
||||
pop di
|
||||
pop si
|
||||
je .end
|
||||
mov di, bp
|
||||
jmp .loop
|
||||
.fail:
|
||||
stc
|
||||
.end:
|
||||
pop cx
|
||||
pop cx
|
||||
ret
|
|
@ -1,96 +0,0 @@
|
|||
cpm_syscall:
|
||||
cmp cl, 0
|
||||
je init
|
||||
|
||||
cmp cl, 1
|
||||
jne console_input.chain
|
||||
|
||||
console_input.loop:
|
||||
call idle
|
||||
console_input:
|
||||
push dx
|
||||
mov dl, 0xFF
|
||||
call console_io
|
||||
pop dx
|
||||
jz console_input.loop
|
||||
test al, al
|
||||
jz console_input.loop
|
||||
push dx
|
||||
mov dl, al
|
||||
call console_output
|
||||
pop dx
|
||||
ret
|
||||
|
||||
.chain:
|
||||
cmp cl, 2
|
||||
jne console_output.chain
|
||||
|
||||
console_output:
|
||||
cmp dl, 0xFF
|
||||
je .end
|
||||
call console_io
|
||||
.end:
|
||||
ret
|
||||
|
||||
.chain:
|
||||
cmp cl, 9
|
||||
jne print_string.chain
|
||||
|
||||
print_string:
|
||||
push si
|
||||
mov si, dx
|
||||
.loop:
|
||||
mov dl, BYTE [si]
|
||||
cmp dl, '$'
|
||||
jz .end
|
||||
call console_output
|
||||
inc si
|
||||
jmp .loop
|
||||
.end:
|
||||
pop si
|
||||
ret
|
||||
|
||||
.chain:
|
||||
cmp cl, 10
|
||||
jne read_buffer.chain
|
||||
|
||||
read_buffer:
|
||||
push ax
|
||||
push dx
|
||||
push bx
|
||||
push si
|
||||
xor bx, bx
|
||||
mov si, dx
|
||||
.loop:
|
||||
call console_input
|
||||
cmp al, 0x0D
|
||||
je .end
|
||||
cmp al, 8
|
||||
je .bs
|
||||
mov [si+bx+2], al
|
||||
inc bx
|
||||
cmp bl, [si]
|
||||
jc .loop
|
||||
.end:
|
||||
mov byte [si+bx+2], 0x0D
|
||||
mov [si+1], bl
|
||||
mov dl, 0x0A
|
||||
call console_output
|
||||
pop si
|
||||
pop bx
|
||||
pop dx
|
||||
pop ax
|
||||
ret
|
||||
.bs:
|
||||
test bx, bx
|
||||
jz .loop
|
||||
mov dl, 0x20
|
||||
call console_output
|
||||
mov dl, 8
|
||||
call console_output
|
||||
dec bx
|
||||
jmp .loop
|
||||
|
||||
.chain:
|
||||
stc
|
||||
ret
|
Loading…
Add table
Add a link
Reference in a new issue