ED: Gotten l (list) working, need to work more on d (delete) as there's a bug with deleting lines that are not line 1.

This commit is contained in:
deadvey
2026-03-11 21:16:52 +00:00
parent 88716c0b64
commit 245cfa57f3
8 changed files with 234 additions and 84 deletions

View File

@@ -1,5 +1,6 @@
os_start_cli:
pusha
call os_print_newline
@@ -67,14 +68,14 @@ os_read_cli:
call os_compare_strings
cmp cl, 1
je .ls
; ED
;ED
mov si, user_input
mov di, ed_string
call os_compare_strings
cmp cl, 1
je .ed
jmp .unkown
.unkown:
@@ -85,6 +86,11 @@ os_read_cli:
jmp .finish
.finish:
; Clear the user input
mov al, 0
mov cx, 20
mov di,user_input
repe stosb
popa
call os_start_cli

View File

@@ -171,7 +171,7 @@ disk_clear_output_buffer:
; OUT
; data_buffer: file contents
; TODO use predefined data for calculations
; carry flag: set if failed to load file
; CX = 0 if failed to load
disk_load_file:
pusha
call string_length ; cl = string length
@@ -235,10 +235,11 @@ disk_load_file:
jmp .done_fail
.done_fail:
popa
stc
mov bx, 1
ret
.done:
popa
xor bx,bx
ret
; Write data to file

View File

@@ -28,6 +28,8 @@ keyboard_check_key:
; IN:
; AX = output address
; BX = max length
; OUT:
; BX = 1 if escape is pressed
keyboard_display_input:
pusha
mov di, ax
@@ -55,14 +57,15 @@ keyboard_display_input:
jmp .check_key_pressed
.esc_key:
stc
popa
mov bx, 1
ret
.enter_key:
mov al, 0
stosb
popa
xor bx,bx
ret ; Return to the parent function (whatever that may be)
.backspace:

View File

@@ -106,39 +106,42 @@ string_join:
ret
; ------------------------------------------------------------------------
; TODO
; Converts a string to an integer
; IN: SI = string location (max 5 chars, up to '65536')
; OUT: AX = number
; OUT: AX = number, DX = length of int string
string_cast_to_int:
pusha
push cx
push bx
push dx
xor cx,cx
.loop:
xor ax,ax
lodsb
cmp al, 30h
; Exit if the character is not a number
cmp al,'0'
jl .finish
cmp al, 39h
cmp al,'9'
jg .finish
sub al, 30h
sub al, '0'
mov bx, ax
mov ax, 10
mul cx ; Multiple the current value by 10
add ax, bx ; Then add the new digit
mov cx, ax
jmp .loop
.finish:
mov [int_tmp], cx
popa
mov ax, [int_tmp]
mov ax,cx
pop dx
pop bx
pop cx
ret
; ------------------------------------------------------------------------
; IN: AX = integer (unsigned)
; OUT: AX -> null-terminated string
string_cast_from_int:
pusha
cld ; Write backwards

View File

@@ -55,10 +55,16 @@ text_print_raw:
je .space
cmp al, 0Ah ; When there's an NL or CR, do both, linux encodes files only with NL
je .new_line
cmp al, 09h ; TAB
je .tab
cmp al, 0Dh
je .repeat
int 10h
jmp .repeat
.tab:
mov al, ' '
int 10h
jmp .repeat
.space:
mov al, 20h
int 10h
@@ -68,9 +74,6 @@ text_print_raw:
int 10h
mov al, 0Dh
int 10h
push ax
call os_read_input ; wait until key is pressed until it prints the next line
pop ax
jmp .repeat
.finish:
popa
@@ -132,6 +135,15 @@ os_set_text_mode:
mov dh, 0
mov dl, 0
int 10h
text_newline:
pusha
mov ax,0E0Ah
int 10h
mov al,0Dh
int 10h
popa
ret
popa
ret

View File

@@ -7,7 +7,8 @@ util_cat:
add si, 4 ; Move si to after 'CAT'
call disk_load_file
jc .done ; if file failed to load, just quit
cmp bx, 1
je .done
mov si, file_buffer
mov cx, [file_length]
@@ -36,7 +37,8 @@ util_basic:
; TODO make this more consistent to account for double spaces
;add si, 3 ; Move si to after 'BAS'
call disk_load_file
jc .done
cmp bx, 1
je .done
mov si, file_buffer