diff --git a/README.md b/README.md index a09b447..b76a5fa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,36 @@ # kern. +--- -This is a second version of Kern. -I am making this because idk how to make a filesystem in the original Kern. +Idk why i called it that it was 3am and i needed sleep -At some point i will probably make this repo Kern and the other one like an archive or something Idk \ No newline at end of file +## 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_ diff --git a/other/charset.png b/other/charset.png new file mode 100644 index 0000000..d506abe Binary files /dev/null and b/other/charset.png differ diff --git a/other/example.png b/other/example.png new file mode 100644 index 0000000..bde5066 Binary files /dev/null and b/other/example.png differ diff --git a/other/logo.png b/other/logo.png new file mode 100644 index 0000000..53ffc6e Binary files /dev/null and b/other/logo.png differ diff --git a/src/boot.asm b/src/boot.asm index 5f33c8f..a57c8bb 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -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] diff --git a/src/fs/calc.asm b/src/fs/calc.asm index 91c5ae9..ca71d2b 100644 --- a/src/fs/calc.asm +++ b/src/fs/calc.asm @@ -13,7 +13,6 @@ start: mov es, ax mov fs, ax mov gs, ax - mov ss, ax jmp 0x2000:0x0000 diff --git a/src/fs/edit.asm b/src/fs/edit.asm index 025e0e9..faad2ee 100644 --- a/src/fs/edit.asm +++ b/src/fs/edit.asm @@ -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 diff --git a/src/kernel.asm b/src/kernel.asm index d2649b6..a2e63ca 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -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 diff --git a/src/lib/print.asm b/src/lib/print.asm index 034c4e1..1da7901 100644 --- a/src/lib/print.asm +++ b/src/lib/print.asm @@ -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 diff --git a/test/test b/test/test deleted file mode 100644 index be55df0..0000000 --- a/test/test +++ /dev/null @@ -1 +0,0 @@ -¸AÍ1ÀÍÃ \ No newline at end of file diff --git a/test/test.asm b/test/test.asm deleted file mode 100644 index 7d10127..0000000 --- a/test/test.asm +++ /dev/null @@ -1,5 +0,0 @@ -mov ax, 0x0e41 -int 0x10 -xor ax, ax -int 0x16 -ret \ No newline at end of file