Enhancement in proc_print_time

Better comments and op suppression
This commit is contained in:
Yann Weber 2018-09-08 18:25:36 +02:00
commit e5d5f69a35

View file

@ -143,8 +143,6 @@ syscall
cmp rax, 0 cmp rax, 0
jne fault jne fault
; initializing lapptr
; preparing SIGINT catch ; preparing SIGINT catch
mov rax, proc_lap_handler mov rax, proc_lap_handler
mov qword [sigaction.sa_handler], rax mov qword [sigaction.sa_handler], rax
@ -267,30 +265,25 @@ newline_exit:
; ;
proc_print_time: proc_print_time:
; updating ts_cur time
mov rax, 228 ; clock_gettime mov rax, 228 ; clock_gettime
mov rdi, 0 ; CLOCK_REALTIME mov rdi, 0 ; CLOCK_REALTIME
mov rsi, ts_cur mov rsi, ts_cur
syscall syscall ; updating ts_cur time
; Calculating elapsed ns
mov rax, [ts_cur.tv_nsec] mov rax, [ts_cur.tv_nsec]
sub rax, [ts_start.tv_nsec] sub rax, [ts_start.tv_nsec]
cmp rax, 0 cmp rax, 0 ; Calculating elapsed ns
jge print_time_us_cont jge print_time_us_cont
; negativ result add rax, 1000000000 ; negativ result
add rax, 1000000000
sub qword [ts_cur.tv_sec], 1 sub qword [ts_cur.tv_sec], 1
print_time_us_cont: print_time_us_cont:
; Divide result given time_res
xor rdx, rdx
div qword [ts_sleep.tv_nsec]
; set the nsec char in timestr ; set the nanosec chars (time_res chars) in timestr
xor rdx, rdx
div qword [ts_sleep.tv_nsec] ; Divide result given time_res
mov rdi, timestr + 6 mov rdi, timestr + 6
mov rsi, rdi mov rsi, rdi ; rsi points on 1st nanosec digit
add rdi, [time_res] ; r8 points on last char before \r add rdi, [time_res] ; rdi points on last nanosec digit
mov r8, 10 mov r8, 10
print_time_us_loop: print_time_us_loop:
xor rdx, rdx xor rdx, rdx
@ -302,33 +295,30 @@ proc_print_time:
cmp rsi, rdi cmp rsi, rdi
loopne print_time_us_loop loopne print_time_us_loop
; handling seconds, minutes & hours ; filling timestr with seconds & minutes chars
mov rax, [ts_cur.tv_sec] mov rax, [ts_cur.tv_sec]
sub rax, [ts_start.tv_sec] sub rax, [ts_start.tv_sec] ; rax now contain elapsed seconds
; rax now contain elapsed seconds
; filling timestr with seconds & minutes mov r8, 10
mov r9, 6
xor rdx, rdx xor rdx, rdx
mov rcx, 10 div r8
div rcx
add dl, 0x30 add dl, 0x30
mov byte [timestr + 5], dl mov byte [timestr + 5], dl
xor dl, dl xor dl, dl
mov rcx, 6 div r9
div rcx
add dl, 0x30 add dl, 0x30
mov byte [timestr + 4], dl mov byte [timestr + 4], dl
xor dl, dl xor dl, dl
mov rcx, 10 div r8
div rcx
add dl, 0x30 add dl, 0x30
mov byte [timestr + 2], dl mov byte [timestr + 2], dl
xor dl, dl xor dl, dl
mov rcx, 6 div r9
div rcx
add dl, 0x30 add dl, 0x30
mov byte[timestr + 1], dl mov byte[timestr + 1], dl