section .text global strlen global strcpy global strcat ;----- strlen(char* str) -----; ; return value: amount of characters before EOS was found strlen: push rbp mov rbp, rsp xor rax, rax .findEOS: cmp byte [rdi+rax], 0x0 je .quit inc rax jmp .findEOS .quit: leave ret ;----- strcpy(char* dest, char* src) -----; ; return value: pointer to dest or NULL if nothing was copied strcpy: push rbp mov rbp, rsp xor rax, rax xor rcx, rcx .loop: cmp byte [rsi], 0x0 je .0f mov r10b, byte [rsi] mov byte [rdi], r10b inc rsi inc rdi inc rcx jmp .loop mov byte [rdi], 0x0 .0f: cmp rcx, 0 jne .quit xor rax, rax .quit: leave ret ;----- strcat(char* dest, char* src) -----; ; return value: pointer to dest strcat: push rbp mov rbp, rsp push rdi sub rsp, 8 call strlen add rdi, rax call strcpy add rsp, 8 pop rax leave ret