86 lines
2.5 KiB
NASM
86 lines
2.5 KiB
NASM
[bits 16] ; Set to 16-bit mode
|
|
[org 0x7C00] ; BIOS loads the bootloader at this address
|
|
|
|
start:
|
|
; Clear screen
|
|
mov ax, 0x0003 ; Set video mode to 3 (80x25 color text)
|
|
int 0x10 ; BIOS interrupt to set video mode
|
|
|
|
; Print welcome message
|
|
mov si, welcome_message
|
|
call print_string
|
|
|
|
; cpu info
|
|
mov eax, 0x1
|
|
cpuid
|
|
test edx, 1<<25
|
|
jz .noSSE
|
|
;SSE is available
|
|
command_loop:
|
|
; Print prompt
|
|
mov si, prompt_message
|
|
call print_string
|
|
|
|
; Read user input
|
|
call read_input
|
|
|
|
; Process command
|
|
cmp al, 'h' ; Check for 'h' command (help)
|
|
je print_help
|
|
cmp al, 'q' ; Check for 'q' command (quit)
|
|
je quit_terminal
|
|
cmp al, 'f' ; Check for 'f' command (heckerfetch)
|
|
je heckerfetch
|
|
|
|
; Unknown command response
|
|
mov si, unknown_command_message
|
|
call print_string
|
|
jmp command_loop ; Repeat the command loop
|
|
|
|
print_help:
|
|
mov si, help_message
|
|
call print_string
|
|
jmp command_loop ; Return to command loop
|
|
|
|
heckerfetch:
|
|
mov si, heckerfetch_message
|
|
call print_string
|
|
jmp command_loop ; Return to command loop
|
|
|
|
quit_terminal:
|
|
mov si, goodbye_message
|
|
call print_string
|
|
jmp hang ; Hang the system
|
|
|
|
; Function to read a character from keyboard input
|
|
read_input:
|
|
mov ah, 0x00 ; BIOS function to read a character
|
|
int 0x16 ; Call BIOS interrupt
|
|
ret ; Return with character in AL
|
|
|
|
; Function to print a string
|
|
print_string:
|
|
mov ah, 0x0E ; BIOS teletype output function
|
|
.next_char:
|
|
lodsb ; Load byte at DS:SI into AL and increment SI
|
|
cmp al, 0 ; Check for null terminator
|
|
je .done ; If null, we are done
|
|
int 0x10 ; Call BIOS to print character in AL
|
|
jmp .next_char ; Repeat for next character
|
|
.done:
|
|
ret ; Return from function
|
|
|
|
; Data section for messages
|
|
welcome_message db 'Welcome to the HeckerOS!', 0
|
|
prompt_message db 'Enter command (h for help, q to quit, f for heckerfetch): ', 0
|
|
help_message db 'Available commands: h (help), q (quit), f (heckerfetch)', 0
|
|
unknown_command_message db 'Unknown command! Try again.', 0
|
|
goodbye_message db 'Goodbye!', 0
|
|
heckerfetch_message db 'OS: HeckerOS Beta, CPU: HeckerSoft Generic CPU 0GHZ, Host: HeckerSoft Unknown Host', 0
|
|
|
|
; Bootloader signature (must be present)
|
|
times 510 - ($ - $$) db 0 ; Fill the rest of the sector with zeros
|
|
dw 0xAA55 ; Boot signature
|
|
|
|
hang:
|
|
jmp hang ; Jump to hang indefinitely |