29 shiftr% function, 30 rotatel% function – Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual

Page 100

Advertising
background image

7Ć12

places to the left. (Bit 15, or bit 31 if double integer, comes off the

end). The binary places vacated by the shift are filled with zeros.
For example:

LSBITS_0_4% = SHIFTL%(INPUT_CARD%,12) AND 0F000H

In this example, a 16Ćbit value is read from an input module. The

least significant group of 4 bits (bits 0 to 3) are shifted to the left into

the most significant position. The remaining lower bits are masked

off by anding" with hex value 0F000.

7.29

SHIFTR% Function

Format:

SHIFTR%(variable,shift_count)

where:

variable is a single or double integer variable.
shift_count is the number of bit positions to shift the integer

expression (0 to 15 for single integer; 0 to 31 for double integer).

This function returns an integer value equal to the integer expression

that was input, shifted the specific number of binary places to the

right. Bit 0 comes off the end. The result is not sign extended but

treated as a logical shift.
For example:

DECADE_2% = SHIFTR%(INPUT_CARD%,4) AND 0FH

In this example, a 16Ćbit value is read from an input module. The

second group of 4 bits (bits 4 to 7) are shifted to the right into the

least significant position. The remaining upper bits are masked off

by anding" with hex value OF.

7.30

ROTATEL% Function

Format:

ROTATEL%(variable, rotate_count)

where:

variable is a single or double integer variable or expression.
rotate_count is the number of bit positions to rotate the integer

expression (0 to 15 for single integer; 0 to 31 for double integer).

This function returns an integer value, equal to the integer

expression that was input, rotated the specific number of binary

places to the left (Bit 15, or bit 31 if double integer, wraps around to

bit 0).
For example:

MOVE_3_4% = ROTATEL%(INPUT_CARD%,4)

In this example, a 16Ćbit value is read from an input module and bits

(0 to 11) are rotated into the most significant bit positions (4 to 15).

Bits (12 to 15) are rotated into bit positions (0 to 3).

Advertising
This manual is related to the following products: