|
@@ -389,40 +389,29 @@ proc_lap_handler:
|
389
|
389
|
syscall
|
390
|
390
|
|
391
|
391
|
; increment the lapcount str directly
|
392
|
|
- mov rbx, lapcount ; first digit ptr
|
393
|
|
- add rbx, lapcountlen ; rightmost digit ptr
|
394
|
|
- sub rbx, 1
|
395
|
|
- mov r8, 1 ; counter
|
396
|
|
- lap_handler_inc_lap:
|
397
|
|
- mov r10b, [rbx]
|
398
|
|
- cmp r10b, 0x39 ; '9'
|
399
|
|
- jl lap_handler_inc_end
|
400
|
|
-
|
401
|
|
- add r8, 1
|
402
|
|
- cmp r8, [laplen]
|
403
|
|
- jl lap_handler_laplen_noupd
|
404
|
|
- mov [laplen], r8 ; update laplen
|
405
|
|
-
|
406
|
|
- lap_handler_laplen_noupd:
|
407
|
|
- mov byte [rbx], 0x30 ; set current digit to '0'
|
408
|
|
- sub rbx, 1
|
409
|
|
- cmp rbx, lapcount
|
410
|
|
- jl fault
|
411
|
|
- jmp lap_handler_inc_lap
|
412
|
|
- lap_handler_inc_end:
|
413
|
|
- add r10b, 1
|
414
|
|
- mov [rbx], r10b
|
|
392
|
+ mov rcx, lapcountlen - 1; digit counter starting by the right most
|
|
393
|
+ proclap_loop:
|
|
394
|
+ cmp byte [lapcount + rcx], '9'
|
|
395
|
+ jl proclap_loopend
|
|
396
|
+ mov byte [lapcount + rcx], '0' ; set current digit to '0'
|
|
397
|
+ loop proclap_loop
|
|
398
|
+ proclap_loopend:
|
|
399
|
+ add byte [lapcount + rcx], 1 ; increment current digit
|
|
400
|
+
|
|
401
|
+ mov rdx, lapcountlen
|
|
402
|
+ sub rdx, rcx
|
|
403
|
+ cmp rdx, [laplen] ; update laplen if needed
|
|
404
|
+ cmovl rdx, [laplen]
|
|
405
|
+ mov [laplen], rdx
|
|
406
|
+ mov rsi, lapcount + lapcountlen
|
|
407
|
+ sub rsi, rdx
|
415
|
408
|
|
416
|
409
|
mov rax, 1
|
417
|
410
|
mov rdi, 1 ; stdout
|
418
|
|
- mov rdx, [laplen]
|
419
|
|
- mov rsi, lapcount
|
420
|
|
- add rsi, lapcountlen
|
421
|
|
- sub rsi, rdx ; leftmost digit ptr
|
422
|
411
|
syscall
|
423
|
412
|
|
424
|
413
|
mov rax, 1 ; write
|
425
|
|
- mov rsi, lapsmsg + 4
|
|
414
|
+ mov rsi, lapsmsg + 3
|
426
|
415
|
mov rdx, 3 ; " : "
|
427
|
416
|
syscall
|
428
|
417
|
|
|
@@ -555,9 +544,9 @@ usage:
|
555
|
544
|
proc_strlen:
|
556
|
545
|
mov r8, rax
|
557
|
546
|
mov r9, r8
|
558
|
|
- sub r9, 1
|
|
547
|
+ dec r9
|
559
|
548
|
strlen_loop:
|
560
|
|
- add r9, 1
|
|
549
|
+ inc r9
|
561
|
550
|
mov al, [r9]
|
562
|
551
|
cmp al, 0
|
563
|
552
|
jne strlen_loop
|