This repository has been archived on 2025-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nub-lang-archive-2/src/CLI/Runtime/nub_string.s
nub31 3cb8a5b4c9 ...
2025-06-26 11:50:37 +02:00

33 lines
556 B
ArmAsm

.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