Addresses of 2 integer variables are on the stack as the parameters.
Sample c call: swap( &num1, &num2);
You must implement the following C swap function:
Swaps the two values pointed to by x_ptr and y_ptr.
void swap (int *x_ptr, int *y_ptr)
if (x_ptr != y_ptr)
*x_ptr ^= *y_ptr; /* note that ^ means xor */
*y_ptr ^= *x_ptr;
*x_ptr ^= *y_ptr;
The values of the two integer parameters have been exchanged.
I'm fairly new to Assembly myself, is there a reason something like this wouldn't work?
xchg eax, ebx ; swap Value1 and Value2
That exchanges the two integers in the registers all right, but doesn't save the values in the memory addresses of the two pointers. The results still have to be saved at those addresses. But that xchg instruction isn't needed for the simple swap in this program -- wasted CPU time.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...