For some reason when I run this code it works perfectly but also causes a segfault after it is done.
global main
extern printf
section .text
main:
push rbp
mov rbp, rsp
mov rcx, format
call printf
mov rax, 0
pop rbp
ret
section .data
format: db "Hello!", 10, 0
I am compiling it using NASM and mingw_w64 GCC
nasm -f win64 main.asm
gcc main.obj -o main.exe
Here is the output I get when I run it in GDB
(gdb) r
Starting program: C:\Users\Admin\Documents\Programming\asm\asm testing\main.exe
[New Thread 18312.0x3938]
[New Thread 18312.0x3550]
Hello!
Thread 1 received signal SIGSEGV, Segmentation fault.
0x00000000006514c0 in ?? ()
(gdb)
I am already following the calling convention defined by Microsoft here.