initial commit, asm operating system with the MikeOS bootloader
This commit is contained in:
BIN
source/features/.cli.asm.swp
Normal file
BIN
source/features/.cli.asm.swp
Normal file
Binary file not shown.
BIN
source/features/.screen.asm.swp
Normal file
BIN
source/features/.screen.asm.swp
Normal file
Binary file not shown.
BIN
source/features/.strings.asm.swp
Normal file
BIN
source/features/.strings.asm.swp
Normal file
Binary file not shown.
49
source/features/cli.asm
Normal file
49
source/features/cli.asm
Normal file
@@ -0,0 +1,49 @@
|
||||
os_start_cli:
|
||||
pusha
|
||||
|
||||
mov si, prompt
|
||||
call os_print_string
|
||||
|
||||
mov di, user_input
|
||||
|
||||
call os_display_input
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
; ------------------------------------------------
|
||||
|
||||
os_read_cli:
|
||||
pusha
|
||||
|
||||
.output_the_user_input:
|
||||
call os_print_newline
|
||||
|
||||
mov si, command_result_text
|
||||
call os_print_string
|
||||
|
||||
mov si, user_input
|
||||
call os_print_string
|
||||
|
||||
call os_print_newline
|
||||
|
||||
.check_matches: ; Check if the user input matches any internal commands
|
||||
mov si, user_input
|
||||
mov di, help_string
|
||||
call os_compare_strings
|
||||
cmp cl, 1
|
||||
je print_help_text
|
||||
|
||||
.finish:
|
||||
call os_start_cli
|
||||
|
||||
print_help_text:
|
||||
mov si, help_text
|
||||
call os_print_string_nl
|
||||
|
||||
|
||||
user_input times 20 db 0
|
||||
prompt db 'CrawOS > ', 0
|
||||
help_string db 'HELP', 0
|
||||
help_text db 'This is CrawOS', 0
|
||||
command_result_text db 'You typed: ', 0
|
6
source/features/power.asm
Normal file
6
source/features/power.asm
Normal file
@@ -0,0 +1,6 @@
|
||||
os_reboot:
|
||||
mov ax, 0x5307
|
||||
mov bx, 0x0001
|
||||
mov cx, 0x0003
|
||||
int 0x19
|
||||
|
152
source/features/screen.asm
Executable file
152
source/features/screen.asm
Executable file
@@ -0,0 +1,152 @@
|
||||
; ==================================================================
|
||||
; MikeOS -- The Mike Operating System kernel
|
||||
; Copyright (C) 2006 - 2021 MikeOS Developers -- see doc/LICENSE.TXT
|
||||
;
|
||||
; SCREEN HANDLING SYSTEM CALLS
|
||||
; ==================================================================
|
||||
|
||||
; ------------------------------------------------------------------
|
||||
; os_print_string -- Displays text
|
||||
; IN: SI = message location (zero-terminated string)
|
||||
; OUT: Nothing (registers preserved)
|
||||
|
||||
os_print_string:
|
||||
pusha
|
||||
|
||||
mov ah, 0Eh ; int 10h teletype function, we're telling the BIOS we will print something
|
||||
|
||||
.repeat:
|
||||
lodsb ; Get char from si into al
|
||||
cmp al, 0 ; Compare al to 0
|
||||
je .done ; If char is zero, end of string
|
||||
|
||||
int 10h ; Otherwise, print it
|
||||
jmp .repeat ; And move on to next char
|
||||
|
||||
.done:
|
||||
popa
|
||||
ret
|
||||
|
||||
; Exact same as the above procedure, but this adds a newline
|
||||
; after priting, similar to the difference between Rust's print! and println!
|
||||
os_print_string_nl: pusha
|
||||
|
||||
mov ah, 0Eh ; int 10h teletype function, we're telling the BIOS we will print something
|
||||
|
||||
.repeat:
|
||||
lodsb ; Get char from si into al
|
||||
cmp al, 0 ; Compare al to 0
|
||||
je .done ; If char is zero, end of string
|
||||
|
||||
int 10h ; Otherwise, print it
|
||||
jmp .repeat ; And move on to next char
|
||||
|
||||
.done:
|
||||
call os_print_newline
|
||||
popa
|
||||
ret
|
||||
|
||||
; --------------------------------------------
|
||||
|
||||
os_print_newline:
|
||||
pusha
|
||||
|
||||
mov ah, 03h
|
||||
int 10h
|
||||
|
||||
mov ah, 02h
|
||||
add dh, 1
|
||||
mov dl, 0
|
||||
int 10h
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; -------------------------------------------
|
||||
|
||||
os_clear_screen:
|
||||
pusha
|
||||
|
||||
mov ah, 00h
|
||||
mov al, 03h ; Set video mode to textmode (80x25). 16 colors, 8 pages
|
||||
int 10h
|
||||
|
||||
mov ah, 02h
|
||||
mov dh, 0
|
||||
mov dl, 0
|
||||
int 10h
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
; -------------------------------------------
|
||||
|
||||
; AX = key pressed
|
||||
os_read_input:
|
||||
mov ah, 11h ; BIOS call to check for key
|
||||
int 16h ; Interrupt
|
||||
jnz .key_pressed ; Jump if input isn't 0
|
||||
|
||||
hlt
|
||||
jmp os_read_input
|
||||
|
||||
.key_pressed:
|
||||
mov ah, 10h
|
||||
int 16h
|
||||
ret
|
||||
|
||||
; -------------------------------------------
|
||||
|
||||
os_display_input:
|
||||
pusha
|
||||
|
||||
call .check_key_pressed
|
||||
|
||||
jmp os_display_input
|
||||
|
||||
.check_key_pressed:
|
||||
call os_read_input
|
||||
|
||||
cmp al, 08h
|
||||
je .backspace
|
||||
|
||||
cmp al, 0Dh
|
||||
je .enter_key
|
||||
|
||||
cmp al, 1Bh
|
||||
je .esc_key
|
||||
|
||||
call .print_current_input
|
||||
ret
|
||||
|
||||
.esc_key:
|
||||
call os_reboot
|
||||
|
||||
.enter_key:
|
||||
mov al, 0
|
||||
stosb
|
||||
mov di, user_input
|
||||
|
||||
call os_read_cli
|
||||
|
||||
.backspace:
|
||||
mov ah, 0Eh
|
||||
|
||||
mov al, 08h
|
||||
int 10h
|
||||
mov al, 20h
|
||||
int 10h
|
||||
mov al, 08h
|
||||
int 10h
|
||||
|
||||
dec di
|
||||
jmp os_display_input
|
||||
|
||||
.print_current_input:
|
||||
stosb
|
||||
|
||||
mov ah, 0Eh
|
||||
int 10h
|
||||
|
||||
ret
|
28
source/features/strings.asm
Normal file
28
source/features/strings.asm
Normal file
@@ -0,0 +1,28 @@
|
||||
; How string comparison works
|
||||
; DI => scasb compares value stored in DI which is 's' with 's' stored in AX register
|
||||
; and then increments DI if DF is 0
|
||||
; v
|
||||
; memory address 1: |s|n|a|t|0|
|
||||
; memory address 2: |s|n|a|k|e|0|
|
||||
; ^
|
||||
; SI => lodsb loads value stored at SI to AX and then increments SI if DF is 0
|
||||
os_compare_strings:
|
||||
pusha
|
||||
|
||||
.compare:
|
||||
lodsb
|
||||
scasb ; Compare di to si
|
||||
jne .unequal ; If they are no equal, jump to .unequal
|
||||
cmp al, 0 ; Check if string is finished
|
||||
je .equal ; If it has, return true
|
||||
jmp .compare ; Finally, repeat
|
||||
|
||||
.unequal:
|
||||
mov cl, 0 ; Change to 0 if unquality is proven
|
||||
popa
|
||||
ret
|
||||
|
||||
.equal:
|
||||
mov cl, 1
|
||||
popa
|
||||
ret
|
Reference in New Issue
Block a user