-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrpbrk.asm
47 lines (40 loc) · 1.06 KB
/
strpbrk.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
bits 64
global strpbrk
section .text
check:
mov r10b, byte [rsi]
cmp r10b, 0
je check_failure
cmp byte [rdi], r10b
je check_success
inc rsi
jmp check
check_success:
mov rax, 0
ret
check_failure:
mov rax, 1
ret
strpbrk:
cmp byte [rsi], 0
je failure
cmp byte [rdi], 0
je failure
mov r8, rdi ; Save source
mov r9, rsi ; Save accept ptr
begin:
cmp byte [r8], 0
je failure
mov rdi, r8
mov rsi, r9
call check
cmp rax, 0
je success
inc r8
jmp begin
failure:
xor rax, rax
ret
success:
mov rax, r8
ret