This is my assembly program which is just a function to swap *x *y.
So first argument from main is address of x which is in 8(%ebp)
and second one is address of y is in 12(%ebp)
.
The program does swap x and y.
I need 7 lines for doing this. can you make it 6 lines
and there is a condition you can use only %eax
, %ecx
, and %edx
3 registers.
I think about it so much, but I can't make it 6 lines. There must be a way, isn't it?
This might be not a big deal, but if there is a way to get it in 6lines I want to know.
movl 8(%ebp), %eax
movl (%eax), %ecx
movl 12(%ebp), %edx
movl (%edx), %eax
movl %ecx, (%edx)
movl 8(%ebp), %ecx
movl %eax, (%ecx)