From: Robert Pengelly <robertapengelly@hotmail.com>
Date: Wed, 18 Sep 2024 23:23:19 +0000 (+0100)
Subject: Overrite/append based on insert key
X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=884b834195437214188a09e3d5cf6313374ca6d3;p=chimaera.git

Overrite/append based on insert key
---

diff --git a/build/chimaera.img b/build/chimaera.img
index ba8e0bf..3a86dda 100644
Binary files a/build/chimaera.img and b/build/chimaera.img differ
diff --git a/build/chimaera.vhd b/build/chimaera.vhd
index d02a78b..9aadad5 100644
Binary files a/build/chimaera.vhd and b/build/chimaera.vhd differ
diff --git a/src/apps/pcomm/cbreak.asm b/src/apps/pcomm/cbreak.asm
index e09ff3a..6ead948 100644
--- a/src/apps/pcomm/cbreak.asm
+++ b/src/apps/pcomm/cbreak.asm
@@ -18,37 +18,6 @@ _cbreak_handler:
     push    ax
     push    bx
     
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    ;; Make sure the extra segment is the same as the code segment.
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    mov     ax,     cs
-    mov     es,     ax
-    
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    ;; Set up di and cx ready to clear the current command.
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    mov     di,     offset _scratch
-    xor     ch,     ch
-    
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    ;; Preserve the di and cx registers.
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    push    di
-    push    cx
-    
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    ;; Zero out al and clear the current command.
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    xor     al,     al
-    rep     movsb
-    
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    ;; Preserve the cx (command length and current offset) and di
-    ;; (current command address) registers.
-    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    pop     cx
-    pop     di
-    
     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     ;; Reset our history index (bp should be unchanged).
     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/src/apps/pcomm/pcomm.asm b/src/apps/pcomm/pcomm.asm
index a229eca..c32bb43 100644
--- a/src/apps/pcomm/pcomm.asm
+++ b/src/apps/pcomm/pcomm.asm
@@ -114,6 +114,9 @@ _main:
     cmp     al,     HEX (50)
     je      .L2
     
+    cmp     al,     HEX (52)
+    je      .L77
+    
     cmp     al,     HEX (53)
     je      .L71
     
@@ -561,6 +564,49 @@ _main:
     cmp     al,     HEX (7F)
     ja      .L11
     
+    cmp     word ptr cs:[_insert],      1
+    jne     .L79
+    
+    push    ax
+    push    bx
+    push    cx
+    push    dx
+    
+    mov     ah,     HEX (02)
+    mov     dl,     al
+    int     HEX (21)
+    
+    stosb
+    mov     bx,     offset _scratch
+    
+    mov     ax,     di
+    sub     ax,     bx
+    
+    mov     cl,     ch
+    xor     ch,     ch
+    
+    cmp     ax,     cx
+    jbe     .L80
+    
+    pop     dx
+    pop     cx
+    pop     bx
+    pop     ax
+    
+    inc     ch
+    jmp     .L11
+
+.L80:
+
+    pop     dx
+    pop     cx
+    pop     bx
+    pop     ax
+    
+    jmp     .L11
+
+.L79:
+
     push    ax
     push    bx
     push    cx
@@ -880,6 +926,36 @@ _main:
     
     jmp     .L11
 
+.L77:
+
+    push    ax
+    push    cx
+    
+    cmp     word ptr cs:[_insert],      1
+    jne     .L78
+    
+    mov     ah,     HEX (01)
+    mov     cx,     HEX (0607)
+    int     HEX (10)
+    
+    mov     word ptr cs:[_insert],      0
+    jmp     .L81
+
+.L78:
+
+    mov     word ptr cs:[_insert],      1
+    
+    mov     ah,     HEX (01)
+    mov     cx,     HEX (0007)
+    int     HEX (10)
+
+.L81:
+
+    pop     cx
+    pop     ax
+    
+    jmp     .L11
+
 .L71:
 
     push    ax
@@ -1743,15 +1819,14 @@ _prompt:
 
     push    ax
     push    bx
-    push    cx
     push    dx
     push    si
-    push    di
     push    es
     push    ds
     
     mov     ax,     cs
     mov     ds,     ax
+    mov     es,     ax
 
 .L17:
 
@@ -1761,6 +1836,8 @@ _prompt:
     mov     cl,     cs:[_scratch_size]
     xor     ch,     ch
     
+    push    cx
+    push    di
     rep     stosb
     
     xor     al,     al
@@ -1811,12 +1888,13 @@ _prompt:
 
 .L18:
 
+    pop     di
+    pop     cx
+    
     pop     ds
     pop     es
-    pop     di
     pop     si
     pop     dx
-    pop     cx
     pop     bx
     pop     ax
     ret
@@ -1856,6 +1934,8 @@ _temp:                          db      257     dup (0)
 _need_ext:                      dw      HEX (0000)
 _dta_addr:                      dw      HEX (0000)
 
+_insert:                        dw      HEX (0000)
+
 global      _vec_history
 _vec_history:                   db      6       dup (0)
 
diff --git a/src/kernel/int23.asm b/src/kernel/int23.asm
index 1af3838..5f1074e 100644
--- a/src/kernel/int23.asm
+++ b/src/kernel/int23.asm
@@ -71,13 +71,13 @@ _regain_control_int23:
 _int23_ign_carry:
 
     pop     ax
-    jnc     _int23_respawn
+    pop     bp
     
+    jnc     _int23_respawn
     xor     ah,     ah
 
 _int23_respawn:
 
-    pop     bp
     jmp     _int21_dispatch
 
 ;******************************************************************************