Command table
Posted: Thu Aug 13, 2009 1:26 am
I am trying to add a command table to my os. I can compare the data that was typed into the prompt with the table and determine which command was entered, but I can figure out how to make it call the function.
Here is the command table:
Here is the code to compare the command with the command table:
Here is the command table:
Code: Select all
commands:
db 'hi', 0
db 'help', 0
db '?', 0
db 0xFF ; end of command table
call_table:
dd cmd_hi
dd cmd_help
dd cmd_help
Code: Select all
mov si, commands ;set si to command table
mov di, buffer ;set di to command
mov cx, 0
jmp NewChar
NextCmd:
inc cx
mov di, buffer ;set di to command
NewChar:
lodsb ; AL = [SI]
test al, al ; if [si] = 0 then end of command
jz FoundCmd ; in command table
mov ah, [di] ; load [di]
inc di ; next char in command
or ah, 0x20 ; convert user input to lowercase
cmp al, ah ; compare user to command table
jz NewChar
LoopTo0: ; ok not this command
lodsb ; so now we need to go the end
test al, al ; of command in the command table
jnz LoopTo0 ; marked by 0
cmp byte [si], 0xFF
jne NextCmd ; no? - good, check next command
mov si, badcommand
call print
jmp mainloop
FoundCmd:
;How do i call the function here?
jmp mainloop