I went to bed, and realized that my answer is wrong. Exchanging the values in register is completely invisible to the function caller. Here's the correct answer.
void swap(int* a, int* b) { __asm volatile { "LDR R2, [R0] \n" "LDR R3, [R1] \n" "STR R2, [R1] \n" "STR R3, [R0] \n" } }
Further, as R0-R3 are all caller-save registers in the ARM ABI, the function body, excluding the function entry stack shenanigans, uses zero memory.
R0-R3
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I went to bed, and realized that my answer is wrong. Exchanging the values in register is completely invisible to the function caller. Here's the correct answer.
Further, as
R0-R3
are all caller-save registers in the ARM ABI, the function body, excluding the function entry stack shenanigans, uses zero memory.