1 ;----------------------------------------------------------;
2 ; BOS 0.04 Christoffer Bubach, 2004-2005. ;
3 ;----------------------------------------------------------;
7 ;----------------------------------------------------------;
14 prompt db 'BOS kernel>', 0
15 cmd_buffer: times 255 db 0 ; 255 char command buffer
19 ;----------------------------------------------;
20 ; print the prompt for the first time.. :-) ;
21 ;----------------------------------------------;
23 mov byte [kbd_status], 0 ; reset LEDs to 0..
36 ;-------------------------------;
37 ; Main shell function & loop ;
38 ;-------------------------------;
40 mov cx, 0 ; max 254 chars in command
41 .loop: ; no. 255 is always a 0
43 push cx ; better be sure it´s safe..
46 call getc ; keyboard.inc
54 cmp ah, 14 ; backspace
57 cmp al, 0 ; no normal key
58 je .loop ; exceptions above..
63 stosb ; store char in buffer
66 mov bl, al ; print it..
73 mov al, 0 ; the command buffer is
74 stosb ; in ASCIIZ format..
78 cmp cx, 0 ; can´t delete the prompt.. ;-)
80 dec edi ; "remove" one char from buffer
81 call backspace ; do backspace on screen
82 dec cx ; decrease buffer counter
89 ;---------------------------------;
90 ; check for valid cmd ;
91 ;---------------------------------;
96 mov ebp, 0 ; command-table counter
98 ;------------------------------------------;
99 ; big loop, for each command in table ;
100 ;------------------------------------------;
102 mov ecx, 0 ; char counter
107 ;------------------------------------------;
108 ; smaller loop for each char in command ;
109 ;------------------------------------------;
111 cmp byte [edi], ' ' ; space or zero
112 je .l_chk ; both indicate
113 cmp byte [edi], 0 ; "end of command"
118 cmp byte [esi], 0 ; commands are equal, but
119 jne .new_cmd ; do not match in size..
123 cmp byte [esi], 0 ; commands are equal, but
124 je .new_cmd ; do not match in size..
132 inc ecx ; inc char counter
134 ;----------------------;
135 ; end of small loop ;
136 ;----------------------;
139 inc ebp ; inc command counter
140 mov edi, cmd_buffer ; remember to point to the right place.. ;-)
143 cmp byte [esi], 0 ; loop until end of command
148 ;----------------------;
150 ;----------------------;
154 ;--------------------------;
155 ; done. command found ;
156 ;--------------------------;
158 cmp ecx, 0 ; make sure it´s more
159 je .d_quit ; then 0 chars..
162 call dword [ebp+call_table]
165 jmp .cont ; then go back to the shell
168 ;--------------------------;
169 ; command not found ;
170 ;--------------------------;
173 ; call search_current_directory_for_file.... :-)
175 call no_such_cmd ; print error..
176 jmp .cont ; then go back to the shell
178 ;---------------------------------;
179 ; make the prompt appear again ;
180 ;---------------------------------;