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
+33 -3
View File
@@ -1,6 +1,36 @@
# kern. # kern.
---
This is a second version of Kern. Idk why i called it that it was 3am and i needed sleep
I am making this because idk how to make a filesystem in the original Kern.
At some point i will probably make this repo Kern and the other one like an archive or something Idk ## About
Kern is a 32-bit OS based on the x86 architecture written in NASM Assembly and C.
It supports a basic command line and has a custom filesystem.
_Note: The filesystem is currently a basic filetable._
## Usage
If you want to try kern for some reason, you can.
You might be able to find some releases, or build it using the build.sh script.
For building, you'll need these tools:
- [NASM](https://www.nasm.us/)
- [QEMU](https://www.qemu.org/) (for emulation)
I personally wouldn't recommend running this on real hardware, because it's untested and will just probably break you pc, but if you really want to, you can try it, but don't blame me if something goes wrong.
If you don't know how to do something, try the 'help' command!
## Some images
The command prompt: \
![CLI image](other/example.png)
Built-in code editor: \
![Code Editor](other/editor.png)
Graphics mode test: \
![Graphics Test](other/graphics.png)
_These images may be outdated, Idk_
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

+5
View File
@@ -59,6 +59,11 @@ start:
mov es, ax mov es, ax
mov fs, ax mov fs, ax
mov gs, ax mov gs, ax
; Setup stack
mov bp, 0xffff
mov sp, bp
mov ax, 0x9000
mov ss, ax mov ss, ax
mov bl, byte [driveNumber] mov bl, byte [driveNumber]
-1
View File
@@ -13,7 +13,6 @@ start:
mov es, ax mov es, ax
mov fs, ax mov fs, ax
mov gs, ax mov gs, ax
mov ss, ax
jmp 0x2000:0x0000 jmp 0x2000:0x0000
+34 -16
View File
@@ -1,9 +1,16 @@
[bits 16] [bits 16]
launch: launch:
pusha
call resetTextMode 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 xor cx, cx
mov di, hexCode mov di, hexCode
@@ -34,10 +41,9 @@ getHexCh:
rol byte [hexByte], 4 rol byte [hexByte], 4
or byte [hexByte], al or byte [hexByte], al
mov al, [hexByte] mov al, [hexByte]
mov [di], al stosb
mov dx, [hexByte] mov dx, [hexByte]
call printHexByte call printHexByte
inc di
xor cx, cx xor cx, cx
mov al, ' ' mov al, ' '
mov ah, 0x0e mov ah, 0x0e
@@ -54,9 +60,14 @@ getHexCh:
call print call print
jmp getHexCh jmp getHexCh
.runInput: .runInput:
mov si, runMsg pusha
call hexCode ; Call the code
popa
mov si, ranMsg
call print call print
call hexBegin ; Call the code xor ax, ax
int 0x16
jmp launch jmp launch
; Expects al to contain an ASCII character, will set bx to it's hex equivalent ; Expects al to contain an ASCII character, will set bx to it's hex equivalent
@@ -69,13 +80,24 @@ asciiToHex:
ret ret
return: return:
mov cx, 256
mov di, hexCode
.loop:
mov byte [di], 0
inc di
dec cx
jnz .loop
popa
mov ax, 0x2000 mov ax, 0x2000
mov es, bx
xor bx, bx
mov ds, ax mov ds, ax
mov es, ax mov es, ax
mov fs, ax mov fs, ax
mov gs, ax mov gs, ax
mov ss, ax
jmp 0x2000:0x0000 jmp 0x2000:0x0000
; - Includes - ; - Includes -
@@ -83,19 +105,15 @@ return:
%include "./src/lib/print.asm" %include "./src/lib/print.asm"
; ------------ ; ------------
headerMsg: db " - EDITOR - ", ENDL, \ statusBarMsg: db " -- HEX -- ", 0
"Type '$' to run your code or '!' to exit", ENDL, ENDL, 0 controlsMsg: db "'$' to execute code; '!' to quit", 0
runMsg: db ENDL, " -- Executing -- ", ENDL, ENDL, 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 hexByte: db 0
hexBegin: ; The label we jump to hexCode: times 256 db 0 ; Code buffer
pusha
hexCode: times 256 db 0 ; Code buffer (user input code)
hexEnd:
popa
ret ret
times 2*512-($-$$) db 0 times 2*512-($-$$) db 0
+7 -8
View File
@@ -182,7 +182,6 @@ foundProgram:
mov es, ax mov es, ax
mov fs, ax mov fs, ax
mov gs, ax mov gs, ax
mov ss, ax
jmp PROGRAM_LOC:0x0000 jmp PROGRAM_LOC:0x0000
.printText: .printText:
@@ -385,7 +384,7 @@ driveNumber: db 0
startMsg: db "kern.", ENDL, ENDL, 0 ; The bootup message startMsg: db "kern.", ENDL, ENDL, 0 ; The bootup message
prompt: db "> ", 0 ; Prompt for input prompt: db "> ", 0 ; Prompt for input
fileNotFoundMsg: db "File not found!", ENDL, 0 ; User tries to load nonexistent file 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 sectorLenText: db "512B", 0
kilobyteText: db "kB", 0 kilobyteText: db "kB", 0
oneHalfText: db ".5kB", 0 oneHalfText: db ".5kB", 0
@@ -394,16 +393,16 @@ fileListMsg: db " Filename E# St Size ", ENDL, \
"---------- ------- ------", ENDL, 0 "---------- ------- ------", ENDL, 0
helpMsg: db "Available Commands:", ENDL, \ helpMsg: db "Available Commands:", ENDL, \
"clear - Clears the screen", ENDL, \ " clear | Clears the screen", ENDL, \
"gfx - Graphics mode test", ENDL, \ " edit | Opens the code editor", ENDL, \
"help - Prints this message", ENDL, \ " gfx | Graphics mode test", ENDL, \
"ls - List all files", ENDL, \ " help | Prints this message", ENDL, \
"reboot - Reboots the system", ENDL, 0 " ls | List all files", ENDL, \
" reboot | Reboots the system", ENDL, ENDL, 0
; Commands ; Commands
; TODO: Put these into a file or something ; TODO: Put these into a file or something
clearCmd: db "clear", 0 clearCmd: db "clear", 0
editCmd: db "edit", 0
gfxCmd: db "gfx", 0 gfxCmd: db "gfx", 0
helpCmd: db "help", 0 helpCmd: db "help", 0
lsCmd: db "ls", 0 lsCmd: db "ls", 0
+26 -1
View File
@@ -5,7 +5,7 @@
print: print:
pusha pusha
mov ah, 0x0e mov ah, 0x0e
mov bl, 0x0f mov bl, 0x1f
mov bh, 0 mov bh, 0
.loop: .loop:
lodsb ; Load [si] into al; Increment si lodsb ; Load [si] into al; Increment si
@@ -53,6 +53,8 @@ printHex:
printHexByte: printHexByte:
pusha pusha
xor cx, cx xor cx, cx
mov bh, 0
mov bl, 0x1f ; White on blue
.loop: .loop:
mov al, dl mov al, dl
and al, 0xF0 and al, 0xF0
@@ -84,6 +86,29 @@ clear:
popa popa
ret 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 ; Usefull definitions
%define ENDL 0x0a, 0x0d %define ENDL 0x0a, 0x0d
VIDMEM equ 0x0b800
newline: db ENDL, 0 ; CRLF newline: db ENDL, 0 ; CRLF
-1
View File
@@ -1 +0,0 @@
¸AÍ1ÀÍÃ
-5
View File
@@ -1,5 +0,0 @@
mov ax, 0x0e41
int 0x10
xor ax, ax
int 0x16
ret