Enhancement in proc_print_time
Better comments and op suppression
This commit is contained in:
parent
aaf7fcac2b
commit
e5d5f69a35
1 changed files with 17 additions and 27 deletions
44
wtfstopw.asm
44
wtfstopw.asm
|
|
@ -143,8 +143,6 @@ syscall
|
|||
cmp rax, 0
|
||||
jne fault
|
||||
|
||||
; initializing lapptr
|
||||
|
||||
; preparing SIGINT catch
|
||||
mov rax, proc_lap_handler
|
||||
mov qword [sigaction.sa_handler], rax
|
||||
|
|
@ -267,30 +265,25 @@ newline_exit:
|
|||
;
|
||||
proc_print_time:
|
||||
|
||||
; updating ts_cur time
|
||||
mov rax, 228 ; clock_gettime
|
||||
mov rdi, 0 ; CLOCK_REALTIME
|
||||
mov rsi, ts_cur
|
||||
syscall
|
||||
syscall ; updating ts_cur time
|
||||
|
||||
; Calculating elapsed ns
|
||||
mov rax, [ts_cur.tv_nsec]
|
||||
sub rax, [ts_start.tv_nsec]
|
||||
cmp rax, 0
|
||||
cmp rax, 0 ; Calculating elapsed ns
|
||||
jge print_time_us_cont
|
||||
; negativ result
|
||||
add rax, 1000000000
|
||||
add rax, 1000000000 ; negativ result
|
||||
sub qword [ts_cur.tv_sec], 1
|
||||
|
||||
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 rsi, rdi
|
||||
add rdi, [time_res] ; r8 points on last char before \r
|
||||
mov rsi, rdi ; rsi points on 1st nanosec digit
|
||||
add rdi, [time_res] ; rdi points on last nanosec digit
|
||||
mov r8, 10
|
||||
print_time_us_loop:
|
||||
xor rdx, rdx
|
||||
|
|
@ -302,33 +295,30 @@ proc_print_time:
|
|||
cmp rsi, rdi
|
||||
loopne print_time_us_loop
|
||||
|
||||
; handling seconds, minutes & hours
|
||||
; filling timestr with seconds & minutes chars
|
||||
mov rax, [ts_cur.tv_sec]
|
||||
sub rax, [ts_start.tv_sec]
|
||||
; rax now contain elapsed seconds
|
||||
; filling timestr with seconds & minutes
|
||||
sub rax, [ts_start.tv_sec] ; rax now contain elapsed seconds
|
||||
|
||||
mov r8, 10
|
||||
mov r9, 6
|
||||
|
||||
xor rdx, rdx
|
||||
mov rcx, 10
|
||||
div rcx
|
||||
div r8
|
||||
add dl, 0x30
|
||||
mov byte [timestr + 5], dl
|
||||
|
||||
xor dl, dl
|
||||
mov rcx, 6
|
||||
div rcx
|
||||
div r9
|
||||
add dl, 0x30
|
||||
mov byte [timestr + 4], dl
|
||||
|
||||
xor dl, dl
|
||||
mov rcx, 10
|
||||
div rcx
|
||||
div r8
|
||||
add dl, 0x30
|
||||
mov byte [timestr + 2], dl
|
||||
|
||||
xor dl, dl
|
||||
mov rcx, 6
|
||||
div rcx
|
||||
div r9
|
||||
add dl, 0x30
|
||||
mov byte[timestr + 1], dl
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue