0
[SOLVED] C ext. asm swap
Hey! I am trying to do a simple swap by passing in variables by reference, it works, however, the end result is wrong. I have done many tests (putting & and * everywhere) (the addresses swap, I have seen) but still no end solution. How can the values be swapped by reference using this method? https://code.sololearn.com/croGtFva8EKY/?ref=app
2 Réponses
+ 2
Dereferencing the pointers first inside asm seems to work
asm("" : "=r" (*a), "=r" (*b) : "1" (*a), "0" (*b));
+ 1
Thanks!
I did it on my computer and it didnt work but whatever, it's solved :)