]> wirehaze git hosting - BOS.git/blobdiff - kernel/shell/shell.asm

wirehaze git hosting

Update shell.asm
[BOS.git] / kernel / shell / shell.asm
index 25e7686ce096341b469a1f139b6bbe20f27f057d..646ca45512efed7b4d30ec494d865913ddc68711 100755 (executable)
@@ -11,8 +11,8 @@
 ;  Variabels   ;\r
 ;--------------;\r
 \r
 ;  Variabels   ;\r
 ;--------------;\r
 \r
-prompt                 db   'BOS kernel>', 0\r
-cmd_buffer: times 255  db   0                        ; 255 char command buffer\r
+    prompt                  db   'BOS kernel>', 0\r
+    cmd_buffer: times 255   db   0                    ; 255 char command buffer\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -20,16 +20,15 @@ cmd_buffer: times 255       db   0                        ; 255 char command buffer
 ;  print the prompt for the first time.. :-)   ;\r
 ;----------------------------------------------;\r
 init_cmd:\r
 ;  print the prompt for the first time.. :-)   ;\r
 ;----------------------------------------------;\r
 init_cmd:\r
-         mov     byte [kbd_status], 0                ; reset LEDs to 0..\r
-         call    update_leds\r
+        mov    byte [kbd_status], 0                   ; reset LEDs to 0..\r
+        call   update_leds\r
 \r
 \r
-         mov     esi, prompt\r
-         mov     bl, 0x0E\r
-         call    print\r
+        mov    esi, prompt\r
+        mov    bl, 0x0E\r
+        call   print\r
 \r
 \r
-         mov     edi, cmd_buffer\r
-\r
-         ret\r
+        mov    edi, cmd_buffer\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -37,52 +36,52 @@ init_cmd:
 ;  Main shell function & loop   ;\r
 ;-------------------------------;\r
 shell:\r
 ;  Main shell function & loop   ;\r
 ;-------------------------------;\r
 shell:\r
-         mov     cx, 0                               ; max 254 chars in command\r
-     .loop:                                          ; no. 255 is always a 0\r
+        mov    cx, 0                                  ; max 254 chars in command\r
+    .loop:                                            ; no. 255 is always a 0\r
 \r
 \r
-         push    cx                                  ; better be sure it´s safe..\r
-         push    edi\r
+        push   cx                                     ; better be sure it´s safe..\r
+        push   edi\r
 \r
 \r
-         call    getc                                ; keyboard.inc\r
+        call   getc                                   ; keyboard.inc\r
 \r
 \r
-         pop     edi\r
-         pop     cx\r
+        pop    edi\r
+        pop    cx\r
 \r
 \r
-         cmp     ah, 28                              ; enter\r
-         je      .enter\r
+        cmp    ah, 28                                 ; enter\r
+        je     .enter\r
 \r
 \r
-         cmp     ah, 14                              ; backspace\r
-         je      .backspace\r
+        cmp    ah, 14                                 ; backspace\r
+        je     .backspace\r
 \r
 \r
-         cmp     al, 0                               ; no normal key\r
-         je      .loop                               ; exceptions above..\r
+        cmp    al, 0                                  ; no normal key\r
+        je     .loop                                  ; exceptions above..\r
 \r
 \r
-         cmp     cx, 254\r
-         jae     .loop\r
+        cmp    cx, 254\r
+        jae    .loop\r
 \r
 \r
-         stosb                                       ; store char in buffer\r
-         inc     cx\r
+        stosb                                         ; store char in buffer\r
+        inc    cx\r
 \r
 \r
-         mov     bl, al                              ; print it..\r
-         mov     bh, 0x07\r
-         call    print_char\r
+        mov    bl, al                                 ; print it..\r
+        mov    bh, 0x07\r
+        call   print_char\r
 \r
 \r
-         jmp     .loop\r
+        jmp    .loop\r
 \r
      .enter:\r
 \r
      .enter:\r
