]>
wirehaze git hosting - BOS.git/blob - kernel/shell/shell.asm
ea157aeb2c747da65c86d5b17d08485d755e8e16
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..
35 ;-------------------------------;
36 ; Main shell function & loop ;
37 ;-------------------------------;
39 mov cx, 0 ; max 254 chars in command
40 .loop: ; no. 255 is always a 0
42 push cx ; better be sure it´s safe..
45 call getc
; keyboard.inc
53 cmp ah, 14 ; backspace
56 cmp al, 0 ; no normal key
57 je .loop ; exceptions above..
62 stosb ; store char in buffer
65 mov bl, al ; print it..
72 mov al, 0 ; the command buffer is
73 stosb ; in ASCIIZ format..
77 cmp cx, 0 ; can´t delete the prompt.. ;-)
79 dec edi ; "remove" one char from buffer
80 call backspace
; do backspace on screen
81 dec cx ; decrease buffer counter
88 ;---------------------------------;
89 ; check for valid cmd ;
90 ;---------------------------------;
95 mov ebp, 0 ; command-table counter
97 ;------------------------------------------;
98 ; big loop, for each command in table ;
99 ;------------------------------------------;
101 mov ecx, 0 ; char counter
106 ;------------------------------------------;
107 ; smaller loop for each char in command ;
108 ;------------------------------------------;
110 cmp byte [edi], ' ' ; space or zero
111 je .l_chk
; both indicate
112 cmp byte [edi], 0 ; "end of command"
117 cmp byte [esi], 0 ; commands are equal, but
118 jne .new_cmd
; do not match in size..
122 cmp byte [esi], 0 ; commands are equal, but
123 je .new_cmd
; do not match in size..
131 inc ecx ; inc char counter
133 ;----------------------;
134 ; end of small loop ;
135 ;----------------------;
138 inc ebp ; inc command counter
139 mov edi, cmd_buffer
; remember to point to the right place.. ;-)
142 cmp byte [esi], 0 ; loop until end of command
147 ;----------------------;
149 ;----------------------;
153 ;--------------------------;
154 ; done. command found ;
155 ;--------------------------;
157 cmp ecx, 0 ; make sure it´s more
158 je .d_quit
; then 0 chars..
161 call dword [ebp+call_table
]
164 jmp .cont
; then go back to the shell
167 ;--------------------------;
168 ; command not found ;
169 ;--------------------------;
172 ; call search_current_directory_for_file.... :-)
174 call no_such_cmd
; print error..
175 jmp .cont
; then go back to the shell
177 ;---------------------------------;
178 ; make the prompt appear again ;
179 ;---------------------------------;