So I'm working on this file. I have to transform complex addressing mode into simple addressing mode.
I've managed to do
movl $0, 0(%esp)
into
addl $0, %esp
movl $0, (%esp)
addl $-0, %esp
works just fine, for all cases.
However I can't do the same thing with
cmpl $4, 28(%esp)
I understand that a compare is not the same as a move. But has anyone an idea how the simple version of the last line would look like? Thx in advance
It's the same logic though:
movl %esp, %eax
addl $28, %eax
cmpl $4, (%eax)
Notice I used eax
as temporary. You could move the stack pointer, but that's bad idea, and also it will mess up the flags when you try to restore it. You would need a temporary anyway, such as:
addl $28, %esp
movl (%esp), %eax
addl $-28, %esp
cmpl $4, %eax
You could of course use lea
as that doesn't modify the flags, but you are apparently forbidden to use complex addressing mode. You can't use pushf
/popf
either, because those need the stack pointer.