DEV Community

Discussion on: How can you swap two variables without using a third?

Collapse
 
lexlohr profile image
Alex Lohr

Basically, it works like this (x64 assembler):

mov rax, [m64]
ror rax, 32
mov [m64], rax

Thread Thread
 
amexboy profile image
Amanu

No, I mean on a high level programming language which you have no idea where is stored.

Even for an assembly, the two variables could potentially be stored in two different registers. But we're going to assume not!

Cool idea anyways