forked from crazyettin/EttinOS
Remove file name extensions from commands, implement command tails, ignore extra spaces either leading or trailing a command or between a command and its tail (except for drive changing), and fix a typo in hello.
This commit is contained in:
parent
dd139699af
commit
001faba978
2 changed files with 63 additions and 9 deletions
|
@ -2,10 +2,10 @@ CPU 8086
|
||||||
ORG 0x2000
|
ORG 0x2000
|
||||||
|
|
||||||
;Prints a hello world.
|
;Prints a hello world.
|
||||||
mov si, .hello
|
mov si, hello
|
||||||
mov ah, 0x2
|
mov ah, 0x2
|
||||||
int 0x21
|
int 0x21
|
||||||
int 0x20
|
int 0x20
|
||||||
|
|
||||||
;Data
|
;Data
|
||||||
.hello db "Hello world!", 0x0
|
hello db "Hello world!", 0x0
|
||||||
|
|
|
@ -86,20 +86,64 @@ int 0x21
|
||||||
cmp byte [input], 0x0
|
cmp byte [input], 0x0
|
||||||
jz shell
|
jz shell
|
||||||
;Check for a drive change command
|
;Check for a drive change command
|
||||||
mov si, input + 1
|
mov si, input + 0x1
|
||||||
mov di, driveletter + 1
|
mov di, driveletter + 0x1
|
||||||
call cmpstr
|
call cmpstr
|
||||||
jnc changedrive
|
jnc changedrive
|
||||||
|
|
||||||
;Load an execute a program
|
;Extract the program name
|
||||||
|
;Set SI at input and DI at program
|
||||||
|
mov si, input
|
||||||
|
mov di, program
|
||||||
|
;Ignore leading spaces
|
||||||
|
call ignoreleading
|
||||||
|
;Initialise program with spaces
|
||||||
|
mov cx, 0xc
|
||||||
|
mov al, 0x20
|
||||||
|
rep stosb
|
||||||
|
sub di, 0xc
|
||||||
|
;Initialise the length counter
|
||||||
|
mov bl, 0x8
|
||||||
|
extractprog:
|
||||||
|
;Load a character
|
||||||
|
lodsb
|
||||||
|
;Check for the string end
|
||||||
|
cmp al, 0x0
|
||||||
|
je addext
|
||||||
|
;Check for a space
|
||||||
|
cmp al, 0x20
|
||||||
|
je addext
|
||||||
|
;Check for the length limit
|
||||||
|
cmp bl, 0x0
|
||||||
|
je cmderror
|
||||||
|
;Store the character
|
||||||
|
stosb
|
||||||
|
;Decrease the counter
|
||||||
|
dec bl
|
||||||
|
jmp extractprog
|
||||||
|
;Add extension to the name
|
||||||
|
addext:
|
||||||
|
push si
|
||||||
|
mov si, extension
|
||||||
|
mov cx, 0x5
|
||||||
|
.loop:
|
||||||
|
lodsb
|
||||||
|
stosb
|
||||||
|
loop .loop
|
||||||
|
|
||||||
|
;Load and execute the program
|
||||||
;Load
|
;Load
|
||||||
mov bx, 0x2000
|
mov bx, 0x2000
|
||||||
mov si, input
|
;mov si, input
|
||||||
|
mov si, program
|
||||||
mov ah, 0x0
|
mov ah, 0x0
|
||||||
int 0x22
|
int 0x22
|
||||||
;Check for errors
|
;Check for errors
|
||||||
cmp al, 0x1
|
cmp al, 0x1
|
||||||
je cmderror
|
je cmderror
|
||||||
|
;Pass the command tail to the program
|
||||||
|
pop si
|
||||||
|
call ignoreleading
|
||||||
;Execute
|
;Execute
|
||||||
jmp 0x2000
|
jmp 0x2000
|
||||||
|
|
||||||
|
@ -157,13 +201,15 @@ call setdriveletter
|
||||||
jmp shell
|
jmp shell
|
||||||
|
|
||||||
;Data
|
;Data
|
||||||
|
welcomemsg db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0
|
||||||
drive db 0x0
|
drive db 0x0
|
||||||
driveletter db "?:", 0x0
|
driveletter db "?:", 0x0
|
||||||
welcomemsg db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0
|
|
||||||
prompt db "> ", 0x0
|
prompt db "> ", 0x0
|
||||||
driverrormsg db "Unknown drive", 0x0
|
|
||||||
cmderrormsg db "Unknown command", 0x0
|
|
||||||
input times 0x4c db 0x0
|
input times 0x4c db 0x0
|
||||||
|
program times 0xd db 0x0
|
||||||
|
extension db ".BIN", 0x0
|
||||||
|
cmderrormsg db "Unknown command", 0x0
|
||||||
|
driverrormsg db "Unknown drive", 0x0
|
||||||
crlf db 0xd, 0xa, 0x0
|
crlf db 0xd, 0xa, 0x0
|
||||||
|
|
||||||
;Set the drive letter
|
;Set the drive letter
|
||||||
|
@ -226,6 +272,14 @@ pop bx
|
||||||
pop ax
|
pop ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
;Ignore leading spaces in the command and its tail
|
||||||
|
ignoreleading:
|
||||||
|
lodsb
|
||||||
|
cmp al, 0x20
|
||||||
|
je ignoreleading
|
||||||
|
dec si
|
||||||
|
ret
|
||||||
|
|
||||||
;Print a CRLF
|
;Print a CRLF
|
||||||
printcrlf:
|
printcrlf:
|
||||||
;Store the initial registers in the stack
|
;Store the initial registers in the stack
|
||||||
|
|
Loading…
Reference in a new issue