|
@@ -187,8 +187,8 @@ setsleep_endloop:
|
187
|
187
|
mov [ts_sleep.tv_nsec], rax
|
188
|
188
|
|
189
|
189
|
main_loop:
|
190
|
|
- push 2 ; stderr
|
191
|
|
- push 0x0D ; \r
|
|
190
|
+ mov rax, 2 ; stderr
|
|
191
|
+ mov rdi, 0xD ; \r
|
192
|
192
|
call proc_print_time
|
193
|
193
|
|
194
|
194
|
; Attempt to read from stdin
|
|
@@ -240,11 +240,8 @@ exit:
|
240
|
240
|
pop rdi ; return code
|
241
|
241
|
syscall
|
242
|
242
|
fault:
|
243
|
|
- mov rax, 1 ; write
|
244
|
243
|
mov rdi, 2 ; stderr
|
245
|
|
- mov rsi, nl
|
246
|
|
- mov rdx, 1
|
247
|
|
- syscall
|
|
244
|
+ call proc_nl
|
248
|
245
|
mov rax, 1
|
249
|
246
|
mov rsi, faultmsg
|
250
|
247
|
mov rdx, faultmsglen
|
|
@@ -254,11 +251,8 @@ fault:
|
254
|
251
|
jmp exit
|
255
|
252
|
|
256
|
253
|
newline_exit:
|
257
|
|
- mov rax, 1
|
258
|
254
|
mov rdi, 1
|
259
|
|
- mov rsi, nl
|
260
|
|
- mov rdx, 1
|
261
|
|
- syscall
|
|
255
|
+ call proc_nl
|
262
|
256
|
|
263
|
257
|
mov rdi, 0 ; exit OK
|
264
|
258
|
jmp exit
|
|
@@ -266,15 +260,12 @@ newline_exit:
|
266
|
260
|
;
|
267
|
261
|
; Print current time on FD and add a leading char CHR
|
268
|
262
|
; push FD & push CHR to set arguments
|
|
263
|
+; rax the FS & rdi the leading CHR
|
269
|
264
|
;
|
270
|
265
|
proc_print_time:
|
271
|
|
- ; push ret addr before arguments
|
272
|
|
- pop r8
|
273
|
|
- pop r9
|
274
|
|
- pop r10
|
275
|
|
- push r8
|
276
|
|
- push r10
|
277
|
|
- push r9
|
|
266
|
+
|
|
267
|
+ push rax
|
|
268
|
+ push rdi
|
278
|
269
|
|
279
|
270
|
; updating ts_cur time
|
280
|
271
|
mov rax, 228 ; clock_gettime
|
|
@@ -284,17 +275,14 @@ proc_print_time:
|
284
|
275
|
|
285
|
276
|
; Calculating elapsed ns
|
286
|
277
|
mov rax, [ts_cur.tv_nsec]
|
287
|
|
- mov rbx, [ts_start.tv_nsec]
|
288
|
|
- sub rax, rbx
|
|
278
|
+ sub rax, [ts_start.tv_nsec]
|
289
|
279
|
cmp rax, 0
|
290
|
280
|
jge print_time_us_cont
|
291
|
281
|
; negativ result
|
292
|
282
|
add rax, 1000000000
|
293
|
|
- mov rbx, [ts_cur.tv_sec]
|
294
|
|
- sub rbx, 1
|
295
|
|
- mov [ts_cur.tv_sec], rbx
|
|
283
|
+ sub qword [ts_cur.tv_sec], 1
|
|
284
|
+
|
296
|
285
|
print_time_us_cont:
|
297
|
|
-
|
298
|
286
|
; Divide result given time_res
|
299
|
287
|
mov r10, rax
|
300
|
288
|
mov rax, 1000000000
|
|
@@ -459,8 +447,8 @@ proc_lap_handler:
|
459
|
447
|
mov rdx, 3 ; " : "
|
460
|
448
|
syscall
|
461
|
449
|
|
462
|
|
- push 1 ; stdout
|
463
|
|
- push 0x0A ; \n
|
|
450
|
+ mov rax, 1 ; stdout
|
|
451
|
+ mov rdi, 0xA ; \n
|
464
|
452
|
call proc_print_time
|
465
|
453
|
|
466
|
454
|
ret
|
|
@@ -550,11 +538,8 @@ arg_strerr:
|
550
|
538
|
call proc_strlen
|
551
|
539
|
mov rax, 1
|
552
|
540
|
syscall
|
553
|
|
- mov rax, 1
|
554
|
|
- mov rsi, nl
|
555
|
|
- mov rdx, 1
|
556
|
|
- syscall
|
557
|
|
- syscall
|
|
541
|
+ call proc_nl
|
|
542
|
+ call proc_nl
|
558
|
543
|
jmp arg_err
|
559
|
544
|
|
560
|
545
|
;
|
|
@@ -600,4 +585,12 @@ proc_strlen:
|
600
|
585
|
mov rdx, r9
|
601
|
586
|
ret
|
602
|
587
|
|
|
588
|
+; with rdi the fd
|
|
589
|
+proc_nl:
|
|
590
|
+ mov rax, 1
|
|
591
|
+ mov rsi, nl
|
|
592
|
+ mov rdx, 1
|
|
593
|
+ syscall
|
|
594
|
+ ret
|
|
595
|
+
|
603
|
596
|
.end:
|