1 ; ==================================================================
2 ; MikeOS -- The Mike Operating System kernel
3 ; Copyright (C) 2006 - 2011 MikeOS Developers -- see doc/LICENSE.TXT
5 ; COMMAND LINE INTERFACE
6 ; ==================================================================
17 mov si, prompt
; Main loop; prompt for input
20 mov ax, input
; Get command string from user
25 mov ax, input
; Remove trailing spaces
28 mov si, input
; If just enter pressed, prompt again
32 mov si, input
; Convert to uppercase for comparison
33 call os_string_uppercase
38 mov di, exit_string
; 'EXIT' entered?
39 call os_string_compare
42 mov di, help_string
; 'HELP' entered?
43 call os_string_compare
46 mov di, cls_string
; 'CLS' entered?
47 call os_string_compare
50 mov di, dir_string
; 'DIR' entered?
51 call os_string_compare
52 jc near list_directory
54 mov di, ver_string
; 'VER' entered?
55 call os_string_compare
58 mov di, time_string
; 'TIME' entered?
59 call os_string_compare
62 mov di, date_string
; 'DATE' entered?
63 call os_string_compare
66 mov di, cat_string
; 'CAT' entered?
68 call os_string_strincmp
73 ; If the user hasn't entered any of the above commands, then we
74 ; need to check if an executable filename (.BIN) was entered...
76 mov si, input
; User entered dot in filename?
78 call os_find_char_in_string
89 add si, ax ; Move to end of input string
95 mov byte [si+4], 0 ; Zero-terminate string
99 mov si, input
; User tried to execute kernel?
100 mov di, kern_file_string
101 call os_string_compare
104 mov ax, input
; If not, try to load specified program
108 mov word [file_size
], bx
110 jc bin_fail
; Skip next part if program with .BIN not found
112 mov ax, input
; Get into right place in filename to check extension
113 call os_string_length
118 mov di, bin_extension
; Is it BIN?
119 call os_string_compare
122 mov ax, 0 ; Clear all registers
129 call 32768 ; Call the external program
131 jmp get_cmd
; When program has finished, start again
136 call os_string_length
141 mov di, bas_extension
142 call os_string_compare
146 mov word bx, [file_size
]
156 call os_string_length
159 add si, ax ; Move to end of input string
160 sub si, 4 ; Subtract 4 chars, because we added .BIN to it before!
162 mov byte [si], '.' ; See if there's a .BAS extension for this
166 mov byte [si+4], 0 ; Zero-terminate string
168 mov ax, input
; Try to load the .BAS code
172 jc total_fail
; Skip if program not found
175 call os_run_basic
; Otherwise execute the code!
186 ; ------------------------------------------------------------------
194 ; ------------------------------------------------------------------
201 ; ------------------------------------------------------------------
205 call os_get_time_string
208 call os_print_newline
212 ; ------------------------------------------------------------------
216 call os_get_date_string
219 call os_print_newline
223 ; ------------------------------------------------------------------
231 ; ------------------------------------------------------------------
234 mov si, kern_warn_msg
239 ; ------------------------------------------------------------------
244 mov ax, dirlist
; Get list of files on disk
245 call os_get_file_list
248 mov ah, 0Eh
; BIOS teletype function
251 lodsb ; Start printing filenames
252 cmp al, 0 ; Quit if end of string
255 cmp al, ',' ; If comma in list string, don't print it
258 call os_print_newline
; But print a newline instead
267 call os_print_newline
271 ; ------------------------------------------------------------------
276 cmp bx, 0 ; Was a filename provided?
277 jne .filename_provided
279 mov si, nofilename_msg
; If not, show error message
286 call os_file_exists
; Check if file exists
289 mov cx, 32768 ; Load file into second 32K
292 mov word [file_size
], bx
294 cmp bx, 0 ; Nothing in the file?
298 mov ah, 0Eh
; int 10h teletype function
300 lodsb ; Get byte from loaded file
302 cmp al, 0Ah ; Move to start of line if we get a newline char
305 call os_get_cursor_pos
311 dec bx ; Count down file size
312 cmp bx, 0 ; End of file?
324 ; ------------------------------------------------------------------
330 ; ------------------------------------------------------------------
333 dirlist times
1024 db 0
334 tmp_string times
15 db 0
337 bin_extension
db 'BIN', 0
338 bas_extension
db 'BAS', 0
341 help_text
db 'Inbuilt commands: DIR, CAT, CLS, HELP, TIME, DATE, VER, EXIT', 13, 10, 0
342 invalid_msg
db 'No such command or program', 13, 10, 0
343 nofilename_msg
db 'No filename specified', 13, 10, 0
344 notfound_msg
db 'File not found', 13, 10, 0
345 version_msg
db 'MikeOS ', MIKEOS_VER
, 13, 10, 0
347 exit_string
db 'EXIT', 0
348 help_string
db 'HELP', 0
349 cls_string
db 'CLS', 0
350 dir_string
db 'DIR', 0
351 time_string
db 'TIME', 0
352 date_string
db 'DATE', 0
353 ver_string
db 'VER', 0
354 cat_string
db 'CAT', 0
356 kern_file_string
db 'KERNEL.BIN', 0
357 kern_warn_msg
db 'Cannot execute kernel file!', 13, 10, 0
360 ; ==================================================================