User Tools

Site Tools


en-us_products:mpino_studio2:box_functions:bit_operations

This is an old revision of the document!


MPINO STUDIO 2 Phase 4-6 · Bitwise Operation Box Functions

These commands apply logic, shift, or rotate operations to the bits in a WORD.

These commands apply logic, shift, or rotate operations to the bits in a WORD.

This ladder screen compares the input forms of WAND, SHL, and ROL.

This ladder screen compares the input forms of WAND, SHL, and ROL.

Box-function inputs and example results

1. Common Rules

Bit-operation commands process all 16 bits in a WORD. A shift discards bits that leave the word and fills with zero; a rotate brings those bits back at the opposite end.

2. WAND, WOR, and WXOR

WAND

Word AND

Applies bitwise AND to two WORD values and stores the result.

Syntax: WAND D0 D1 D2

Run condition Before Command entered Expected result
Left condition ON D0=0x00CC, D1=0x00AA WAND D0 D1 D2 D2=0x0088

WOR

Word OR

Applies bitwise OR to two WORD values and stores the result.

Syntax: WOR D0 D1 D2

Run condition Before Command entered Expected result
Left condition ON D0=0x00CC, D1=0x00AA WOR D0 D1 D2 D2=0x00EE

WXOR

Word XOR

Applies bitwise XOR to two WORD values and stores the result.

Syntax: WXOR D0 D1 D2

Run condition Before Command entered Expected result
Left condition ON D0=0x00CC, D1=0x00AA WXOR D0 D1 D2 D2=0x0066

3. WNOT

Word NOT

Inverts every bit in the source WORD and stores the result.

Syntax: WNOT D0 D1

Arguments

  • 1st = S: source address or constant to invert
  • 2nd = D: result destination address
Run condition Before Command entered Expected result
Left condition ON D0=0x00CC WNOT D0 D1 D1=0xFF33

4. SHL and SHR

SHL

Shift Left

Shifts a WORD left and stores the result. Bits leaving the left are discarded and zeros fill from the right. Use a shift count from 0 to 15.

Syntax: SHL D0 2 D1

Arguments

  • 1st = source: integer WORD address
  • 2nd = shift count: 0 to 15
  • 3rd = destination: result address
Run condition Before Command entered Expected result
Left condition ON D0=0x0003 SHL D0 2 D1 D1=0x000C

SHR

Shift Right

Logically shifts a D WORD right and stores the result. Bits leaving the right are discarded and zeros fill from the left.

Syntax: SHR D0 1 D1

Arguments

  • 1st = source: D WORD address
  • 2nd = shift count: 0 to 15
  • 3rd = destination: result address
Run condition Before Command entered Expected result
Left condition ON D0=0x000C SHR D0 1 D1 D1=0x0006

5. ROL and ROR

ROL

Rotate Left

Rotates a D, C, or T WORD left. Bits leaving the left return at the right end.

Syntax: ROL D0 2 D1

Arguments

  • 1st = source: D, C, or T WORD address
  • 2nd = rotate count
  • 3rd = destination: D, C, or T WORD address
Run condition Before Command entered Expected result
Left condition ON D0=0x8001 ROL D0 2 D1 D1=0x0006

ROR

Rotate Right

Rotates a D, C, or T WORD right. Bits leaving the right return at the left end.

Syntax: ROR D0 1 D1

Arguments

  • 1st = source: D, C, or T WORD address
  • 2nd = rotate count
  • 3rd = destination: D, C, or T WORD address
Run condition Before Command entered Expected result
Left condition ON D0=0x0003 ROR D0 1 D1 D1=0x8001

6. Troubleshooting

Symptom What to check
A sign bit does not fill the left side during a right shift. SHR is a logical shift that fills the upper empty bits with zero.
Bits disappear after a shift. Use ROL or ROR instead of SHL or SHR when the shifted-out bits must be preserved.
en-us_products/mpino_studio2/box_functions/bit_operations.1788947072.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki