aboutsummaryrefslogtreecommitdiff
path: root/semestr-4/ask/lista5/zad2.asm
blob: 7fe4364f313f991cb88db204a6e6cce463103b09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
puzzle2:
        movq    %rdi, %rax      ; rax := rdi
.L3:    movb    (%rax), %r9b    ; r9b := *rax
        leaq    1(%rax), %r8    ; r8  := rax + 1
        movq    %rsi, %rdx    ; rdx := *rsi
.L2:    movb    (%rdx), %cl     ; cl := *rdx
        incq    %rdx            ; rdx++
        testb   %cl, %cl        ; if (cl == 0)
        je      .L4             ; then jump to L4        
        cmpb    %cl, %r9b       ; if (cl != r9b)
        jne     .L2             ; then jump to L2
        movq    %r8, %rax       ; rax := r8
        jmp     .L3             ; jump to L3
.L4     subq    %rdi, %rax      ; rax -= rdi
        ret