Download asm/strings.asm from Snapkitty/snapkitty-twin-mars-asm: direct link, hf CLI and curl.
- Browser
- Download file 838 Bytes
-
https://huggingface.co/Snapkitty/snapkitty-twin-mars-asm/resolve/main/asm/strings.asm
- Command line
-
hf download hf://Snapkitty/snapkitty-twin-mars-asm/asm/strings.asm
-
curl -L -o strings.asm https://huggingface.co/Snapkitty/snapkitty-twin-mars-asm/resolve/main/asm/strings.asm
838 Bytes
| ; strings.asm — string primitives: strlen, str_eq, str_copy | |
| "include/syscall.inc" | |
| .text | |
| str_len | |
| str_eq | |
| str_copy | |
| ; size_t str_len(const char *s) | |
| str_len: | |
| xor rax, rax | |
| .loop: | |
| cmp byte [rdi+rax], 0 | |
| je .done | |
| inc rax | |
| jmp .loop | |
| .done: | |
| ret | |
| ; int str_eq(const char *a, const char *b) — returns 1 if equal, 0 if not | |
| str_eq: | |
| push rbx | |
| .loop: | |
| movzx rax, byte [rdi] | |
| movzx rbx, byte [rsi] | |
| cmp rax, rbx | |
| jne .not_eq | |
| test rax, rax | |
| je .equal | |
| inc rdi | |
| inc rsi | |
| jmp .loop | |
| .equal: | |
| mov rax, 1 | |
| pop rbx | |
| ret | |
| .not_eq: | |
| xor rax, rax | |
| pop rbx | |
| ret | |
| ; void str_copy(char *dst, const char *src) | |
| str_copy: | |
| .loop: | |
| movzx rax, byte [rsi] | |
| mov [rdi], al | |
| test rax, rax | |
| je .done | |
| inc rdi | |
| inc rsi | |
| jmp .loop | |
| .done: | |
| ret | |