extern puts %include "../inc/length_func.inc" section .data text db "42",0 section .text global main main: sub rsp, 8 mov rdi, text call length_func mov r9, rax mov r11, r9 mov r8, text xor r10, r10 xor r11, r11 _loop: mov r10, [r8] cmp r10, 0 jz _exitloop ;if its zero we have reached the end of the string mov r10, [r8] sub r10, 48 ; change "0" into 0 mov [r8], r10 add r8, 1 jmp _loop xor rcx, rcx add rcx, 1 _exitloop: cmp r9, r8 je _addvalues mov r10, r9 mov rax, r10 mul rcx mov r10, rax mov [r9], r10 sub r9, 1 mov rdi, 10 mov rax, rcx mul rdi mov rcx, rax jmp _exitloop add r9, 1 _addvalues: cmp r9, r11 je _end mov r10, [r8] mov r11, [r9] add r11, r10 mov [r9], r11 add r8, 1 add r9, 1 jmp _addvalues ;this returns the r8 pointer ;mov rdi, text ;cld ;call puts ;this is the put s way of printing a string _end: add rsp, 8 ret ; mov rax, 60 ; exit ; mov edi, 1 ; error 1 dont need the exit anymore beacue libc or somthing ; syscall