section .data msg db "0123456789", 0 aind dd 1,0 indcl dd 1,0 section .text global _start _start: jmp begin index: mov di, ax ; point di to location mov si, [msg] ; point si to string mov cx, 10 ; load length in cx cld ; auto-increment char_loop: lodsb ; load next char in al mov r8,[indcl] inc r8 mov [indcl],r8 cmp r8,[aind] je callpa jmp char_loop callpa: call pa ret pa: mov rax, rsi mov rax, 1 mov rdi, 1 mov rdx, 2 syscall mov rax, 60 mov rdi, 0 syscall begin: call index