Browse Source

Allign proc_print_time loops

Yann Weber 5 years ago
parent
commit
8b427138e0
1 changed files with 14 additions and 12 deletions
  1. 14
    12
      wtfstopw.asm

+ 14
- 12
wtfstopw.asm View File

212
 
212
 
213
 	; Attempt to read from stdin
213
 	; Attempt to read from stdin
214
 	; if something read, enter has been pressed
214
 	; if something read, enter has been pressed
215
-	mov rax, 0
216
-	mov rdi, 0
215
+	xor rax, rax
216
+	xor rdi, rdi
217
 	mov rsi, buf
217
 	mov rsi, buf
218
 	mov rdx, 1
218
 	mov rdx, 1
219
 	syscall
219
 	syscall
220
-	cmp rax, 0
221
-	jge flush_stdin ; flush stdin and exit
220
+	test rax, rax
221
+	jns flush_stdin ; flush & exit
222
 
222
 
223
 	mov rax, 35 ; nanosleep
223
 	mov rax, 35 ; nanosleep
224
 	mov rdi, ts_sleep
224
 	mov rdi, ts_sleep
225
-	mov rsi, 0
225
+	xor rsi, rsi
226
 	syscall
226
 	syscall
227
 
227
 
228
 jmp main_loop ; main_loop
228
 jmp main_loop ; main_loop
289
 	mov rsi, ts_cur
289
 	mov rsi, ts_cur
290
 	syscall ; updating ts_cur time
290
 	syscall ; updating ts_cur time
291
 
291
 
292
+
292
 	mov rsi, ts_start.tv_sec
293
 	mov rsi, ts_start.tv_sec
293
 %define RSIPTR(x) rsi + x - ts_start.tv_sec
294
 %define RSIPTR(x) rsi + x - ts_start.tv_sec
294
 
295
 
295
-	mov rax, [RSIPTR(ts_cur.tv_nsec)] ;mov rax, [ts_cur.tv_nsec]
296
-	sub rax, [RSIPTR(ts_start.tv_nsec)] ;sub rax, [ts_start.tv_nsec]
296
+	mov rax, [ts_cur.tv_nsec] ; allign procpt_loopns
297
+	sub rax, [ts_start.tv_nsec] ; allign procpt_loopns
297
 	jge print_time_us_cont
298
 	jge print_time_us_cont
298
 	add rax, 1000000000 ; negativ result
299
 	add rax, 1000000000 ; negativ result
299
-	sub qword [RSIPTR(ts_cur.tv_sec)], 1 ;sub qword [ts_cur.tv_sec], 1
300
+	sub qword [RSIPTR(ts_cur.tv_sec)], 1
300
 	print_time_us_cont:
301
 	print_time_us_cont:
301
 
302
 
302
 	xor rdx, rdx
303
 	xor rdx, rdx
310
 	mov rcx, [RSIPTR(time_res)]
311
 	mov rcx, [RSIPTR(time_res)]
311
 	mov rdi, 10
312
 	mov rdi, 10
312
 	xor rdx, rdx
313
 	xor rdx, rdx
314
+	align 16 ; should be allready alligned
313
 	procpt_loopns:
315
 	procpt_loopns:
314
-		xor dl, dl
315
 		div rdi
316
 		div rdi
316
 		or dl, 0x30 ; '0'
317
 		or dl, 0x30 ; '0'
317
 		shl rbx, 8
318
 		shl rbx, 8
318
-		mov bl, dl
319
+		xchg bl, dl
319
 		loop procpt_loopns
320
 		loop procpt_loopns
320
 	mov [timestr+7], rbx
321
 	mov [timestr+7], rbx
321
 
322
 
348
 	xor rbx, rbx
349
 	xor rbx, rbx
349
 	mov rcx, HOURSLEN
350
 	mov rcx, HOURSLEN
350
 	mov rdi, 10
351
 	mov rdi, 10
352
+	xor dl, dl
353
+	align 16
351
 	procpt_looph:
354
 	procpt_looph:
352
-		xor dl, dl
353
 		div rdi
355
 		div rdi
354
 		shl rbx, 8
356
 		shl rbx, 8
355
-		mov bl, dl
357
+		xchg bl, dl
356
 		cmp rax, 0
358
 		cmp rax, 0
357
 		loopne procpt_looph
359
 		loopne procpt_looph
358
 	procpt_looph_end:
360
 	procpt_looph_end:

Loading…
Cancel
Save