diff --git a/src/HELLO.ASM b/src/HELLO.ASM index d892647..ab81a21 100644 --- a/src/HELLO.ASM +++ b/src/HELLO.ASM @@ -2,10 +2,10 @@ CPU 8086 ORG 0x2000 ;Prints a hello world. -mov si, .hello +mov si, hello mov ah, 0x2 int 0x21 int 0x20 ;Data -.hello db "Hello world!", 0x0 +hello db "Hello world!", 0x0 diff --git a/src/SYSTEM.ASM b/src/SYSTEM.ASM index 6c0a1d1..7a05636 100644 --- a/src/SYSTEM.ASM +++ b/src/SYSTEM.ASM @@ -86,20 +86,64 @@ int 0x21 cmp byte [input], 0x0 jz shell ;Check for a drive change command -mov si, input + 1 -mov di, driveletter + 1 +mov si, input + 0x1 +mov di, driveletter + 0x1 call cmpstr 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 mov bx, 0x2000 -mov si, input +;mov si, input +mov si, program mov ah, 0x0 int 0x22 ;Check for errors cmp al, 0x1 je cmderror +;Pass the command tail to the program +pop si +call ignoreleading ;Execute jmp 0x2000 @@ -157,13 +201,15 @@ call setdriveletter jmp shell ;Data +welcomemsg db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0 drive db 0x0 driveletter db "?:", 0x0 -welcomemsg db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0 prompt db "> ", 0x0 -driverrormsg db "Unknown drive", 0x0 -cmderrormsg db "Unknown command", 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 ;Set the drive letter @@ -226,6 +272,14 @@ pop bx pop ax ret +;Ignore leading spaces in the command and its tail +ignoreleading: +lodsb +cmp al, 0x20 +je ignoreleading +dec si +ret + ;Print a CRLF printcrlf: ;Store the initial registers in the stack