## -*- asm -*- ## AMD64 assembly word count subroutine. On entry we expect a ## pointer to an ASCIZ NUL-terminated string in RDI, and ## return the return value in RAX, as per standard AMD64 ABI. ## Unfinished; currently it only counts characters. .intel_syntax noprefix .text .globl count_words_asm count_words_asm: xor rax, rax # initialize return value dec rax # to compensate for terminating NUL 1: inc rax movzx esi, byte ptr [rdi] # load byte inc rdi # increment pointer test rsi, rsi # bail out if end of string jne 1b 2: ret .data isalpha: .byte 0 isnonalpha: .byte 0