Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

RE: Re: interchanging variables the tough way (BENCHMARK)

by ncw (Friar)
on Aug 30, 2000 at 20:09 UTC ( [id://30322]=note: print w/replies, xml ) Need Help??


in reply to Re: interchanging variables the tough way (BENCHMARK)
in thread interchanging variables the tough way

In ARM assembler the XOR method is actually equal in speed to the temporary variable method, and saves a register, and hence is a standard trick in any ARM programmers macro library. Eg :-
; Swap r0,r1 using r2 as temporary ; Takes 3 cycles traditional MOV r2, r0 ; r2 <- r0 MOV r0, r1 ; r0 <- r1 MOV r1, r2 ; r1 <- r2 ; Swap r0, r1 with no extra register ; Takes 3 cycles xor EOR r0, r0, r1 ; r0 <- r0 ^ r1 EOR r1, r0, r1 ; r1 <- r0 ^ r1 EOR r0, r0, r1 ; r0 <- r0 ^ r1
Apologies for non perl post, but perspective can be useful sometimes ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://30322]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found