Browse Source

Avoid multiple memory access in print_proc_time

For nano sec, sec and min printing
Yann Weber 5 years ago
parent
commit
fca12d227a
1 changed files with 18 additions and 21 deletions
  1. 18
    21
      wtfstopw.asm

+ 18
- 21
wtfstopw.asm View File

@@ -285,22 +285,21 @@ proc_print_time:
285 285
 	sub qword [ts_cur.tv_sec], 1
286 286
 	print_time_us_cont:
287 287
 
288
-	; set the nanosec chars (time_res chars) in timestr
289 288
 	xor rdx, rdx
290 289
 	div qword [ts_sleep.tv_nsec] ; Divide result given time_res
291
-	mov rdi, timestr + 6
292
-	mov rsi, rdi ; rsi points on 1st nanosec digit
293
-	add rdi, [time_res] ; rdi points on last nanosec digit
290
+
291
+	; set the nanosec chars (time_res chars) in timestr
292
+	mov rbx, 0x2020202020202020
293
+	mov rcx, [time_res]
294 294
 	mov r8, 10
295
-	print_time_us_loop:
295
+	procpt_loopns:
296 296
 		xor rdx, rdx
297 297
 		div r8
298
-		xchg al, dl
299
-		add al, 0x30
300
-		stosb
301
-		mov al, dl
302
-		cmp rsi, rdi
303
-		loopne print_time_us_loop
298
+		add dl, '0'
299
+		shl rbx, 8
300
+		mov bl, dl
301
+		loop procpt_loopns
302
+	mov [timestr+7], rbx
304 303
 
305 304
 	; filling timestr with seconds & minutes chars
306 305
 	mov rax, [ts_cur.tv_sec]
@@ -311,23 +310,21 @@ proc_print_time:
311 310
 
312 311
 	xor rdx, rdx
313 312
 	div r8
314
-	add dl, 0x30
315
-	mov byte [timestr + 5], dl
316
-
313
+	mov bh, dl
317 314
 	xor dl, dl
318 315
 	div r9
319
-	add dl, 0x30
320
-	mov byte [timestr + 4], dl
316
+	mov bl, dl
317
+	add bx, 0x3030
318
+	mov word [timestr + 4], bx
321 319
 
322 320
 	xor dl, dl
323 321
 	div r8
324
-	add dl, 0x30
325
-	mov byte [timestr + 2], dl
326
-
322
+	mov bh, dl
327 323
 	xor dl, dl
328 324
 	div r9
329
-	add dl, 0x30
330
-	mov byte[timestr + 1], dl
325
+	mov bl, dl
326
+	add bx, 0x3030
327
+	mov word [timestr + 1], bx
331 328
 
332 329
 	; filling the hours buffer
333 330
 	; rcx will contain max_digits - digits_count

Loading…
Cancel
Save