-         mov     al, 0                               ; the command buffer is\r
-         stosb                                       ; in ASCIIZ format..\r
-         jmp     chk_cmd\r
+        mov    al, 0                                  ; the command buffer is\r
+        stosb                                         ; in ASCIIZ format..\r
+        jmp    chk_cmd\r
 \r
      .backspace:\r
 \r
      .backspace:\r
-         cmp     cx, 0                               ; can´t delete the prompt.. ;-)\r
-         je      .loop\r
-         dec     edi                                 ; "remove" one char from buffer\r
-         call    backspace                           ; do backspace on screen\r
-         dec     cx                                  ; decrease buffer counter\r
-         jmp     .loop\r
-         jmp     $\r
-         ret\r
+        cmp    cx, 0                                  ; can´t delete the prompt.. ;-)\r
+        je     .loop\r
+        dec    edi                                    ; "remove" one char from buffer\r
+        call   backspace                              ; do backspace on screen\r
+        dec    cx                                     ; decrease buffer counter\r
+        jmp    .loop\r
+        jmp    $\r
+        ret\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -91,100 +90,100 @@ shell:
 ;---------------------------------;\r
 chk_cmd:\r
 \r
 ;---------------------------------;\r
 chk_cmd:\r
 \r
-         mov     esi, commands\r
-         mov     edi, cmd_buffer\r
-         mov     ebp, 0                              ; command-table counter\r
-\r
-     ;------------------------------------------;\r
-     ;   big loop, for each command in table    ;\r
-     ;------------------------------------------;\r
-     .l1:\r
-         mov     ecx, 0                              ; char counter\r
-\r
-         cmp     byte [esi], 0xFF\r
-         je      .no_valid_cmd\r
-\r
-     ;------------------------------------------;\r
-     ;  smaller loop for each char in command   ;\r
-     ;------------------------------------------;\r
-     .l2:\r
-         cmp     byte [edi], ' '                     ; space or zero\r
-         je      .l_chk                              ; both indicate\r
-         cmp     byte [edi], 0                       ; "end of command"\r
-         je      .l_chk\r
-         jmp     .l_cont\r
+        mov    esi, commands\r
+        mov    edi, cmd_buffer\r
+        mov    ebp, 0                                 ; command-table counter\r
+\r
+    ;------------------------------------------;\r
+    ;   big loop, for each command in table    ;\r
+    ;------------------------------------------;\r
+    .l1:\r
+        mov    ecx, 0                                 ; char counter\r
+\r
+        cmp    byte [esi], 0xFF\r
+        je     .no_valid_cmd\r
+\r
+    ;------------------------------------------;\r
+    ;  smaller loop for each char in command   ;\r
+    ;------------------------------------------;\r
+    .l2:\r
+        cmp    byte [edi], ' '                        ; space or zero\r
+        je     .l_chk                                 ; both indicate\r
+        cmp    byte [edi], 0                          ; "end of command"\r
+        je     .l_chk\r
+        jmp    .l_cont\r
 \r
      .l_chk:\r
 \r
      .l_chk:\r
-         cmp     byte [esi], 0                       ; commands are equal, but\r
-         jne     .new_cmd                            ; do not match in size..\r
-         jmp     .done\r
+        cmp    byte [esi], 0                          ; commands are equal, but\r
+        jne    .new_cmd                               ; do not match in size..\r
+        jmp    .done\r
 \r
      .l_cont:\r
 \r
      .l_cont:\r
