Browse Source

Removed \r from lap messages

Yann Weber 5 years ago
parent
commit
aaf7fcac2b
1 changed files with 18 additions and 13 deletions
  1. 18
    13
      wtfstopw.asm

+ 18
- 13
wtfstopw.asm View File

101
 	badval_msglen: equ $ - badval_msg
101
 	badval_msglen: equ $ - badval_msg
102
 
102
 
103
 	hours: db "000000000" ; increase size of this string to increase hours max
103
 	hours: db "000000000" ; increase size of this string to increase hours max
104
-	timestr: db ":00:00.0           ", 0x0a
104
+	timestr: db ":00:00.0           ", 0
105
 	timestrlen: equ $ - timestr
105
 	timestrlen: equ $ - timestr
106
 	hourslen: equ timestr - hours ; hours len -> the max number of digits
106
 	hourslen: equ timestr - hours ; hours len -> the max number of digits
107
 
107
 
108
 	time_res: dq 2 ; 2 digits bellow seconds can grow to 8
108
 	time_res: dq 2 ; 2 digits bellow seconds can grow to 8
109
 
109
 
110
 	nl: db 0x0A
110
 	nl: db 0x0A
111
+	cr: db 0xd
111
 	buf: db 0
112
 	buf: db 0
112
 
113
 
113
-	lapsmsg: db 0x0d, "Lap : "
114
+	lapsmsg: db "Lap : "
114
 	lapsmsglen: equ $ - lapsmsg
115
 	lapsmsglen: equ $ - lapsmsg
115
 
116
 
116
 	lapcount: db "00000000"
117
 	lapcount: db "00000000"
189
 
190
 
190
 std ; set DF for string operations
191
 std ; set DF for string operations
191
 main_loop:
192
 main_loop:
192
-	push 2
193
-	push 0xD
193
+	push 2 ; stderr
194
+	push 0xD ; \r
194
 	call proc_print_time
195
 	call proc_print_time
195
 
196
 
196
 	; Attempt to read from stdin
197
 	; Attempt to read from stdin
362
 	cmp rcx, r9
363
 	cmp rcx, r9
363
 	cmovnle rcx, r9
364
 	cmovnle rcx, r9
364
 
365
 
365
-	mov r10, [rsp + 8]
366
+	mov r10, [rsp + 8] ; leading chr as 1st argument
366
 	mov byte [timestr+timestrlen-1], r10b
367
 	mov byte [timestr+timestrlen-1], r10b
367
 
368
 
368
 	mov rax, 1 ; write
369
 	mov rax, 1 ; write
369
-	mov rdi, [rsp + 16]
370
+	mov rdi, [rsp + 16] ; fd as 2nd argument
370
 	mov rdx, timestrlen + 9
371
 	mov rdx, timestrlen + 9
371
 	sub rdx, rcx ; timestr + hours len
372
 	sub rdx, rcx ; timestr + hours len
372
 	lea rsi, [hours + rcx] ; hours start pointer
373
 	lea rsi, [hours + rcx] ; hours start pointer
378
 ;	sig handler for SIGINT displaying lap count and time on stdout
379
 ;	sig handler for SIGINT displaying lap count and time on stdout
379
 ;
380
 ;
380
 proc_lap_handler:
381
 proc_lap_handler:
382
+	mov rax, 1
383
+	mov rdi, 2
384
+	mov rsi, cr
385
+	mov rdx, 1
386
+	syscall ; \r on stderr
387
+
381
 	mov rax, 1
388
 	mov rax, 1
382
 	mov rdi, 1
389
 	mov rdi, 1
383
 	mov rsi, lapsmsg
390
 	mov rsi, lapsmsg
384
-	mov rdx, 5 ; "Lap "
391
+	mov rdx, 4 ; "Lap "
385
 	syscall
392
 	syscall
386
 
393
 
387
 	; increment the lapcount str directly
394
 	; increment the lapcount str directly
409
 		add r10b, 1
416
 		add r10b, 1
410
 		mov [rbx], r10b
417
 		mov [rbx], r10b
411
 	
418
 	
412
-
413
 	mov rax, 1
419
 	mov rax, 1
414
-	mov rdi, 1
420
+	mov rdi, 1 ; stdout
415
 	mov rdx, [laplen]
421
 	mov rdx, [laplen]
416
 	mov rsi, lapcount
422
 	mov rsi, lapcount
417
 	add rsi, lapcountlen
423
 	add rsi, lapcountlen
418
 	sub rsi, rdx ; leftmost digit ptr
424
 	sub rsi, rdx ; leftmost digit ptr
419
 	syscall
425
 	syscall
420
 
426
 
421
-	mov rax, 1
422
-	mov rdi, 1
427
+	mov rax, 1 ; write
423
 	mov rsi, lapsmsg + 4
428
 	mov rsi, lapsmsg + 4
424
 	mov rdx, 3 ; " : "
429
 	mov rdx, 3 ; " : "
425
 	syscall
430
 	syscall
426
 
431
 
427
 	std ; set DF for string operations
432
 	std ; set DF for string operations
428
-	push 1
429
-	push 0xA
433
+	push 1 ; stdout
434
+	push 0xA ; \n
430
 	call proc_print_time
435
 	call proc_print_time
431
 
436
 
432
 	ret
437
 	ret

Loading…
Cancel
Save