I'm a little confused for how to pass things to the stack when calling a function, I have the following assembly:
.data
str:
.asciz "%d %d %d %d %d %d %d %d %d %d\n"
.text
__entry:
pushq %rbp
movq %rsp, %rbp
leaq str(%rip), %rdi
movq $1, %rsi
movq $2, %rdx
movq $3, %rcx
movq $4, %r8
movq $5, %r9
movq $6, -4(%rbp)
movq $8, -8(%rbp)
movq $9, -12(%rbp)
movq $10, -16(%rbp)
call _printf
popq %rbp
ret
.global _main
_main:
pushq %rbp
movq %rsp, %rbp
call __entry
popq %rbp
ret
But when I run the program I get a load of junk values. The values passed in the registers are fine, but the ones passed in the stack are not. I checked the call convention and it says that "additional arguments are passed on the stack.", and that they should be "aligned to a 16 byte boundary".
Two questions:
- What am I doing wrong here w/r/t passing my values to the stack?
and:
- What does it mean by "aligned to a 16 byte boundary"?