Kernel
Code: Select all
org 1000h
;times 512-($-$$) db 0
include 'boot.asm'
;org 1000h
;push cs
;pop ds
start:
push cs
pop ds
mov si, hello
call printf
main:
mov ah, 0eh
mov al, '>'
int 10h
main2:
push cs
pop ds
mov di, buffer
call getinput
mov si, buffer
mov di, cmdhello
call cmpstr
jc sayhello
mov si, buffer
mov di, cmdprint
call cmpstr
jc prints
mov si, buffer
mov di, cmdhelp
call cmpstr
jc help
mov si, buffer
mov di, cmdqt
call cmpstr
jc quit
mov si, buffer
mov di, cmdcls
call cmpstr
jc clearscreen
mov si, buffer
mov di, cmdec
call cmpstr
jc echos
mov si, buffer
mov di, cmdal
call cmpstr
jc os_msgbox
mov si, buffer
mov di, cmdrest
call cmpstr
jc restartpmpt
cmp al, 0
je main
mov si, badcommand
call printf
jmp main
restartpmpt:
mov ah, 0fh
int 10h
push ax bx
mov ah, 00
int 10h
jmp start
nomsg:
mov si, n2put
call printf
jmp main
n2put db "Syntax: alert <caption>", 0ah, 0dh, 0
os_msgbox:
lea si, [buffer+5]
lodsb
cmp al, 0
je nomsg
msgbox:
call hide_curs
mov dl, 19
mov dh, 09
mloop:
call mv_curs
pusha
mov ah, 09h
mov bh, 0
mov cx, 42
mov bl, 01001111b
mov al, ' '
int 10h
inc dh
cmp dh, 16
je boxdone
jmp mloop
boxdone:
mov dl, 20
mov dh, 10
call mv_curs
xor cl, cl
printer:
lodsb
cmp al, 0
je mcont2
cmp cl, 40
jne printsl
mov dl, 20
inc dh
call mv_curs
xor cl, cl
;jmp printer
printsl:
mov ah, 0eh
int 10h
inc cl
jmp printer
mcont2:
mov bl, 11110000b
mov dh, 14
mov dl, 35
mov si, 10
mov di, 15
call drawblock
mov dl, 39
mov dh, 14
call mv_curs
mov si, okbtn
call printf
mouseclick:
mov ah, 01h
int 16h
jz m2
call keypress
m2:
;mov ax, 0004h
;mov cx, 165h
;mov dx, 78h
;int 33h
mov ax, 0003h
int 33h
cmp bx, 1
jne mouseclick
cmp dx, 70h
jnge mouseclick
cmp cx, 115h
jnge mouseclick
cmp cx, 165h
jnle mouseclick
cmp dx, 75h
jnle mouseclick
nowait:
call show_curs
jmp clearscreen
keypress:
mov ah, 00h
int 16h
cmp al, 0dh
je nowait
ret
okbtn db "OK ", 0ah, 0ah, 0dh, 0
noinpt:
mov si, msginpt
call printf
jmp main
msginpt db "Syntax: echo <text>", 0ah, 0dh, 0
echos:
mov di, buffer
lodsb
cmp al, 0
je noinpt
mov ah, 0eh
int 10h
mov al, 0dh
int 10h
echo2:
inc di
lodsb
cmp al, 0
jne contec
mov ax, 0e0dh
int 10h
mov al, 0ah
int 10h
jmp main
contec:
mov ah, 0eh
int 10h
jmp echo2
nprint:
mov si, nprintmsg
call printf
jmp main
nprintmsg db "Syntax: print <text>", 0ah, 0dh, 0
prints:
lea si, [buffer+5]
lodsb
cmp al, 0
je nprint
call printp
sayhello:
mov si, msghello
call printf
jmp main
clearscreen:
mov ah, 0fh
int 10h
push ax
push bx
mov ah, 0
int 10h
jmp main
help:
mov si, msghelp
call printf
jmp main
cmdhello db "hello", 0
msgbeta db "Thanks for using xOS!", 0
cmdec db "echo", 0
msghello db "Hello World!", 0Dh, 0ah, 0
cmdhelp db "help", 0
cmdal db "alert", 0
cmdcls db "cls", 0
cmdrest db "restart", 0
cmdprint db "print", 0
pbuff db 3fh dup (0)
;buglist db "Bugs: None so far except for the alert command's messagebox can be typed over", 0ah, 0dh, 0
msghelp db "Commands: ", 0dh, 0ah, "help: this menu", 0dh, 0ah, "hello: hello world", 0dh, 0ah, "print: allows user to type text to first printer", 0dh, 0ah, "quit: exit prompt", 0ah, 0dh, "echo: echo text after command", 0dh, 0ah, "cls: clear screen", 0ah, 0dh, "alert: shows messagebox with text from user input", 0ah, 0dh, "restart: restart prompt", 0ah, 0dh, 0
badcommand db "Bad command", 0Dh, 0ah, 0
hello db "Welcome to xOS beta", 0
cmdqt db "quit", 0
buffer db 40h dup (0)
quit:
mov ax, 4c00h
int 21h
printf:
lodsb
cmp al, 0
jne cont
ret
cont:
mov ah, 0eh
int 10h
jmp printf
cmpstr:
mov al, [si]
mov bl, [di]
cmp al, 20h
je spexcept
cmp al, bl
jne notequal
cmp al, 0
je done
inc di
inc si
jmp cmpstr
spexcept:
inc di
mov al, [di]
cmp al, 0
je notequal
;add di, 2
jmp done
done:
stc
ret
notequal:
clc
ret
getinput:
push cs
pop ds
xor cl, cl
loops:
mov ah, 00h
int 16h
cmp al, 0dh
je entered
cmp al, 08h
je bkspace
cmp cl, 3fh
je loops
mov ah, 0eh
int 10h
stosb
inc cl
jmp loops
bkspace:
cmp cl, 0 ; beginning of string?
je loops ; yes, ignore the key
dec di
mov byte [di], 0 ; delete character
dec cl ; decrement counter as well
mov ah, 0eh
mov al, 08h
int 10h ; backspace on the screen
mov al, ' '
int 10h ; blank character out
mov al, 08h
int 10h ; backspace again
jmp loops ; go to the main loop
entered:
mov al, 0
stosb
mov ah, 0eh
mov al, 0dh
int 10h
mov al, 0ah
int 10h
ret
printp:
mov ah, 00h
mov dx, 00h
ploop:
lodsb
cmp al, 0
jne cloop
ret
cloop:
int 17h
jmp ploop
mv_curs:
pusha
mov ah, 02h
mov bh, 00
int 10h
popa
ret
drawblock:
pusha
.more:
call mv_curs
mov ah, 09h
mov bh, 0
mov cx, si
mov al, ' '
int 10h
inc dh
mov ax, 0
mov al, dh
cmp ax, di
jne .more
popa
ret
hide_curs:
pusha
mov ch, 32
mov ah, 1
mov al, 3
int 10h
popa
ret
wait_key:
pusha
mov ah, 00h
int 16h
cmp al, 13
jne wait_key
call show_curs
popa
ret
show_curs:
pusha
mov ch, 6
mov cl, 7
mov ah, 1
mov al, 3
int 10h
popa
ret
os_newline:
pusha
mov ax, 0e0dh
int 10h
mov ax, 0e0ah
int 10h
popa
ret
times 1474560-($-$$) db 0
;times 512-($-$$) db (0)
Code: Select all
org 7c00h
starts:
push cs
pop ds
push cs
pop es
cli
mov ax, 0x0000
mov ss, ax
mov sp, 0xFFFF
sti
call loads
jmp 1000h:0
lsuccess db "Load successful", 0ah, 0dh, 0
rattempt db "Atempting to read drive", 0ah, 0dh, 0
attempt db "Atempting to load kernel", 0ah, 0dh, 0
rsuccess db "Drive successfully restarted", 0ah, 0dh, 0
resttempt db "Attempting to restart drive", 0ah, 0dh, 0
bootdrv db 0
ptext:
lodsb
cmp al, 0
jne pcont
retn
pcont:
mov ah, 0eh
int 10h
jmp ptext
loads:
push ds
.reset:
mov si, resttempt
call ptext
mov ax, 0
mov dl, [bootdrv]
int 13h
jc .reset
pop ds
mov si, rsuccess
call ptext
.read:
mov si, rattempt
call ptext
mov ax, 0x1000
mov es, ax
mov bx, 0
mov ah, 2
mov al, 5
mov cx, 2
mov dh, 0
mov dl, [bootdrv]
int 13h
jc .read
mov si, lsuccess
call ptext
retn
times 512-($-$$) -2 db 0
dw 0aa55h