News:

  • August 29, 2026, 06:25:41 AM

Login with username, password and session length

Author Topic: Bit masking  (Read 43838 times)

DLTimmons

  • Hero Member
  • *****
  • Posts: 232
Bit masking
« on: March 20, 2013, 02:24:07 PM »
I'm sure it is some place but I can not find a way to move bits into a word. The p-3000 has a pack and unpack function. I searched for any info on bit masking and could not find a thing in the help files.

I'm working on setting up a peerlink between 4 Do-Mores and using MOVER is waste of 15 bits per word.

Donnie

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: Bit masking
« Reply #1 on: March 20, 2013, 02:30:47 PM »
MOVER
Source: C0
Range: 10
Destination: V2000:0

Or

MOVE
Source: C0
Dest: V2000:4
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Bit masking
« Reply #2 on: March 20, 2013, 02:34:35 PM »
There are many ways in Do-more to manipulate/pack/unpack bits in a word. Can you be more specific about what you are trying to do?
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

DLTimmons

  • Hero Member
  • *****
  • Posts: 232
Re: Bit masking
« Reply #3 on: March 20, 2013, 02:43:15 PM »
I would Like to take a group of C bits say C100 thru C115 move them to PL0 then that would be sent out the Peerlink to the other Do-Mores and there move them back to a group of c bit in that Do-More

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: Bit masking
« Reply #4 on: March 20, 2013, 02:52:21 PM »
I would Like to take a group of C bits say C100 thru C115 move them to PL0 then that would be sent out the Peerlink to the other Do-Mores and there move them back to a group of c bit in that Do-More

MOVER
C100
16
PL0:0
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Bit masking
« Reply #5 on: March 20, 2013, 02:57:10 PM »
I would Like to take a group of C bits say C100 thru C115 move them to PL0 then that would be sent out the Peerlink to the other Do-Mores and there move them back to a group of c bit in that Do-More

MOVER
C100
16
PL0:0

Or easier still (and far faster execution-wise), word align them and just assign:

MOVE C96:W PL0

...or create nicknames for the specific bits and use them straight from PL memory:

MyFirstBit PL0:0
MySecondBit PL0:1
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

DLTimmons

  • Hero Member
  • *****
  • Posts: 232
Re: Bit masking
« Reply #6 on: March 20, 2013, 03:08:31 PM »
Thanks

Casting was what I need to find.


DLTimmons

  • Hero Member
  • *****
  • Posts: 232
Re: Bit masking
« Reply #7 on: March 20, 2013, 03:26:36 PM »
Or easier still (and far faster execution-wise), word align them and just assign:

MOVE C96:W PL0

...or create nicknames for the specific bits and use them straight from PL memory:

MyFirstBit PL0:0
MySecondBit PL0:1

What would the inverse of MOVE C96:W PL0 be?

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: Bit masking
« Reply #8 on: March 20, 2013, 03:40:55 PM »
I believe it's
MOVE PL0 C96:W
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

DLTimmons

  • Hero Member
  • *****
  • Posts: 232
Re: Bit masking
« Reply #9 on: March 20, 2013, 03:44:47 PM »
I believe it's
MOVE PL0 C96:W

Looks like it will be  MOVE PL0  C96:SW   If you use just a :W it puts a :SW in the instruction.


franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Bit masking
« Reply #10 on: March 20, 2013, 04:01:33 PM »
For bit transfers, use :UW (Unsigned Word) to ensure no sign extension on anything.  So C96:UW is best.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Bit masking
« Reply #11 on: March 20, 2013, 04:11:41 PM »
Looks like it will be  MOVE PL0  C96:SW   If you use just a :W it puts a :SW in the instruction.

Sorry. When you apply a cast like that and don't provide a format type, it adds the default format for the type. As Franj said, use C96:UW...which aggregates 16 consecutive C bits unto a single unsigned word. As you have probably figured, the 'S' formats as signed integer.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

DLTimmons

  • Hero Member
  • *****
  • Posts: 232
Re: Bit masking
« Reply #12 on: March 20, 2013, 05:30:26 PM »
Thanks

I knew there had to be a way.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Bit masking
« Reply #13 on: March 20, 2013, 09:05:41 PM »
Sorry. When you apply a cast like that and don't provide a format type, it adds the default format for the type. As Franj said, use C96:UW...which aggregates 16 consecutive C bits unto a single unsigned word. As you have probably figured, the 'S' formats as signed integer.

I noticed he asked about C100-C115, but you all are using C96 as your example.  When doing a cast, must whichever is smaller, source or destination, begin on a word boundary? (Presumably it's automatic that the larger one will)
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Bit masking
« Reply #14 on: March 20, 2013, 10:46:52 PM »
I noticed he asked about C100-C115, but you all are using C96 as your example.  When doing a cast, must whichever is smaller, source or destination, begin on a word boundary? (Presumably it's automatic that the larger one will)

A cast isn't a source/destination thing, it is just a re-interpretation of the data at a location. The casting issue here is alignment, and related to how RISC style processors work. When you are doing an extraction cast (bigger to smaller), wrong answers aren't possible, but aggregation casts (smaller to larger) can result in mis-alignments that the processor architecture can't handle. So any time you are aggregating, the data must be aligned on the boundary of the cast size...bytes, words, or dwords. So C96 is a great choice because it is valid for bytes, words, or dwords...and was close to his specified range.

If he genuinely needed to move C100-C115, he could have used the MOVER instruction as plcnut suggested. The advantage of using an aggregation cast is that if the address is arbitrary, as in this case, it is much faster to do a simple MOVE. The MOVER with bits gives you great flexibility, but at the expense of performance. Always trade-offs...
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO