I tried to follow a very simple example provided by https://cs.lmu.edu/~ray/notes/nasmtutorial/. I intentionally commented below line to ensure that stack is not aligned to 16 bytes boundary as required by x64 calling convention. But still program continues to work. Please can someone answer why calling convention not being honoured, i was expecting some sort of segmentation fault.
; sub rsp, 8 ; must align stack before call
In order to run this program: (Ubuntu 20.04 lts, gcc 9.3.0)
nasm -felf64 echo.asm && gcc echo.o && ./a.out 123ABC
; -----------------------------------------------------------------------------
; A 64-bit program that displays its command line arguments, one per line.
;
; On entry, rdi will contain argc and rsi will contain argv.
; -----------------------------------------------------------------------------
global main
extern puts
section .text
main:
push rdi ; save registers that puts uses
push rsi
; sub rsp, 8 ; must align stack before call
mov rdi, [rsi] ; the argument string to display
call puts WRT ..plt ; print it
; add rsp, 8 ; restore %rsp to pre-aligned value
pop rsi ; restore registers puts used
pop rdi
add rsi, 8 ; point to next argument
dec rdi ; count down
jnz main ; if not done counting keep going
ret