I know that rmmovl can be used in the following way:
rmmovl %ecx, 4(%edx)
But how can I dynamically set the number of bits to move down the stack (4 in this case)? I've tried setting a variable with the value I want to shift to, such as rmmovl %ecx, %edi(%edx)
, but this is not working.
You'll have to manually set %edx to contain the offset. We can save the value of %edx on the stack and restore it afterwards, so its original value is not affected.
pushl %edx # save current value of %edx
addl %edi, %edx # add %edi to %edx
rmmovl %ecx, (%edx) # store value of %ecx into %edx with offset %edi
popl %edx # restore old %edx