aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorturret <turret@duck.com>2023-09-13 13:28:25 +0000
committerturret <turret@duck.com>2023-09-13 13:28:25 +0000
commitc7ac1461c721877d73a91400e4de231a9ffaaf8e (patch)
tree172b44fa9facd081cf60019421cf3d3f391940ba
parent865f913eb14a358bb44b93eb54a46edad6c1950d (diff)
downloadcat-c7ac1461c721877d73a91400e4de231a9ffaaf8e.tar.gz
cat-c7ac1461c721877d73a91400e4de231a9ffaaf8e.tar.bz2
cat-c7ac1461c721877d73a91400e4de231a9ffaaf8e.zip
bug fixes, changes, typo fixes, and still unfinished
-rw-r--r--cat.s27
1 files changed, 20 insertions, 7 deletions
diff --git a/cat.s b/cat.s
index e9bb318..37ade09 100644
--- a/cat.s
+++ b/cat.s
@@ -19,12 +19,12 @@ process_fd:
mov r9, buf ; write pointer
mov r10, buf ; read pointer
.loop:
+ mov rcx, [r10]
+ and rcx, 0xff
; SHOWENDS
mov r11, r13
and r11, showends
cmp r11, 1
- mov rcx, [r10]
- and rcx, 0xff
jl .skipshowends
cmp rcx, 0x0a
jne .skipshowends
@@ -46,18 +46,20 @@ process_fd:
.docaret:
cmp rcx, 127
jge .showendsm
+ ;cmp rcx, [r10]
+ ;jne .endsmflushandcont
cmp rcx, 0x20
jge .skipnonprinting
; carrot notation (less than 0x20)
- xor rcx, 0x40
+ cmp r9, r10
+ je .skipnonprinting
+ or rcx, 0x40
ror rcx, 8
or rcx, "^"
and rcx, 0xffff
mov [smallbuf], rcx
mov rax, smallbuf
call outpstring
- cmp r9, r10
- je .skipnonprinting
dec r9
call .flushbuf
inc r10
@@ -69,14 +71,24 @@ process_fd:
je .eq127
xor rdi, rdi
or rdi, "M-"
- and rcx, 0xffff
+ and rdi, 0xffff
mov [smallbuf], rdi
mov rax, smallbuf
call outpstring
mov rcx, [r10]
and rcx, 0xff
- sub rcx, 128
+ sub rcx, rax
jmp .docaret
+.endsmflushandcont:
+ mov [smallbuf], rcx
+ mov rax, smallbuf
+ call outpstring
+ dec r9
+ call .flushbuf
+ inc r10
+ inc r9
+ dec r8
+ jmp .skipnonprinting
.eq127:
xor rcx, rcx
mov rcx, "^?"
@@ -89,6 +101,7 @@ process_fd:
inc r10
cmp r8, 0
jl .contrwloop
+ call .flushbuf
jmp .loop
.flushbuf: