Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 12 of 70

SLC 500 Instruction Set Reference Manual, pages 111 to 120

Pages 111 to 120 of 694

The original document is the PDF (7.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Allen-Bradley 1747-L514

Page 111

Data Handling Instructions

5-15

Entering Parameters Enter the following parameters when programming this instruction. • Source is the program constant or element address. The file indicator (#) is not required for an element address. When using either an SLC 5/03 (OS301 or higher), SLC 5/04 (OS401), or SLC 5/05 processor, floating point and string values are supported. • Destination is the destination starting address of the file you want to fill. You must use the file indicator (#) in the address. When using either an SLC 5/03 (OS301 or higher), SLC 5/04 (OS401), or SLC 5/05 processor, floating point and string values are supported. • Length is the number of elements in the file you want filled. – Maximum length is based on destination file type. If the destination file type is 3 words per element (Timer or Counter), you can specify a maximum length of 42. If the destination file type is 1 word per element, you can specify a maximum length of 128 words.

TIP

TIP

The maximum lengths are based on destination file type.

All elements are filled from the source value (typically a constant) into the specified destination file each scan the rung is true. Elements are filled in ascending order.

The instruction will not write over a file boundary (such as between files N16 and N17) at the destination. An error is declared if a write is attempted over a file boundary.

Publication 1747-RM001G-EN-P - November 2008

Page 112

5-16

Data Handling Instructions

Move and Logical Instructions Overview

The following general information applies to move and logical instructions.

Entering Parameters • Source is the address of the value on which the logical or move operation is to be performed. The source can be a word address or a program constant, unless otherwise described. If the instruction has two source operands, it does not accept program constants in both operands. When using either an SLC 5/03 (OS301 or higher), SLC 5/04 (OS401), or SLC 5/05 processor, floating point and string values are supported. • Destination is the result address of a move or logical operation. It must be a word address.

Using Indexed Word Addresses You have the option of using indexed word addresses for instruction parameters specifying word addresses. Refer to Specifying Indexed Addresses on page E-10 for more information.

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Using Indirect Word Addresses You have the option of using indirect word-level and bit-level addresses for instructions specifying word addresses when using an SLC 5/03 (OS302), SLC 5/04 (OS401), or SLC 5/05 processors. Refer to Specifying an Indirect Address on page E-14 for more information.

Publication 1747-RM001G-EN-P - November 2008

Page 113

Data Handling Instructions

5-17

Updates to the Math Register, S:13 and S:14 Move and logical instructions do not affect the math register.

Entering Mask Values

TIP

When entering constants, you can use ‘b’ or ‘h’ to change the radix of your entry. For example, instead of entering -1 as a constant, you could enter 1111111111111111b or FFFFh.

This output instruction moves the source value to the destination location. As long as the rung remains true, the instruction moves the data each scan.

Move (MOV)

Entering Parameters MOV Move Source Dest

N7:66 0< N7:14 6<

Enter the following parameters when programming this instruction.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

Output Instruction

•

• Source is the address or constant of the data you want to move • Destination is the address where the instruction moves the data

•

TIP

If you wish to move one word of data without affecting the arithmetic bits, use a copy (COP) instruction with a length of 1 word instead of the MOV instruction.

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Publication 1747-RM001G-EN-P - November 2008

Page 114

5-18

Data Handling Instructions

Table 5.7 Controller Function With this Bit

The Controller

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

always resets.

S:0/2

Zero (Z)

sets if result is zero; otherwise resets.

S:0/3

Sign (S)

sets if result is negative (most significant bit is set); otherwise resets.

The MVM instruction is a word instruction that moves data from a source location to a destination, and allows portions of the destination data to be masked by a separate word. As long as the rung remains true, the instruction moves the data each scan.

Masked Move (MVM)

Entering Parameters MVM Masked Move Source N7:68 0< Mask 7FFFh 32767< Dest N7:67 0<

Enter the following parameters when programming this instruction.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

• Source is the address of the data you want to move • Mask is the address of the mask through which the instruction moves data; the mask can also be a hexadecimal value (constant) • Destination is the address where the instruction moves the data

•

Output Instruction

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Table 5.8 Controller Function With this Bit

Publication 1747-RM001G-EN-P - November 2008

The Controller

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

always resets.

S:0/2

Zero (Z)

sets if result is zero; otherwise resets.

S:0/3

Sign (S)

sets if result is negative; otherwise resets.

Page 115

Data Handling Instructions

5-19

Operation When the rung containing this instruction is true, data at the source address passes through the mask to the destination address. See the figure below.

MVM MASKED MOVE Source

B3:0

Mask

F0F0

Dest

B3:2

B3:2 before move 1111111111111111 source B3:0 0101010101010101 Mask F0F0 1111000011110000 B3:2 after move 0101111101011111

Mask data by resetting bits in the mask; pass data by setting bits in the mask to one. The bits of the mask can be fixed by a constant value, or you can vary them by assigning the mask a direct address.

TIP

Bits in the destination that correspond to zeros in the mask are not altered.

Publication 1747-RM001G-EN-P - November 2008

Page 116

5-20

Data Handling Instructions

This instruction performs a bit-by-bit logical AND. The operation is performed using the value at source A and the value at source B. The result is stored in the destination.

And (AND)

AND Bitwise AND Source A Source B Dest

Table 5.9 Truth Table for A AND B = Dest

B3:1 C0E0h< 255 255< B3:1 C0E0h<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

A

B

Dest

0

0

0

1

0

0

0

1

0

1

1

1

•

Output Instruction

Source A and B can either be a word address or a constant; however, both sources cannot be a constant. The destination must be a word address.

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Table 5.10 Controller Function With this Bit

Publication 1747-RM001G-EN-P - November 2008

The Controller

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

always resets.

S:0/2

Zero (Z)

sets if result is zero; otherwise resets.

S:0/3

Sign (S)

sets if most significant bit is set; otherwise resets.

Page 117

Data Handling Instructions

5-21

Or (OR) This instruction performs a bit-by-bit logical OR. The operation is performed using the value at source A and the value at source B. The result is stored in the destination.

OR Bitwise Inclusive OR Source A B3:2 16C8h< Source B B3:3 EF0Ch< Dest B3:4 FFCCh<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

Output Instruction

•

•

Table 5.11 Truth Table for A OR B = Dest A

B

Dest

0

0

0

1

0

1

0

1

1

1

1

1

Source A and B can either be a word address or a constant; however, both sources cannot be a constant. The destination must be a word address.

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Table 5.12 Controller Function With this Bit

The Controller

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

always resets.

S:0/2

Zero (Z)

sets if result is zero; otherwise resets.

S:0/3

Sign (S)

sets if result is negative (most significant bit is set) otherwise resets.

Publication 1747-RM001G-EN-P - November 2008

Page 118

5-22

Data Handling Instructions

This instruction performs a bit-by-bit logical XOR. The operation is performed using the value at source A and the value at source B. The result is stored in the destination.

Exclusive Or (XOR)

XOR Bitwise Exclusive OR Source A B3:2 16C8h< Source B B3:3 EF0Ch< Dest B3:5 F9C4h<

Table 5.13 Truth Table for A XOR B = Dest

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

•

Output Instruction

A

B

Dest

0

0

0

1

0

1

0

1

1

1

1

0

Source A and B can either be a word address or a constant; however, both sources cannot be a constant. The destination must be a word address.

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Table 5.14 Controller Function With this Bit

Publication 1747-RM001G-EN-P - November 2008

The Controller

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

always resets.

S:0/2

Zero (Z)

sets if result is zero; otherwise resets

S:0/3

Sign (S)

sets if result is negative (most significant bit is set); otherwise resets.

Page 119

Data Handling Instructions

This instruction performs a bit-by-bit logical NOT. The operation is performed using the value at source A. The result (one’s complement of A) is stored in the destination.

Not (NOT)

NOT NOT Source B3:2 0001011011001000< Dest B3:6 1110100100110111<

Table 5.15 Truth Table for A Not = Dest

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

5-23

•

•

•

•

A

Dest

0

1

1

0

The source and destination must be word addresses.

Output Instruction

Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0 to 3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Table 5.16 Controller Function With this Bit

The Controller

S:0/0

Carry (C)

always resets.

S:0/1

Overflow (V)

always resets.

S:0/2

Zero (Z)

sets if result is zero; otherwise resets.

S:0/3

Sign (S)

sets if result is negative (most significant bit is set); otherwise resets.

Publication 1747-RM001G-EN-P - November 2008

Page 120

5-24

Data Handling Instructions

Use the NEG instruction to change the sign of the source and then place it in the destination. The destination contains the two’s complement of the source. For example, if the source is 5, the destination would be -5.

Negate (NEG)

The source and destination must be word addresses. NEG Negate Source B3:2 0001011011001000< Dest B3:7 1110100100111000<

Updates to Arithmetic Status Bits

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

•

•

•

The arithmetic status bits are found in Word 0, bits 0 to 3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated.

Output Instruction

Table 5.17 Controller Function With this Bit

Publication 1747-RM001G-EN-P - November 2008

The Controller

S:0/0

Carry (C)

clears if 0 or overflow, otherwise sets.

S:0/1

Overflow (V)

sets if overflow, otherwise reset. Overflow occurs only if -32,768 is the source. On overflow, the minor error flag is also set. The value 32,767 is placed in the destination. If S:2/14 is set, then the unsigned, truncated overflow remains in the destination. For floating point destinations, the overflow result remains in the destination.

S:0/2

Zero (Z)

sets if result is zero; otherwise resets.

S:0/3

Sign (S)

sets if result is negative; otherwise resets.