Added some docs and improved editor

This commit is contained in:
2023-12-26 15:27:16 +01:00
parent d9e782d450
commit 9384471535
11 changed files with 106 additions and 36 deletions
+5
View File
@@ -59,6 +59,11 @@ start:
mov es, ax
mov fs, ax
mov gs, ax
; Setup stack
mov bp, 0xffff
mov sp, bp
mov ax, 0x9000
mov ss, ax
mov bl, byte [driveNumber]
-1
View File
@@ -13,7 +13,6 @@ start:
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x2000:0x0000
+35 -17
View File
@@ -1,9 +1,16 @@
[bits 16]
launch:
pusha
call resetTextMode
mov si, headerMsg
call print
mov di, 0x0e60 ; Offset in vidmem (2nd to last line)
mov si, statusBarMsg
call drawString
mov di, 0x0f00 ; Last line
mov si, controlsMsg
call drawString
xor cx, cx
mov di, hexCode
@@ -34,10 +41,9 @@ getHexCh:
rol byte [hexByte], 4
or byte [hexByte], al
mov al, [hexByte]
mov [di], al
stosb
mov dx, [hexByte]
call printHexByte
inc di
xor cx, cx
mov al, ' '
mov ah, 0x0e
@@ -54,9 +60,14 @@ getHexCh:
call print
jmp getHexCh
.runInput:
mov si, runMsg
pusha
call hexCode ; Call the code
popa
mov si, ranMsg
call print
call hexBegin ; Call the code
xor ax, ax
int 0x16
jmp launch
; Expects al to contain an ASCII character, will set bx to it's hex equivalent
@@ -69,13 +80,24 @@ asciiToHex:
ret
return:
mov cx, 256
mov di, hexCode
.loop:
mov byte [di], 0
inc di
dec cx
jnz .loop
popa
mov ax, 0x2000
mov es, bx
xor bx, bx
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x2000:0x0000
; - Includes -
@@ -83,19 +105,15 @@ return:
%include "./src/lib/print.asm"
; ------------
headerMsg: db " - EDITOR - ", ENDL, \
"Type '$' to run your code or '!' to exit", ENDL, ENDL, 0
runMsg: db ENDL, " -- Executing -- ", ENDL, ENDL, 0
statusBarMsg: db " -- HEX -- ", 0
controlsMsg: db "'$' to execute code; '!' to quit", 0
ranMsg: db ENDL, ENDL, " - Finished Execution - ", ENDL, 0
backChars: db 8, 8, 8, ' ', 8, 8, 0
backChars: db 8,8,8,' ',8,8,0
hexByte: db 0
hexBegin: ; The label we jump to
pusha
hexCode: times 256 db 0 ; Code buffer (user input code)
hexEnd:
popa
hexCode: times 256 db 0 ; Code buffer
ret
times 2*512-($-$$) db 0
+7 -8
View File
@@ -182,7 +182,6 @@ foundProgram:
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp PROGRAM_LOC:0x0000
.printText:
@@ -385,7 +384,7 @@ driveNumber: db 0
startMsg: db "kern.", ENDL, ENDL, 0 ; The bootup message
prompt: db "> ", 0 ; Prompt for input
fileNotFoundMsg: db "File not found!", ENDL, 0 ; User tries to load nonexistent file
programLoadFailMsg: db "Failed while loading program!", ENDL, 0 ; File load fail
programLoadFailMsg: db "Couldn't load file!", ENDL, 0 ; File load fail
sectorLenText: db "512B", 0
kilobyteText: db "kB", 0
oneHalfText: db ".5kB", 0
@@ -394,16 +393,16 @@ fileListMsg: db " Filename E# St Size ", ENDL, \
"---------- ------- ------", ENDL, 0
helpMsg: db "Available Commands:", ENDL, \
"clear - Clears the screen", ENDL, \
"gfx - Graphics mode test", ENDL, \
"help - Prints this message", ENDL, \
"ls - List all files", ENDL, \
"reboot - Reboots the system", ENDL, 0
" clear | Clears the screen", ENDL, \
" edit | Opens the code editor", ENDL, \
" gfx | Graphics mode test", ENDL, \
" help | Prints this message", ENDL, \
" ls | List all files", ENDL, \
" reboot | Reboots the system", ENDL, ENDL, 0
; Commands
; TODO: Put these into a file or something
clearCmd: db "clear", 0
editCmd: db "edit", 0
gfxCmd: db "gfx", 0
helpCmd: db "help", 0
lsCmd: db "ls", 0
+26 -1
View File
@@ -5,7 +5,7 @@
print:
pusha
mov ah, 0x0e
mov bl, 0x0f
mov bl, 0x1f
mov bh, 0
.loop:
lodsb ; Load [si] into al; Increment si
@@ -53,6 +53,8 @@ printHex:
printHexByte:
pusha
xor cx, cx
mov bh, 0
mov bl, 0x1f ; White on blue
.loop:
mov al, dl
and al, 0xF0
@@ -84,6 +86,29 @@ clear:
popa
ret
;
; Writes a string into video memory
; di - Video memory offset
; si - string
;
drawString:
pusha
push es ; For some reason doesn't get stored in pusha
mov ax, VIDMEM
mov es, ax
.loop:
cmp byte [si], 0
je .after
movsb
mov byte [es:di], 0x1f ; White on blue
inc di
jmp .loop
.after:
pop es
popa
ret
; Usefull definitions
%define ENDL 0x0a, 0x0d
VIDMEM equ 0x0b800
newline: db ENDL, 0 ; CRLF