I've noticed that I'm only allowed to do push
on an 8 byte or 2 byte value. For example:
push $5 # same as pushq
# sub $8, %rsp
# movq $5,(%rsp)
Or:
pushw $3
# sub $2, %rsp
# movw $3,(%rsp)
And making sure the stack looks correct with gdb
:
>>> x/5hd $rsp
0x7fffffffe426: 3 5 0 0 0
However, all other suffixes give me:
Error: invalid instruction suffix for `push'
Why does push
only allow using a 64 bit or 16 bit value? Is it common to use the sub...mov
to be more specific, or is that an anti-pattern? Finally, does the CPU interpret push
identical to a sub...mov
instructions, or are they two different things entirely (that produce the same result) ?