0xDE5

Trying to solve and expand 0xde5 exercises in assembly (or C)
git clone git://git.mdnr.space/0xDE5
Log | Files | Refs | README | LICENSE

commit 47dda4bad718d9c57da615a6808310b18bf34549
parent bf5aca5f7be55db2518223738a953f2fd7784de1
Author: mehdi-norouzi <mehdeenoroozi@gmail.com>
Date:   Thu, 31 Oct 2024 13:04:11 +0330

wcx64e: fix visual line counter

Diffstat:
M.gitignore | 2+-
Mwcx64/wcx64e.s | 7+++++--
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,4 +1,4 @@ *.elf *.o tags -build +bin diff --git a/wcx64/wcx64e.s b/wcx64/wcx64e.s @@ -24,7 +24,6 @@ .set READBUFLEN, 16384 .set ITOABUFLEN, 12 .set NEWLINE, '\n' -.set CARRIAGE_RETURN, '\r' .set CR, '\r' .set TAB, '\t' .set SPACE, ' ' @@ -210,7 +209,7 @@ count_in_file: cmp $0, %rax # No bytes read? je .L_done_with_file - mov $1, %r14 + mov $1, %r14 # to count visual lines xor %rcx, %rcx .L_next_byte_in_buf: @@ -270,6 +269,10 @@ count_in_file: .L_done_with_file: # Done with this file. The char count is already in r9. # Put the word and line counts in their return locations. + cmp $NEWLINE, %dl + jne .L_dont_decrease + dec %r14 +.L_dont_decrease: mov %r15, %rdx mov %r14, %rax