From aaf7fcac2bc1261e5c6c08eb8faf2e24a58f950f Mon Sep 17 00:00:00 2001 From: Yann Weber Date: Sat, 8 Sep 2018 18:13:10 +0200 Subject: [PATCH] Removed \r from lap messages --- wtfstopw.asm | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/wtfstopw.asm b/wtfstopw.asm index 2937efd..527468a 100644 --- a/wtfstopw.asm +++ b/wtfstopw.asm @@ -101,16 +101,17 @@ section .data badval_msglen: equ $ - badval_msg hours: db "000000000" ; increase size of this string to increase hours max - timestr: db ":00:00.0 ", 0x0a + timestr: db ":00:00.0 ", 0 timestrlen: equ $ - timestr hourslen: equ timestr - hours ; hours len -> the max number of digits time_res: dq 2 ; 2 digits bellow seconds can grow to 8 nl: db 0x0A + cr: db 0xd buf: db 0 - lapsmsg: db 0x0d, "Lap : " + lapsmsg: db "Lap : " lapsmsglen: equ $ - lapsmsg lapcount: db "00000000" @@ -189,8 +190,8 @@ mov [ts_sleep.tv_nsec], rax std ; set DF for string operations main_loop: - push 2 - push 0xD + push 2 ; stderr + push 0xD ; \r call proc_print_time ; Attempt to read from stdin @@ -362,11 +363,11 @@ proc_print_time: cmp rcx, r9 cmovnle rcx, r9 - mov r10, [rsp + 8] + mov r10, [rsp + 8] ; leading chr as 1st argument mov byte [timestr+timestrlen-1], r10b mov rax, 1 ; write - mov rdi, [rsp + 16] + mov rdi, [rsp + 16] ; fd as 2nd argument mov rdx, timestrlen + 9 sub rdx, rcx ; timestr + hours len lea rsi, [hours + rcx] ; hours start pointer @@ -378,10 +379,16 @@ proc_print_time: ; sig handler for SIGINT displaying lap count and time on stdout ; proc_lap_handler: + mov rax, 1 + mov rdi, 2 + mov rsi, cr + mov rdx, 1 + syscall ; \r on stderr + mov rax, 1 mov rdi, 1 mov rsi, lapsmsg - mov rdx, 5 ; "Lap " + mov rdx, 4 ; "Lap " syscall ; increment the lapcount str directly @@ -409,24 +416,22 @@ proc_lap_handler: add r10b, 1 mov [rbx], r10b - mov rax, 1 - mov rdi, 1 + mov rdi, 1 ; stdout mov rdx, [laplen] mov rsi, lapcount add rsi, lapcountlen sub rsi, rdx ; leftmost digit ptr syscall - mov rax, 1 - mov rdi, 1 + mov rax, 1 ; write mov rsi, lapsmsg + 4 mov rdx, 3 ; " : " syscall std ; set DF for string operations - push 1 - push 0xA + push 1 ; stdout + push 0xA ; \n call proc_print_time ret