Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- .global mystrspn
- mystrspn:
- push %ebp
- mov %esp, %ebp
- push %esi
- push %edx
- push %edi
- mov 8(%ebp), %eax
- mov 12(%ebp), %esi
- movl $0, %ebx
- movl $0, %edi
- movzb (%esi), %edx
- movzb (%eax), %ecx
- continue:
- sub %edx, %ecx
- jz equal
- jmp not_equal
- equal:
- incl %edi
- inc %esi
- movzb (%esi), %edx
- test %edx, %edx
- jz max_before_end
- inc %eax
- movzb (%eax), %ecx
- test %ecx, %ecx
- jnz continue
- jmp max_before_end
- not_equal:
- cmp $0, %edi
- jae max
- not_equal_later:
- inc %esi
- movzb (%esi), %edx
- mov 8(%ebp), %eax
- movzb (%eax), %ecx
- test %edx, %edx
- jnz continue
- jmp end
- max:
- cmp %ebx, %edi
- ja need_change
- mov $0, %edi
- jmp not_equal_later
- need_change:
- mov %edi, %ebx
- mov $0, %edi
- jmp not_equal_later
- max_before_end:
- cmp %ebx, %edi
- ja need_change_before_end
- jmp end
- need_change_before_end:
- mov %edi, %ebx
- jmp end
- end:
- mov %ebx, %eax
- pop %edi
- pop %edx
- pop %esi
- movl %ebp, %esp
- popl %ebp
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement