Move system calls to interrupts and rename the main system loop to shell.
This commit is contained in:
parent
fc3a0bbbe9
commit
59d9c7e89d
|
@ -5,7 +5,8 @@ echo:
|
||||||
;Read a string
|
;Read a string
|
||||||
mov di, buffer
|
mov di, buffer
|
||||||
mov al, 0xff
|
mov al, 0xff
|
||||||
call readln
|
mov ah, 0x3
|
||||||
|
int 0x21
|
||||||
|
|
||||||
;Check for an empty string
|
;Check for an empty string
|
||||||
cmp byte [buffer], 0x0
|
cmp byte [buffer], 0x0
|
||||||
|
@ -13,7 +14,8 @@ je .done
|
||||||
|
|
||||||
;Print the string
|
;Print the string
|
||||||
mov si, buffer
|
mov si, buffer
|
||||||
call println
|
mov ah, 0x2
|
||||||
|
int 0x21
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -5,7 +5,8 @@ fileify:
|
||||||
;Read a string
|
;Read a string
|
||||||
mov di, buffer
|
mov di, buffer
|
||||||
mov al, 0xff
|
mov al, 0xff
|
||||||
call readln
|
mov ah, 0x3
|
||||||
|
int 0x21
|
||||||
|
|
||||||
;Set SI and DI
|
;Set SI and DI
|
||||||
mov si, buffer
|
mov si, buffer
|
||||||
|
@ -50,13 +51,15 @@ jmp .extloop
|
||||||
.error:
|
.error:
|
||||||
pop ax
|
pop ax
|
||||||
mov si, .errormsg
|
mov si, .errormsg
|
||||||
call println
|
mov ah, 0x2
|
||||||
|
int 0x21
|
||||||
jmp .done
|
jmp .done
|
||||||
|
|
||||||
.print:
|
.print:
|
||||||
pop ax
|
pop ax
|
||||||
mov si, .file
|
mov si, .file
|
||||||
call println
|
mov ah, 0x2
|
||||||
|
int 0x21
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
hello:
|
hello:
|
||||||
|
|
||||||
mov si, .hello
|
mov si, .hello
|
||||||
call println
|
mov ah, 0x2
|
||||||
|
int 0x21
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.hello db "Hello world!", 0x0
|
.hello db "Hello world!", 0x0
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
help:
|
help:
|
||||||
|
|
||||||
mov si, .help
|
mov si, .help
|
||||||
call println
|
mov ah, 0x2
|
||||||
|
int 0x21
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ mov [.ascii], al
|
||||||
|
|
||||||
;Print the prefix
|
;Print the prefix
|
||||||
mov si, .prefix
|
mov si, .prefix
|
||||||
call printstr
|
mov ah, 0x0
|
||||||
|
int 0x21
|
||||||
|
|
||||||
;Convert the scancode to a hex string
|
;Convert the scancode to a hex string
|
||||||
mov al, [.scan]
|
mov al, [.scan]
|
||||||
|
@ -27,7 +28,8 @@ call .byte2hex
|
||||||
|
|
||||||
;Print the keycode
|
;Print the keycode
|
||||||
mov si, .keycode
|
mov si, .keycode
|
||||||
call println
|
mov ah, 0x2
|
||||||
|
int 0x21
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ push si
|
||||||
|
|
||||||
;Print the newline
|
;Print the newline
|
||||||
mov si, .newline
|
mov si, .newline
|
||||||
call printstr
|
mov ah, 0x0
|
||||||
|
int 0x21
|
||||||
|
|
||||||
;Load the initial registers from the stack
|
;Load the initial registers from the stack
|
||||||
pop si
|
pop si
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
println:
|
println:
|
||||||
|
|
||||||
;Print the string
|
;Print the string
|
||||||
call printstr
|
mov ah, 0x0
|
||||||
|
int 0x21
|
||||||
|
|
||||||
;Print a newline
|
;Print a newline
|
||||||
call newline
|
call newline
|
||||||
|
|
||||||
ret
|
iret
|
||||||
|
|
|
@ -23,4 +23,4 @@ jmp .loop
|
||||||
;Load the initial registers from the stack
|
;Load the initial registers from the stack
|
||||||
pop ax
|
pop ax
|
||||||
|
|
||||||
ret
|
iret
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
readln:
|
readln:
|
||||||
|
|
||||||
;Read the string
|
;Read the string
|
||||||
call readstr
|
mov ah, 0x1
|
||||||
|
int 0x21
|
||||||
|
|
||||||
;Print a newline
|
;Print a newline
|
||||||
call newline
|
call newline
|
||||||
|
|
||||||
ret
|
iret
|
||||||
|
|
|
@ -129,7 +129,7 @@ pop cx
|
||||||
pop bx
|
pop bx
|
||||||
pop ax
|
pop ax
|
||||||
|
|
||||||
ret
|
iret
|
||||||
|
|
||||||
;Move the cursor forward
|
;Move the cursor forward
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,33 @@ ORG 0x500
|
||||||
|
|
||||||
jmp start
|
jmp start
|
||||||
|
|
||||||
;Calls
|
;Interrupt handler
|
||||||
%include "CMPSTR.INC"
|
int0x20:
|
||||||
|
jmp shell
|
||||||
|
int0x21:
|
||||||
|
cmp ah, 0x0
|
||||||
|
je printstr
|
||||||
|
cmp ah, 0x1
|
||||||
|
je readstr
|
||||||
|
cmp ah, 0x2
|
||||||
|
je println
|
||||||
|
cmp ah, 0x3
|
||||||
|
je readln
|
||||||
|
iret
|
||||||
|
int0x22:
|
||||||
|
;To do: loading and saving files
|
||||||
|
iret
|
||||||
|
|
||||||
|
;System calls
|
||||||
%include "PRINTSTR.INC"
|
%include "PRINTSTR.INC"
|
||||||
%include "READSTR.INC"
|
%include "READSTR.INC"
|
||||||
%include "NEWLINE.INC"
|
|
||||||
%include "PRINTLN.INC"
|
%include "PRINTLN.INC"
|
||||||
%include "READLN.INC"
|
%include "READLN.INC"
|
||||||
|
|
||||||
|
;Internal calls
|
||||||
|
%include "CMPSTR.INC"
|
||||||
|
%include "NEWLINE.INC"
|
||||||
|
|
||||||
;Commands
|
;Commands
|
||||||
%include "ECHO.INC"
|
%include "ECHO.INC"
|
||||||
%include "FILEIFY.INC"
|
%include "FILEIFY.INC"
|
||||||
|
@ -20,42 +39,61 @@ jmp start
|
||||||
|
|
||||||
start:
|
start:
|
||||||
|
|
||||||
|
;Setup
|
||||||
;Set up the stack
|
;Set up the stack
|
||||||
cli
|
cli
|
||||||
mov sp, stack
|
mov sp, stack
|
||||||
add sp, 0x100
|
add sp, 0x100
|
||||||
sti
|
sti
|
||||||
|
;Set up the interrupt vectors
|
||||||
|
;Interrupt 0x20
|
||||||
|
mov ax, int0x20
|
||||||
|
mov [0x80], ax
|
||||||
|
mov ax, 0x0
|
||||||
|
mov [0x82], ax
|
||||||
|
;Interrupt 0x21
|
||||||
|
mov ax, int0x21
|
||||||
|
mov [0x84], ax
|
||||||
|
mov ax, 0x0
|
||||||
|
mov [0x86], ax
|
||||||
|
;Interrupt 0x22
|
||||||
|
mov ax, int0x22
|
||||||
|
mov [0x88], ax
|
||||||
|
mov ax, 0x0
|
||||||
|
mov [0x8a], ax
|
||||||
|
|
||||||
;Print a welcome message
|
;Print a welcome message
|
||||||
mov si, welcomemsg
|
mov si, welcomemsg
|
||||||
call println
|
mov ah, 0x2
|
||||||
|
int 0x21
|
||||||
|
|
||||||
loop:
|
shell:
|
||||||
|
|
||||||
;Prompt for and read a command
|
;Prompt for and read a command
|
||||||
;Print a prompt
|
;Print a prompt
|
||||||
mov si, prompt
|
mov si, prompt
|
||||||
call printstr
|
mov ah, 0x0
|
||||||
|
int 0x21
|
||||||
;Read a command
|
;Read a command
|
||||||
mov di, buffer
|
mov di, buffer
|
||||||
mov al, 0xff
|
mov al, 0xff
|
||||||
call readln
|
mov ah, 0x3
|
||||||
|
int 0x21
|
||||||
|
|
||||||
;Identify and execute the command
|
;Identify and execute the command
|
||||||
exec:
|
exec:
|
||||||
;Check for no command
|
;Check for no command
|
||||||
cmp byte [buffer], 0x0
|
cmp byte [buffer], 0x0
|
||||||
je loop
|
je shell
|
||||||
.echo:
|
.echo:
|
||||||
;Check
|
;Check
|
||||||
mov si, buffer
|
mov si, buffer
|
||||||
mov di, cmd.echo
|
mov di, cmd.echo
|
||||||
call cmpstr
|
call cmpstr
|
||||||
jnc .fileify
|
jnc .fileify
|
||||||
;jnc .hello
|
|
||||||
;Execute
|
;Execute
|
||||||
call echo
|
call echo
|
||||||
jmp loop
|
jmp shell
|
||||||
.fileify:
|
.fileify:
|
||||||
;Check
|
;Check
|
||||||
mov si, buffer
|
mov si, buffer
|
||||||
|
@ -64,7 +102,7 @@ call cmpstr
|
||||||
jnc .hello
|
jnc .hello
|
||||||
;Execute
|
;Execute
|
||||||
call fileify
|
call fileify
|
||||||
jmp loop
|
jmp shell
|
||||||
.hello:
|
.hello:
|
||||||
;Check
|
;Check
|
||||||
mov si, buffer
|
mov si, buffer
|
||||||
|
@ -73,7 +111,7 @@ call cmpstr
|
||||||
jnc .help
|
jnc .help
|
||||||
;Execute
|
;Execute
|
||||||
call hello
|
call hello
|
||||||
jmp loop
|
jmp shell
|
||||||
.help:
|
.help:
|
||||||
;Check
|
;Check
|
||||||
mov si, buffer
|
mov si, buffer
|
||||||
|
@ -82,7 +120,7 @@ call cmpstr
|
||||||
jnc .keycode
|
jnc .keycode
|
||||||
;Execute
|
;Execute
|
||||||
call help
|
call help
|
||||||
jmp loop
|
jmp shell
|
||||||
.keycode:
|
.keycode:
|
||||||
;Check
|
;Check
|
||||||
mov si, buffer
|
mov si, buffer
|
||||||
|
@ -91,11 +129,12 @@ call cmpstr
|
||||||
jnc .error
|
jnc .error
|
||||||
;Execute
|
;Execute
|
||||||
call keycode
|
call keycode
|
||||||
jmp loop
|
jmp shell
|
||||||
.error:
|
.error:
|
||||||
mov si, errormsg
|
mov si, errormsg
|
||||||
call println
|
mov ah, 0x2
|
||||||
jmp loop
|
int 0x21
|
||||||
|
jmp shell
|
||||||
|
|
||||||
welcomemsg db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0
|
welcomemsg db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue