I have to iterate through the stack to temporary move the values of the words to a register, something like this:
movq ((i - 3)*8)(%rsp), %esi
or
movq %rcx, %rbx # where %rcx is the counter
subq $3, %rbx
movq $8, %rax
mulq %rbx
movq (%rbx)(%rsp), %esi
But obviously, neither of the above works, so how should I change it to make it work?
movl -24(%rsp,%rcx,8),%esi
Please, read the AT&T syntax documentation (and have it around).
Personal bias: while usually I don't mind alternatives, in case of x86 assembly I think the MASM quirk mode should be burnt, and AT&T should be used only by compilers as machine format for further compilation/etc, but not by humans. If you insist on using AT&T, go ahead, but I will consider you being a masochist.
Just to compare, Intel syntax (nasm):
mov esi,[rsp+rcx*8-24]