.intel_syntax noprefix .text .globl nub_string_length # func nub_string_length(string: string): u64 nub_string_length: mov rsi, [rdi] # Length of string in bytes add rdi, 8 # Start of bytes xor rax, rax # Character count xor rdx, rdx # Current byte position test rsi, rsi jz _done _count_loop: cmp rdx, rsi jge _done mov dl, [rdi + rdx] and dl, 0b11000000 cmp dl, 0b10000000 je _skip_byte inc rax _skip_byte: inc rdx jmp _count_loop _done: ret