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

6th Mar 2019, 6:43 PM
Henrik Andersson
Henrik Andersson - avatar
2 odpowiedzi
+ 2
Dereferencing the pointers first inside asm seems to work asm("" : "=r" (*a), "=r" (*b) : "1" (*a), "0" (*b));
6th Mar 2019, 8:14 PM
Dennis
Dennis - avatar
+ 1
Thanks! I did it on my computer and it didnt work but whatever, it's solved :)
6th Mar 2019, 8:17 PM
Henrik Andersson
Henrik Andersson - avatar