From: Robert Pengelly Date: Thu, 1 Aug 2024 22:26:07 +0000 (+0100) Subject: Added tab auto-complete X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=bf0d71ea8a2ecdd8b311ec020ce6934629ddac57;p=chimaera.git Added tab auto-complete --- diff --git a/build/chimaera.img b/build/chimaera.img index fbf278f..f8cac9e 100644 Binary files a/build/chimaera.img and b/build/chimaera.img differ diff --git a/build/chimaera.vhd b/build/chimaera.vhd index d3567ff..ca7e583 100644 Binary files a/build/chimaera.vhd and b/build/chimaera.vhd differ diff --git a/src/apps/pcomm/Makefile.unix b/src/apps/pcomm/Makefile.unix index 215b56d..ddb3cc1 100644 --- a/src/apps/pcomm/Makefile.unix +++ b/src/apps/pcomm/Makefile.unix @@ -46,7 +46,7 @@ genver: genver.c gcc -o $@ $^ endif -pcomm.com: ../../lib/crt/crt0.o cbreak.o cd.o crlf.o date.o dir.o erase.o exit.o history.o pcomm.o time.o type.o vector.o writedec.o writestr.o xmalloc.o xstrcpy.o ../../lib/crt/libc.a +pcomm.com: ../../lib/crt/crt0.o cbreak.o cd.o crlf.o date.o dir.o erase.o exit.o history.o pcomm.o time.o type.o vector.o writedec.o writehex.o writestr.o xmalloc.o xstrcpy.o ../../lib/crt/libc.a ../../utils/binutils/slink --oformat msdos -o $@ $^ %.o: %.asm diff --git a/src/apps/pcomm/dir.asm b/src/apps/pcomm/dir.asm index a15c65e..2e4a9d5 100644 --- a/src/apps/pcomm/dir.asm +++ b/src/apps/pcomm/dir.asm @@ -129,7 +129,7 @@ _handler_dir.next: inc ax cmp ax, cs:[_vec_files + 4] - ja _handler_dir.free + ja _handler_dir.cleanup mov word ptr [bp - 6], ax dec ax @@ -153,15 +153,26 @@ _handler_dir.next: call _walk_dir jmp _handler_dir.next -_handler_dir.free: +_handler_dir.cleanup: mov ax, cs:[_dta_addr] push ax call _free add sp, 2 - -_handler_dir.cleanup: + + push dx + push ds + + mov dx, HEX (80) + mov ax, cs + mov ds, ax + + mov ah, HEX (1A) + int HEX (21) + + pop ds + pop dx mov ax, cs:[_vec_files + 0] push ax diff --git a/src/apps/pcomm/pcomm.asm b/src/apps/pcomm/pcomm.asm index f8505d1..e4e3669 100644 --- a/src/apps/pcomm/pcomm.asm +++ b/src/apps/pcomm/pcomm.asm @@ -54,6 +54,36 @@ _main: and al, al jnz .L10 + mov bx, cs:[_dta_addr] + + and bx, bx + jz .L35 + + push bx + + call _free + add sp, 2 + + xor bx, bx + mov cs:[_dta_addr], bx + + push dx + push ds + push ax + + mov dx, HEX (80) + mov ax, cs + mov ds, ax + + mov ah, HEX (1A) + int HEX (21) + + pop ax + pop ds + pop dx + +.L35: + mov ah, HEX (08) int HEX (21) @@ -74,49 +104,315 @@ _main: jne .L14 push ax + push bx + push dx + push si + push cx + push di + + mov di, offset _temp + + mov ax, ' ' + push ax + + mov si, offset _scratch + push si + + call _strrchr + add sp, 4 + + and ax, ax + jz .L50 + + mov si, ax + inc si + +.L50: + + push si + + call _strlen + add sp, 2 + + mov cx, ax + +.L49: + + push cx + push di + + mov cx, 257 + xor al, al + + rep stosb + pop di + pop cx + rep movsb + + mov ax, cs:[_dta_addr] + + and ax, ax + jnz .L46 + + mov ax, 64 + xor dx, dx + + push ax push dx - xor ah, ah - mov al, ch + call _xmalloc + add sp, 4 + + mov cs:[_dta_addr], ax + + push ds + push dx + push ax + + mov ds, ax xor dx, dx - mov cx, 4 - div cx + mov ah, HEX (1A) + int HEX (21) - mov cx, 4 - sub cx, dx + pop ax + pop dx + pop ds + +.L51: + + mov bx, offset _temp - mov al, ' ' - push cx + cmp byte ptr [bx], 0 + jne .L40 + + mov bx, offset _fn_wild + jmp .L38 + +.L40: + + mov al, '*' + stosb + +.L38: + + mov ah, HEX (4E) + xor cx, cx + mov dx, bx + int HEX (21) + jc .L39 + +.L48: + + push es + push si + + mov ax, cs:[_dta_addr] + mov es, ax + + mov si, 30 + mov al, es:[si] + + pop si + pop es + + cmp al, '.' + je .L46 + +.L47: + + mov ax, '\\' + push ax + + mov ax, offset _temp + push ax + + call _strrchr + add sp, 4 + + mov bx, di + pop di + pop cx + + and ax, ax + jnz .L44 + + mov bx, offset _temp + push bx + + call _strlen + add sp, 2 + + mov bx, ax + jmp .L41 + +.L44: + + cmp byte ptr [bx - 1], '*' + jne .L53 + + inc ax + inc ax + + jmp .L52 + +.L53: + + inc ax + +.L52: + + sub bx, ax + +.L41: + + and bx, bx + jz .L42 + + call _handle_backspace + + dec bx + jnz .L41 + +.L42: + + push si + push ds + + mov ax, cs:[_dta_addr] + mov ds, ax + + mov si, 30 .L15: - and cx, cx + lodsb + + and al, al jz .L16 + cmp al, HEX (41) + jb .L45 + + cmp al, HEX (5A) + ja .L45 + + or al, HEX (20) + +.L45: + mov ah, HEX (02) mov dl, al int HEX (21) stosb - dec cx + inc ch jmp .L15 .L16: + pop ds + pop si + + jmp .L37 + +.L46: + + push dx + push ds + push ax + + mov ax, cs:[_dta_addr] + mov ds, ax + xor dx, dx + + mov ah, HEX (1A) + int HEX (21) + pop ax + pop ds pop dx - pop cx - add ch, al + mov ah, HEX (4F) + int HEX (21) + jc .L43 + + jmp .L48 + +.L39: + + mov ax, cs:[_dta_addr] + push ax + + call _free + add sp, 2 + + xor ax, ax + mov cs:[_dta_addr], ax + + push dx + push ds + push ax + + mov dx, HEX (80) + mov ax, cs + mov ds, ax + + mov ah, HEX (1A) + int HEX (21) + + pop ax + pop ds + pop dx + +.L43: + + pop di + pop cx + +.L37: + + pop si + pop dx + pop bx pop ax jmp .L11 .L14: + mov bx, cs:[_dta_addr] + + and bx, bx + jz .L36 + + push bx + + call _free + add sp, 2 + + xor bx, bx + mov cs:[_dta_addr], bx + + push dx + push ds + push ax + + mov dx, HEX (80) + mov ax, cs + mov ds, ax + + mov ah, HEX (1A) + int HEX (21) + + pop ax + pop ds + pop dx + +.L36: + cmp al, HEX (0D) je .L3 @@ -168,7 +464,7 @@ _main: push ax push dx - call _malloc + call _xmalloc add sp, 4 and ax, ax @@ -254,14 +550,14 @@ _main: mov si, bx xor ax, ax - push bx - xor bx, bx - lodsb - or al, al + and al, al jz .L7 + push bx + xor bx, bx + or al, HEX (20) mov bl, al @@ -414,8 +710,7 @@ _main: stosb mov dx, offset _app_path - - add bx, 1 + inc bx mov di, bx mov bx, offset _param_blk @@ -594,11 +889,12 @@ _get_command.done: pop dx pop ax pop si - pop bp add sp, 2 clc + pop bp + and bx, bx jz _get_command.ret @@ -896,7 +1192,11 @@ _err_invalid: db "Bad command or file name - ", HEX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data area. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +_fn_wild: db "*.*", HEX (00) +_temp: db 257 dup (0) + _need_ext: dw HEX (0000) +_dta_addr: dw HEX (0000) global _vec_history _vec_history: db 6 dup (0) diff --git a/src/apps/pcomm/vector.asm b/src/apps/pcomm/vector.asm index 9f89487..3e74644 100644 --- a/src/apps/pcomm/vector.asm +++ b/src/apps/pcomm/vector.asm @@ -44,8 +44,8 @@ _vec_adjust.set: _vec_adjust.alloc: - mov ax, 2 xor dx, dx + mov ax, 2 mul cx @@ -58,6 +58,9 @@ _vec_adjust.alloc: call _realloc add sp, 6 + and ax, ax + jz _vec_adjust.done + mov [bx + 0], ax _vec_adjust.done: @@ -95,7 +98,8 @@ _vec_push.alt: mov ax, [bx + 4] push ax - push word ptr [bp + 4] + mov ax, bx + push ax call _vec_adjust add sp, 4 diff --git a/src/apps/pcomm/xmalloc.asm b/src/apps/pcomm/xmalloc.asm index 5957544..13dd03e 100644 --- a/src/apps/pcomm/xmalloc.asm +++ b/src/apps/pcomm/xmalloc.asm @@ -27,7 +27,6 @@ _xmalloc: and ax, ax jnz _xmalloc.ok - pop ax pop di pop cx pop es @@ -45,18 +44,12 @@ _xmalloc: _xmalloc.ok: push ax - push bx dec ax mov es, ax - xor bx, bx - mov cx, es:[bx + 3] - - pop bx - pop ax - - push ax + mov cx, es:[HEX (0003)] + inc ax mov es, ax _xmalloc.loop: diff --git a/src/apps/pcomm/xstrcpy.asm b/src/apps/pcomm/xstrcpy.asm index 77c9b06..cbe9400 100644 --- a/src/apps/pcomm/xstrcpy.asm +++ b/src/apps/pcomm/xstrcpy.asm @@ -15,6 +15,7 @@ _xstrcpy: mov bp, sp push ax + push cx push si push di @@ -28,13 +29,16 @@ _xstrcpy.loop: or al, al jz _xstrcpy.done - cmp al, 90 + cmp al, HEX (7A) ja _xstrcpy.got_char - cmp al, 65 + cmp al, HEX (61) jb _xstrcpy.got_char - or al, HEX (20) + mov cl, HEX (20) + not cl + + and al, cl _xstrcpy.got_char: @@ -48,6 +52,7 @@ _xstrcpy.done: pop di pop si + pop cx pop ax pop bp ret diff --git a/src/kernel/int21.asm b/src/kernel/int21.asm index bff6bb3..9140701 100644 --- a/src/kernel/int21.asm +++ b/src/kernel/int21.asm @@ -229,9 +229,10 @@ _get_disk_info.got_disk: _get_disk_info.copy: push si + push ds - mov ds, ax xor si, si + mov ds, ax lodsw ;mov cs:[_curr_path], ax @@ -246,12 +247,16 @@ _get_disk_info.copy: mov cs:[_disk_scratch], ax mov di, offset _fat_bpb + push es + mov ax, cs mov es, ax mov cx, 25 rep movsb + pop es + lodsb mov cs:[_drive_no], al @@ -288,6 +293,7 @@ _get_disk_info.copy: lodsw mov cs:[_clustsize], ax + pop ds pop si mov bx, cs:[_root_cluster] @@ -311,8 +317,10 @@ _get_disk_info.fat32: _get_disk_info.done: - mov word ptr cs:[_fat_sector], ax - mov word ptr cs:[_fat_sector + 2], ax + xor ax, ax + + mov cs:[_fat_sector], ax + mov cs:[_fat_sector + 2], ax pop ds pop es @@ -330,8 +338,6 @@ _get_disk_info.done: _get_disk_info.error: - xor ax, ax - pop ds pop es pop di diff --git a/src/lib/crt/stdlib/realloc.asm b/src/lib/crt/stdlib/realloc.asm index 2e43b97..2bb888a 100644 --- a/src/lib/crt/stdlib/realloc.asm +++ b/src/lib/crt/stdlib/realloc.asm @@ -100,11 +100,19 @@ _realloc.alloc: ;; Call int 21h/ah=48 to allocate the blocks. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; push bx - mov bx, si mov ah, HEX (48) + mov bx, si int HEX (21) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Restoer the bx register. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pop bx + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Jump to error if the call fails. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; jc _realloc.error ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;