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
 	sub qword [ts_cur.tv_sec], 1
285
 	sub qword [ts_cur.tv_sec], 1
286
 	print_time_us_cont:
286
 	print_time_us_cont:
287
 
287
 
288
-	; set the nanosec chars (time_res chars) in timestr
289
 	xor rdx, rdx
288
 	xor rdx, rdx
290
 	div qword [ts_sleep.tv_nsec] ; Divide result given time_res
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
 	mov r8, 10
294
 	mov r8, 10
295
-	print_time_us_loop:
295
+	procpt_loopns:
296
 		xor rdx, rdx
296
 		xor rdx, rdx
297
 		div r8
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
 	; filling timestr with seconds & minutes chars
304
 	; filling timestr with seconds & minutes chars
306
 	mov rax, [ts_cur.tv_sec]
305
 	mov rax, [ts_cur.tv_sec]
311
 
310
 
312
 	xor rdx, rdx
311
 	xor rdx, rdx
313
 	div r8
312
 	div r8
314
-	add dl, 0x30
315
-	mov byte [timestr + 5], dl
316
-
313
+	mov bh, dl
317
 	xor dl, dl
314
 	xor dl, dl
318
 	div r9
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
 	xor dl, dl
320
 	xor dl, dl
323
 	div r8
321
 	div r8
324
-	add dl, 0x30
325
-	mov byte [timestr + 2], dl
326
-
322
+	mov bh, dl
327
 	xor dl, dl
323
 	xor dl, dl
328
 	div r9
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
 	; filling the hours buffer
329
 	; filling the hours buffer
333
 	; rcx will contain max_digits - digits_count
330
 	; rcx will contain max_digits - digits_count

Loading…
Cancel
Save