From 8d7abd99949f402e8707d5ca7f6903a633411aaa Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 21 Jul 2019 10:52:36 -0400 Subject: [PATCH] ed: fix broken buf insert logic --- apps/ed/buf.asm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/ed/buf.asm b/apps/ed/buf.asm index 64cb39d..3ba15ab 100644 --- a/apps/ed/buf.asm +++ b/apps/ed/buf.asm @@ -147,9 +147,12 @@ bufInsertLine: ; when it's time to insert the line in the space we make. ld hl, (BUF_LINECNT) call bufLineAddr + ; HL is pointing to *first byte* after last line. Our source needs to + ; be the second byte of the last line and our dest is the second byte + ; after the last line. push hl \ pop de - dec hl - dec hl + dec hl ; second byte of last line + inc de ; second byte beyond last line ; HL = BUF_LINECNT-1, DE = BUF_LINECNT, BC is set. We're good! lddr ; We still need to increase BUF_LINECNT