beautypg.com

Function, Hint, Sample program – Omron SYSMAC CP CP1E-N@@D@-@ User Manual

Page 290: 2 instructions

background image

2 Instructions

2-254

CP1E CPU Unit Instructions Reference Manual(W483)

Function

SWAP(637) switches the position of the two
bytes in all of the words in the range of mem-
ory from R1 to R1+N-1.

Hint

This instruction can be used to reverse the order of ASCII-code characters in each word.

Sample program

When CIO 0.00 is ON in the following example, SWAP(637) switches the data in the leftmost bytes with
the data in the rightmost bytes in each word in the 10-word range from W0 to W9.

N

R1

Byte position is swapped.

SWAP

&10

W0

0

7

8

15

4

1

4 2

4

3

4 4

4

5

4 6

3

0

3 1

0

7

8

15

4 2

4

1

4 4

4

3

4 6

4

5

3 1

3

0

W0

W1

W2

to

W9

W0

W1

W2

to

W9

N

R1

to

to

0.00

This manual is related to the following products: