%include "MY_IO.h" global PRINT_HELLO global DOUBLE_NUMBER global DOUBLE_IN_PLACE global FILL_ARRAY section .data HELLO_STRING db `Hello from Assembly!\n`,0 helloLen equ $ - HELLO_STRING section .text PRINT_HELLO: push rbp mov rbp, rsp mov rdi, HELLO_STRING mov rsi, helloLen call PRINT_STRING pop rbp ret ; rdi holds the number ; return value in rax DOUBLE_NUMBER: mov rax, rdi add rax, rax ret ; rdi holds the address of the number; ; at first I was u sing r8, but crashed on return ; I was over writing memory that was not part of the variable. DOUBLE_IN_PLACE: mov r8d, DWORD [rdi] add r8d, r8d mov DWORD [rdi], r8d ret ; rdi holds the address of the array ; rsi holds the size of the array ; rdx holds the fill value FILL_ARRAY: push rbp mov rbp, rsp push r15 ; lcv push r14 ; offset mov r15, 0 mov r14, 0 .top: cmp r15, rsi je .done mov [rdi+r14], rdx add r14, 4 inc r15 jmp .top .done: pop r14 pop r15 pop rbp ret