You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.6 KiB
83 lines
1.6 KiB
BITS 16 |
|
;CLI |
|
|
|
;Command syntax: <command name> <arg1> |
|
;Argument must not contain spaces. |
|
|
|
; Data |
|
CLI_Command_Buffer times 255 db 0 |
|
CLI_Command_Counter dw 0 |
|
|
|
; API |
|
; args: |
|
; ax: keyboard keycode. |
|
CLI_ASCII_INPUT: |
|
pusha |
|
|
|
; Fetch command buffer offset. |
|
; If there is no room in the buffer, then just bail on the key press. |
|
mov bx, [CLI_Command_Counter] |
|
cmp bx, 255 |
|
je .end |
|
|
|
inc bx ; The new last element will be located at this offset. |
|
mov [CLI_Command_Counter], bx ; Save the new counter. |
|
add bx, CLI_Command_Buffer ; address+offset = destination |
|
|
|
; Move new ascii character into command buffer. |
|
mov [bx], al |
|
|
|
; Print out the input character |
|
mov ah, 0xe ; Teletype output |
|
mov bl, 0x02 ; color (green) |
|
int 0x10 |
|
|
|
.end: |
|
popa |
|
ret |
|
|
|
; args: |
|
CLI_DELETE: |
|
pusha |
|
|
|
; Check if at the beginning of the line. |
|
mov bx, [CLI_Command_Counter] |
|
cmp bx, 0x00 |
|
je .end |
|
|
|
; Move the counter one back |
|
sub bx, 0x01 |
|
mov [CLI_Command_Counter], bx |
|
|
|
;Move NULL into the last character of the line (delete) |
|
mov al, 0x0 |
|
add bx, CLI_Command_Buffer ; address+offset = destination |
|
mov [bx], al |
|
|
|
; Go back one space |
|
mov ax, 0x0e08 ; ah=0x0e means teletype output. al=0x08 means backspace character. |
|
int 0x10 |
|
|
|
; Place a NULL |
|
mov al, 0x0 ; NULL |
|
int 0x10 |
|
|
|
; Go back one space again as the above print of NULL pushes the cursor forward again. |
|
mov ax, 0x0e08 |
|
int 0x10 |
|
|
|
.end: |
|
popa |
|
ret |
|
|
|
; Probably activated with the 'Enter' button. |
|
CLI_CONFIRM_INPUT: |
|
mov bx, 0 |
|
mov [CLI_Command_Counter], bx |
|
mov [CLI_Command_Buffer], bx |
|
ret |
|
|
|
; Executes the command. |
|
CLI_EXECUTE: |
|
ret |
|
|
|
|