Before C Switch

This commit is contained in:
2024-03-08 19:28:09 +01:00
parent da52676e78
commit 2f3b4f6e6b
4 changed files with 47 additions and 39 deletions
+2
View File
@@ -39,3 +39,5 @@ _These images may be outdated, Idk_
- If you run the kernel.bin, loading files sorta breaks, because the program is running at 0x8000, but it thinks that it's at 0x2000 (i think)
- If you run anything in the code editor and return to the kernel, you won't be able to load any files
- If you type only the starting letters of a command, it will still run (i.e. 'he' will run help)
## [Old Version](https://github.com/Tom-on64/old-kern)
+5 -1
View File
@@ -256,6 +256,10 @@ getInput:
; Expects al to contain an ASCII character, will set bx to it's hex equivalent
asciiToHex:
cmp al, 'F'
jle .upperCase
sub al, 32
.upperCase:
cmp al, '9'
jle .getHex
sub al, 7
@@ -275,7 +279,7 @@ saveFileMsg: db "Save as: ", 0 ; Make sure to erase
openFileMsg: db "Open file: ", 0
bytesMsg: db " Bytes", 0
; savedMsg: db "Saved file as '", 0
; oepenedMsg: db "Editing file '", 0
; openedMsg: db "Editing file '", 0
runMsg: db ENDL, ENDL, 0
ranMsg: db ENDL, ENDL, " - Finished Execution - ", ENDL, 0
notFoundMsg: db "File not found! ", 0 ; Erase the user input
+35 -36
View File
@@ -66,23 +66,16 @@ input:
je input
tokenize: ; Tokenize
mov byte cl, [inputLen]
mov di, tokens
.tokenLoop:
lodsb
cmp al, 0 ; Check for end of input
je runCommand
.wsLoop:
cmp al, ' ' ; Compare with whitespace
jne .stringLoop
lodsb
jmp .wsLoop
.stringLoop:
cmp al, ' '
je .next
.next:
mov si, userInput
.loop:
inc si
cmp byte [si], 0
je .done
cmp byte [si], ' '
jne .loop
mov byte [si], 0
jmp .loop
.done:
; Runs a command in userInput
; Expects tokenized input
@@ -188,25 +181,33 @@ foundProgram:
inc bx ; Ignore Number of FT entries for now
mov cl, [es:bx] ; Starting sector
inc bx
mov al, [es:bx] ; Number of sectors to read
push ax ; Save file size
; mov cl, [es:bx] ; Starting sector
; inc bx
; mov al, [es:bx] ; Number of sectors to read
; push ax ; Save file size
mov ah, 0 ; Reset disk system
mov dl, byte [driveNum]
int 0x13
; mov ah, 0 ; Reset disk system
; mov dl, byte [driveNum]
; int 0x13
mov bx, PROGRAM_LOC
mov es, bx
xor bx, bx ; [es:bx] - Place to load out program
; mov bx, PROGRAM_LOC
; mov es, bx
; xor bx, bx ; [es:bx] - Place to load out program
mov ah, 2 ; Read sectors into memory
mov dl, byte [driveNum]
mov ch, 0 ; Cylinder
mov dh, 0 ; Head
int 0x13
jnc .loaded ; Loaded file successfully
; mov ah, 2 ; Read sectors into memory
; mov dl, byte [driveNum]
; mov ch, 0 ; Cylinder
; mov dh, 0 ; Head
; int 0x13
mov byte dl, [driveNum] ; Drive number
push word userInput ; Filename
push word PROGRAM_LOC ; Dest. segment
push word 0x0000 ; Dest. offset
call loadFile
cmp byte al, 0
je .loaded ; Loaded file successfully
mov si, programLoadFailMsg
call print
@@ -491,10 +492,8 @@ fileExt: db " ", 0
binExt: db "bin", 0
txtExt: db "txt", 0
tokens: times 50 db 0 ; char[10][5] (List of 5 strings that are 10 chars long each or null terminated)
tokenLen: times 5 db 0 ; 5 lengths for each token
tokenCount: db 0
inputLen: db 0
tokenCount: db 0
userInput: times 80 db 0
;; Constants
+5 -2
View File
@@ -1,7 +1,7 @@
;
; Loads a file from the filetable into a memory location
; Params:
; dl - Disk number
; dl - Disk number (byte)
; Filename (Null terminated)
; Destination location segment
; Destination location offset
@@ -42,6 +42,9 @@ loadFile:
stosb
loop .filenamePadLoop
.filenameDone:
mov si, fileName
call print
mov ax, FILETAB_LOC
mov es, ax
xor di, di ; es:di - Filetable location
@@ -311,7 +314,7 @@ returnToCaller:
; Filename
;
removeFile:
ret
;; Variables
availableSector: db 0