%ifndef ZSTRING_INC %define ZSTRING_INC %ifndef SYS_INC %include "sys.inc" %endif %ifndef ALLOC_INC %include "alloc.inc" %endif %macro make_zstring 2-* %1: db %2 %rep %0-2 db %3 %rotate 1 %endrep db 0 %endm section .text length_zstring: ;; rax = zstring address push rbp mov rbp, rsp ;; mov rdx, rax xor rax, rax .loop: mov cl, byte [rdx] cmp cl, 0 je .exit inc rax inc rdx jmp .loop .exit: ;; mov rsp, rbp pop rbp ret print_zstring: ;; rax = zstring address push rbp mov rbp, rsp ;; push rax mov rsi, rax call length_zstring mov rdx, rax mov rax, SYS_WRITE mov rdi, 1 syscall ;; mov rsp, rbp pop rbp ret %endif