Last active
March 28, 2025 13:02
-
-
Save bromaster912791/94478b0651a979a987733f44610c1820 to your computer and use it in GitHub Desktop.
my own os in asm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ORG 0x7C00] ; BIOS loads bootloader at 0x7C00 | |
[BITS 16] ; 16-bit real mode | |
section .text | |
start: | |
cli ; Disable interrupts | |
cld ; Clear direction flag | |
xor ax, ax ; Zero out registers | |
mov ds, ax | |
mov es, ax | |
mov ss, ax | |
mov sp, 0x7C00 ; Set stack pointer | |
sti ; Enable interrupts | |
call clear_screen ; Clear screen | |
call print_welcome ; Print welcome message | |
call set_time ; Prompt user to set time | |
call set_date ; Prompt user to set date | |
call print_prompt ; Print initial prompt | |
command_loop: | |
call read_command ; Read user input | |
call process_command ; Process input | |
jmp command_loop ; Repeat | |
; Function to clear the screen | |
clear_screen: | |
mov ah, 0x06 | |
mov al, 0 | |
mov bh, 0x02 ; Green text on black background | |
mov cx, 0 | |
mov dh, 24 | |
mov dl, 79 | |
int 0x10 | |
ret | |
; Function to print welcome message | |
print_welcome: | |
mov si, welcome_msg | |
call print_string | |
ret | |
; Function to print prompt | |
print_prompt: | |
mov si, prompt_msg | |
call print_string | |
ret | |
; Function to process command | |
process_command: | |
mov si, buffer | |
mov di, cmd_clear | |
call strcmp | |
jz clear_screen | |
mov si, buffer | |
mov di, cmd_poke | |
call strcmp | |
jz basic_poke | |
mov si, buffer | |
mov di, cmd_peek | |
call strcmp | |
jz basic_peek | |
mov si, buffer | |
mov di, cmd_time | |
call strcmp | |
jz show_time | |
mov si, buffer | |
mov di, cmd_date | |
call strcmp | |
jz show_date | |
mov si, buffer | |
mov di, cmd_randcolor | |
call strcmp | |
jz randomize_color | |
ret | |
; Function to prompt for date | |
set_date: | |
mov si, set_date_msg | |
call print_string | |
call read_command | |
mov si, buffer | |
call strcpy | |
ret | |
; Function to show stored date | |
show_date: | |
mov si, date_msg | |
call print_string | |
mov si, buffer | |
call print_string | |
call display_season_icon | |
ret | |
; Display season icon based on month | |
; Assumes date stored as MM/DD | |
display_season_icon: | |
mov si, buffer | |
lodsb ; Get first digit of month | |
sub al, '0' | |
imul al, 10 | |
lodsb | |
sub al, '0' | |
add al, ah ; Convert MM to integer | |
cmp al, 3 | |
jl .winter ; January-February | |
cmp al, 6 | |
jl .spring ; March-May | |
cmp al, 9 | |
jl .summer ; June-August | |
cmp al, 12 | |
jl .fall ; September-November | |
jmp .winter ; December | |
.spring: | |
mov si, spring_icon | |
jmp .print_icon | |
.summer: | |
mov si, summer_icon | |
jmp .print_icon | |
.fall: | |
mov si, fall_icon | |
jmp .print_icon | |
.winter: | |
mov si, winter_icon | |
jmp .print_icon | |
.print_icon: | |
call print_string | |
ret | |
; Data section | |
data: | |
welcome_msg db 'Welcome to Happy OS', 0 | |
set_time_msg db 'Set time (HH:MM): ', 0 | |
set_date_msg db 'Set date (MM/DD): ', 0 | |
time_msg db 'Current Time: ', 0 | |
date_msg db 'Current Date: ', 0 | |
spring_icon db ' *', 0 | |
summer_icon db ' ^', 0 | |
fall_icon db ' %', 0 | |
winter_icon db ' #', 0 | |
basic_msg db 'Entering BASIC mode. Supported: PRINT, GOTO, INPUT, LET, IF, FOR, RND, TIMER, SOUND, DICE, TIME, DATE, POKE, PEEK, RANDCOLOR, END', 0 | |
prompt_msg db 'Simple Kernel> ', 0 | |
cmd_clear db 'clear', 0 | |
cmd_poke db 'POKE ', 0 | |
cmd_peek db 'PEEK ', 0 | |
cmd_time db 'TIME', 0 | |
cmd_date db 'DATE', 0 | |
cmd_randcolor db 'RANDCOLOR', 0 | |
num_buffer times 6 db 0 | |
buffer times 64 db 0 | |
date_buffer times 10 db 0 | |
exec_buffer times 256 db 0 | |
basic_program times 512 db 0 | |
times 510-($-$$) db 0 | |
dw 0xAA55 ; Boot signature | |
;Brogan-Guthrie | |
;edit-how-much-you-want-and-like-becuase-its-underneth-the-GNU-General-License-version-2-(GPLv2)-copyright | |
now its 32 bit on its own page
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
32 bit version soon :)