A puzzle for 2013

here is another fun one:

Move the value in n7:0 to n7:1 and move the value in n7:1 to n7:0 without using any intermediate register.

Example
before
n7:0 = 105
n7:1 = 93

after
n7:0 = 93
n7:1 = 105

Code:
sub n7:0 n7:1 n7:1 // 105 - 93 = 12
sub n7:0 n7:1 n7:0 // 105 - 12 = 93
add n7:0 n7:1 n7:1 // 93 + 12 =105
That was a good one (y)
 
Code:
sub n7:0 n7:1 n7:1 // 105 - 93 = 12
sub n7:0 n7:1 n7:0 // 105 - 12 = 93
add n7:0 n7:1 n7:1 // 93 + 12 =105
That was a good one (y)
Yes, very clever!

A handful of the AD processors have an instruction called SWAP, which allows you to swap data between (consecutive) groups of up to 255 registers. I remember using this instruction to move recipe data around. Handy when you need it. Page 170 in this PDF:

http://www.automationdirect.com/static/manuals/d006userm/ch5.pdf

🍻

-Eric
 
A handful of the AD processors have an instruction called SWAP, which allows you to swap data between (consecutive) groups of up to 255 registers. I remember using this instruction to move recipe data around. Handy when you need it. Page 170 in this PDF:

http://www.automationdirect.com/static/manuals/d006userm/ch5.pdf

🍻

-Eric

Seems like I remember seeing a similar SWAP instruction in the Logix instruction set, but I've never read up on it or used it. If it isn't there, it should be
 
Seems like I remember seeing a similar SWAP instruction in the Logix instruction set, but I've never read up on it or used it. If it isn't there, it should be
I think SWP just does the high/low byte swap... :unsure:

In the AD stuff, that instruction is SWAPB

🍻

-Eric
 
Code:
sub n7:0 n7:1 n7:1 // 105 - 93 = 12
sub n7:0 n7:1 n7:0 // 105 - 12 = 93
add n7:0 n7:1 n7:1 // 93 + 12 =105
That was a good one (y)


🍺
Another way:
XOR N7:0 N7:1 N7:0
XOR N7:0 N7:1 N7:1
XOR N7:0 N7:1 N7:0
(this method won't have any over/under flow problems)
 
Last edited:
🍺
Another way:
XOR N7:0 N7:1 N7:0
XOR N7:0 N7:1 N7:1
XOR N7:0 N7:1 N7:0
(this method won't have any over/under flow problems)

Very nice. A little more counter-intuitive, with different intermediate results, but definitely fool-proof
🍻
 

Similar Topics

Hi I've inherited an IFIX 5.5 application. A picture is enabled every now and then. I beleive its being enabled by a tag that is read from a PLC...
Replies
0
Views
437
I have 15 wires coming from a black box sensor. I can't open it to look within. I know that two of those fifteen wires will comprise the feedback...
Replies
17
Views
7,722
Which wire would you cut, Red or green? Hint: You are color blind :yeah:
Replies
12
Views
4,055
Find 3 palindromic numbers that, when added together, make 85709 (Numbers are in Base 10) Answers by pm please.
Replies
19
Views
6,496
It was too early for Easter, suppose I could have done Chinese New year, but that's too close to Valentines Day. Two parts : 1. A Logix5000...
Replies
1
Views
1,320
Back
Top Bottom