commit whatever is in my worktree rn

This commit is contained in:
Nero 2021-12-10 10:41:02 +00:00
parent 1dea0c40bc
commit a3ef693059
5 changed files with 211 additions and 197 deletions

View file

@ -7,11 +7,8 @@ banner: db "RDOS KERNEL ", V, 0x0A, 0x0D, '$', 0x1A
%include "kernel/far.asm"
%include "kernel/char.asm"
%include "inc/bpb.asm"
%include "kernel/drive.asm"
%include "kernel/fcb.asm"
%include "kernel/rootdir.asm"
%include "kernel/cluster.asm"
%include "kernel/fat.asm"
section .text
@ -21,32 +18,15 @@ init: call rstseg
mov dx, banner
call puts
call rstseg
mov dx, testdta
push ds
call norm
call setdta
pop ds
mov dl, 0
call select
mov dx, testfcb
call norm
call open
call read
mov ax, [cs:testdta]
mov cx, [cs:testdta+2]
int 3
mov dx, 3
call setclus
call rdfat
mov dx, bx
inc dx
call wdfat
hlt: hlt
jmp hlt
section .data
testfcb db 0, "HELLO ","COM"
times FCBSIZ db 0
section .bss
testdta resb 128

View file

@ -43,10 +43,6 @@ dmpdx3: int 0x10
free dw 0 ; free ram size
lncnt dw 0 ; line count
rdptr dw 0xFFFF ; infile blk ptr
symbol dw 0 ; symbol of current line
offset dw 0 ; byte offset in outfile
len db 0 ; len for wrd (must be before it)
wrd dw 0,0,0,0,0,0,0,0 ; 16 byte word buf
getc mov bx, [rdptr]
cmp bx, 0x80
@ -72,12 +68,6 @@ l02 mov al, 0x1A
l03 cmp al, eof
ret
;getc2 call peek
; cmp al, eof
; jne getc_
; inc word [rdptr]
;getc_ ret
newlin mov dl, 0x0A
mov ah, 2
int 0x21
@ -99,145 +89,32 @@ error mov dl, [bx]
e_eof db "EOF "
e_dup db "DUPSYM "
; scan word
scawrd mov si, wrd
l04 call getc
; EOF is fatal
mov bx, e_eof
jz error
; tab=end
cmp al, 9
je pad
; space=end
cmp al, 0x20
je pad
; if lbl full, continue eating
cmp si, wrd+0x10
jnc l04
; insert
mov [si], al
inc si
jmp l04
; pad with spaces
pad mov cx, si
sub cx, wrd
mov [len], cl
cmp si, wrd+0x10
jnc l06
mov ah, 0x20
xchg ah, [si]
inc si
cmp ah, 0x20
jne pad
l06 ret
tok1:
s_ws db " " ; also used for tabs
s_com db ","
s_obr db "["
s_cbr db "]"
s_plu db "+"
s_min db "-"
; print wrd
dmpwrd mov si, wrd
mov cx, 0x10
mov ah, 2
l05 mov dl, [si]
cmp dl, 0x20
je l07
inc si
int 0x21
loop l05
l07 call newlin
ret
align 2
tok2:
reg8 db "AL","CL","DL","BL","AH","CH","DH","BH"
reg16 db "AX","CX","DX","BX","SP","BP","SI","DI"
sreg db "ES","CS","SS","DS"
s_db db "DB"
s_dw db "DW"
; create symbol table entry
; name is read from [wrd]
; offset is written to [symbol]
symins cmp byte [wrd], 0x20
je nosym
mov bx, init ; walk ptr
mov bp, [free]
add bp, bx ; end addr
jmp l09
l08 add bx, 8
l09 mov al, [bx]
cmp al, 0
je l10
call symcmp
jnz l08
mov bx, e_dup
jmp error
; copy str to table
l10 mov si, wrd
mov di, bx
movsw
movsw
movsw
xor ax, ax
stosw
mov byte [bx+8], 0
mov [symbol], bx
ret
tok3:
s_org db "ORG"
s_equ db "EQU"
nosym xor ax, ax
mov [symbol], ax
ret
; compares 6 bytes [bx] with [wrd]
; bit 7 of each byte is ignored
symcmp mov si, wrd
xor ax, ax
mov dx, [wrd]
xor dx, [bx]
or ax, dx
mov dx, [wrd+2]
xor dx, [bx+2]
or ax, dx
mov dx, [wrd+4]
xor dx, [bx+4]
or ax, dx
test ax, 0x8F8F
ret
; look up keyword in wrd
; result is stored in bx
lookup mov ch, 0
mov bx, s_org
l11 mov si, bx
mov di, len ; wrd immediately follows
mov cl, [bx]
test cx, cx
jz l13
inc cl
mov dx, cx
rep cmpsb
je l12
add bx, dx
jmp l11
; found!
l12 clc
ret
; give up
l13 xor bx, bx
stc
ret
s_org db 3, "org"
s_equ db 3, "equ"
db 0
; TODO: parse a line into wordlist of tokens and ptrs to strings
rline: ret
; clear symbol table
main mov byte [init], 0
; scan and create label
mloop call scawrd
call symins
; scan instruction word
call scawrd
call lookup
; special stuff
cmp bx, s_org
je iorg
mov ax, bx
call dumpax
int 0x20
; org pseudo instruction
iorg mov ax, 0x5A5A
call dumpax
call rline
int 0x20
align 16