Introduction

Add to My manuals
704 Pages

advertisement

Introduction | Manualzz

Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7

Bit Field Distribute (BTD)

The BTD instruction copies the specified bits from the Source, shifts the bits to the appropriate position, and writes the bits into the Destination.

This instruction is available in structured text and function block as BTDT, see page 294.

Operands:

Relay Ladder

Operand

Source

Type

SINT

INT

Description

tag that contains the bits to move

DINT

A SINT or INT tag converts to a DINT value by zero-fill.

Source bit DINT immediate number of the bit (lowest bit number) from where to start the move

Destination SINT

(0-31 DINT)

(0-15 INT)

(0-7 SINT) tag must be within the valid range for the Source data type tag where to move the bits

INT

Destination bit

DINT

DINT

Format

immediate tag

Length DINT immediate

(0-31 DINT)

(0-15 INT)

(0-7 SINT) immediate

(1-32) the number of the bit (lowest bit number) where to start copying bits from the Source must be within the valid range for the

Destination data type number of bits to move

Description:

When enabled, the BTD instruction copies a group of bits from the Source to the Destination. The group of bits is identified by the Source bit (lowest bit number of the group) and the Length (number of bits to copy). The

Destination bit identifies the lowest bit number bit to start with in the

Destination. The Source remains unchanged.

If the length of the bit field extends beyond the Destination, the instruction does not save the extra bits. Any extra bits do not wrap to the next word.

If you mix integer data types, the instruction fills the upper bits of the smaller integer data types with 0s so that they are the same size as the largest data type.

Arithmetic Status Flags:

not affected

Publication 1756-RM003K-EN-P - July 2008

Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com

291

Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT)

Fault Conditions:

none

Execution:

Condition

prescan rung-condition-in is false rung-condition-in is true postscan

Relay Ladder Action

The rung-condition-out is set to false.

The rung-condition-out is set to false.

The instruction copies and shifts the Source bits to the Destination.

The rung-condition-out is set to true.

The rung-condition-out is set to false.

Example 1:

When enabled, the BTD instruction moves bits within value_1.

destination bit source bit

value_1

before BTD instruction

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0

value_1

after BTD instruction

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

The shaded boxes show the bits that changed in value_1.

292

Publication 1756-RM003K-EN-P - July 2008

Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com

Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7

Example 2:

When enabled, the BTD instruction moves 10 bits from value_1 to value_2.

source bit

value_1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 destination bit

value_2

before BTD instruction

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

value_2

after BTD instruction

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0

The shaded boxes show the bits that changed in value_2.

Publication 1756-RM003K-EN-P - July 2008

Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com

293

advertisement

Related manuals

advertisement

Table of contents