-         cmp     byte [esi], 0                       ; commands are equal, but\r
-         je      .new_cmd                            ; do not match in size..\r
-\r
-         mov     al, [esi]\r
-         cmp     al, [edi]\r
-         jne     .new_cmd\r
-\r
-         inc     esi\r
-         inc     edi\r
-         inc     ecx                                 ; inc char counter\r
-         jmp     .l2\r
-     ;----------------------;\r
-     ;  end of small loop   ;\r
-     ;----------------------;\r
-\r
-     .new_cmd:\r
-         inc     ebp                                 ; inc command counter\r
-         mov     edi, cmd_buffer                     ; remember to point to the right place.. ;-)\r
-     .l3:\r
-         inc     esi\r
-         cmp     byte [esi], 0                       ; loop until end of command\r
-         jne     .l3\r
-\r
-         inc     esi\r
-         jmp     .l1\r
-     ;----------------------;\r
-     ;   end of big loop    ;\r
-     ;----------------------;\r
-\r
-\r
-\r
-     ;--------------------------;\r
-     ;   done. command found    ;\r
-     ;--------------------------;\r
-     .done:\r
-         cmp     ecx, 0                              ; make sure it´s more\r
-         je      .d_quit                             ; then 0 chars..\r
-\r
-         shl     ebp, 2\r
-         call    dword [ebp+call_table]\r
-\r
-     .d_quit:\r
-         jmp     .cont                               ; then go back to the shell\r
-\r
-\r
-     ;--------------------------;\r
-     ;   command not found      ;\r
-     ;--------------------------;\r
-     .no_valid_cmd:\r
-\r
-         ; call search_current_directory_for_file.... :-)\r
-\r
-         call     no_such_cmd                        ; print error..\r
-         jmp      .cont                              ; then go back to the shell\r
-\r
-     ;---------------------------------;\r
-     ;  make the prompt appear again   ;\r
-     ;---------------------------------;\r
-     .cont:\r
-         call    new_line\r
-         call    new_line\r
-         mov     esi, prompt\r
-         mov     bl, 0x0E\r
-         call    print\r
-         mov     edi, cmd_buffer\r
-         jmp     shell\r
-\r
-         ret\r
+        cmp    byte [esi], 0                          ; commands are equal, but\r
+        je     .new_cmd                               ; do not match in size..\r
+\r
+        mov    al, [esi]\r
+        cmp    al, [edi]\r
+        jne    .new_cmd\r
+\r
+        inc    esi\r
+        inc    edi\r
+        inc    ecx                                    ; inc char counter\r
+        jmp    .l2\r
+    ;----------------------;\r
+    ;  end of small loop   ;\r
+    ;----------------------;\r
+\r
+    .new_cmd:\r
+        inc    ebp                                    ; inc command counter\r
+        mov    edi, cmd_buffer                        ; remember to point to the right place.. ;-)\r
+    .l3:\r
+        inc    esi\r
+        cmp    byte [esi], 0                          ; loop until end of command\r
+        jne    .l3\r
+\r
+        inc    esi\r
+        jmp    .l1\r
+    ;----------------------;\r
+    ;   end of big loop    ;\r
+    ;----------------------;\r
+\r
+\r
+\r
+    ;--------------------------;\r
+    ;   done. command found    ;\r
+    ;--------------------------;\r
+    .done:\r
+        cmp    ecx, 0                                 ; make sure it´s more\r
+        je     .d_quit                                ; then 0 chars..\r
+\r
+        shl    ebp, 2\r
+        call   dword [ebp+call_table]\r
+\r
+    .d_quit:\r
+        jmp    .cont                                  ; then go back to the shell\r
+\r
+\r
+    ;--------------------------;\r
+    ;   command not found      ;\r
+    ;--------------------------;\r
+    .no_valid_cmd:\r
+\r
+        ; call search_current_directory_for_file.... :-)\r
+\r
+        call   no_such_cmd                            ; print error..\r
+        jmp    .cont                                  ; then go back to the shell\r
+\r
+    ;---------------------------------;\r
+    ;  make the prompt appear again   ;\r
+    ;---------------------------------;\r
+    .cont:\r
+        call   new_line\r
+        call   new_line\r
+        mov    esi, prompt\r
+        mov    bl, 0x0E\r
+        call   print\r
+        mov    edi, cmd_buffer\r
+        jmp    shell\r
+\r
+        ret\r