Browse Source

Enhancement in proc_print_time

Better comments and op suppression
Yann Weber 5 years ago
parent
commit
e5d5f69a35
1 changed files with 17 additions and 27 deletions
  1. 17
    27
      wtfstopw.asm

+ 17
- 27
wtfstopw.asm View File

143
 cmp rax, 0
143
 cmp rax, 0
144
 jne fault
144
 jne fault
145
 
145
 
146
-; initializing lapptr
147
-
148
 ; preparing SIGINT catch
146
 ; preparing SIGINT catch
149
 mov rax, proc_lap_handler
147
 mov rax, proc_lap_handler
150
 mov qword [sigaction.sa_handler], rax
148
 mov qword [sigaction.sa_handler], rax
267
 ;
265
 ;
268
 proc_print_time:
266
 proc_print_time:
269
 	
267
 	
270
-	; updating ts_cur time
271
 	mov rax, 228 ; clock_gettime
268
 	mov rax, 228 ; clock_gettime
272
 	mov rdi, 0 ; CLOCK_REALTIME
269
 	mov rdi, 0 ; CLOCK_REALTIME
273
 	mov rsi, ts_cur
270
 	mov rsi, ts_cur
274
-	syscall
271
+	syscall ; updating ts_cur time
275
 
272
 
276
-	; Calculating elapsed ns
277
 	mov rax, [ts_cur.tv_nsec]
273
 	mov rax, [ts_cur.tv_nsec]
278
 	sub rax, [ts_start.tv_nsec]
274
 	sub rax, [ts_start.tv_nsec]
279
-	cmp rax, 0
275
+	cmp rax, 0 ; Calculating elapsed ns
280
 	jge print_time_us_cont
276
 	jge print_time_us_cont
281
-	; negativ result
282
-	add rax, 1000000000
277
+	add rax, 1000000000 ; negativ result
283
 	sub qword [ts_cur.tv_sec], 1
278
 	sub qword [ts_cur.tv_sec], 1
284
-
285
 	print_time_us_cont:
279
 	print_time_us_cont:
286
-	; Divide result given time_res
287
-	xor rdx, rdx
288
-	div qword [ts_sleep.tv_nsec]
289
 
280
 
290
-	; set the nsec char in timestr
281
+	; set the nanosec chars (time_res chars) in timestr
282
+	xor rdx, rdx
283
+	div qword [ts_sleep.tv_nsec] ; Divide result given time_res
291
 	mov rdi, timestr + 6
284
 	mov rdi, timestr + 6
292
-	mov rsi, rdi
293
-	add rdi, [time_res] ; r8 points on last char before \r
285
+	mov rsi, rdi ; rsi points on 1st nanosec digit
286
+	add rdi, [time_res] ; rdi points on last nanosec digit
294
 	mov r8, 10
287
 	mov r8, 10
295
 	print_time_us_loop:
288
 	print_time_us_loop:
296
 		xor rdx, rdx
289
 		xor rdx, rdx
302
 		cmp rsi, rdi
295
 		cmp rsi, rdi
303
 		loopne print_time_us_loop
296
 		loopne print_time_us_loop
304
 
297
 
305
-	; handling seconds, minutes & hours
298
+	; filling timestr with seconds & minutes chars
306
 	mov rax, [ts_cur.tv_sec]
299
 	mov rax, [ts_cur.tv_sec]
307
-	sub rax, [ts_start.tv_sec]
308
-	; rax now contain elapsed seconds
309
-	; filling timestr with seconds & minutes
300
+	sub rax, [ts_start.tv_sec] ; rax now contain elapsed seconds
301
+
302
+	mov r8, 10
303
+	mov r9, 6
310
 
304
 
311
 	xor rdx, rdx
305
 	xor rdx, rdx
312
-	mov rcx, 10
313
-	div rcx
306
+	div r8
314
 	add dl, 0x30
307
 	add dl, 0x30
315
 	mov byte [timestr + 5], dl
308
 	mov byte [timestr + 5], dl
316
 
309
 
317
 	xor dl, dl
310
 	xor dl, dl
318
-	mov rcx, 6
319
-	div rcx
311
+	div r9
320
 	add dl, 0x30
312
 	add dl, 0x30
321
 	mov byte [timestr + 4], dl
313
 	mov byte [timestr + 4], dl
322
 
314
 
323
 	xor dl, dl
315
 	xor dl, dl
324
-	mov rcx, 10
325
-	div rcx
316
+	div r8
326
 	add dl, 0x30
317
 	add dl, 0x30
327
 	mov byte [timestr + 2], dl
318
 	mov byte [timestr + 2], dl
328
 
319
 
329
 	xor dl, dl
320
 	xor dl, dl
330
-	mov rcx, 6
331
-	div rcx
321
+	div r9
332
 	add dl, 0x30
322
 	add dl, 0x30
333
 	mov byte[timestr + 1], dl
323
 	mov byte[timestr + 1], dl
334
 
324
 

Loading…
Cancel
Save