Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: DLTimmons on March 20, 2013, 02:24:07 PM

Title: Bit masking
Post by: DLTimmons 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
Title: Re: Bit masking
Post by: plcnut on March 20, 2013, 02:30:47 PM
MOVER
Source: C0
Range: 10
Destination: V2000:0

Or

MOVE
Source: C0
Dest: V2000:4
Title: Re: Bit masking
Post by: BobO 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?
Title: Re: Bit masking
Post by: DLTimmons 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
Title: Re: Bit masking
Post by: plcnut 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
Title: Re: Bit masking
Post by: BobO 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
Title: Re: Bit masking
Post by: DLTimmons on March 20, 2013, 03:08:31 PM
Thanks

Casting was what I need to find.

Title: Re: Bit masking
Post by: DLTimmons 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?
Title: Re: Bit masking
Post by: plcnut on March 20, 2013, 03:40:55 PM
I believe it's
MOVE PL0 C96:W
Title: Re: Bit masking
Post by: DLTimmons 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.

Title: Re: Bit masking
Post by: franji1 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.
Title: Re: Bit masking
Post by: BobO 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.
Title: Re: Bit masking
Post by: DLTimmons on March 20, 2013, 05:30:26 PM
Thanks

I knew there had to be a way.
Title: Re: Bit masking
Post by: Controls Guy 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)
Title: Re: Bit masking
Post by: BobO 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...
Title: Re: Bit masking
Post by: Controls Guy on March 20, 2013, 11:10:55 PM
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.

Of course -- senior moment on my part!  :D  I was mixing thoughts about casting and MOVEing between different size source and destination and wanted to make sure that MOVER didn't need to be word-aligned.  Thanks.
Title: Re: Bit masking
Post by: BobO on March 20, 2013, 11:21:16 PM
Of course -- senior moment on my part!  :D

Dude...I understand that more and more all the time. More and more... ::)
Title: Re: Bit masking
Post by: DLTimmons on March 21, 2013, 09:19:04 AM
BobO

What help me was finnaly finding the help page on casting. In the old gw basic you bit masked to get bit out of a Byte word or double word. It would have helped me to have a link in the help files that routed bit masking to the casting page.

All part of the learing curve, You still have a very powerful processor the more power the larger the learnming curve :)

Senior moment more like senior hour ::)
Title: Re: Bit masking
Post by: BobO on March 21, 2013, 09:34:40 AM
BobO

What help me was finnaly finding the help page on casting. In the old gw basic you bit masked to get bit out of a Byte word or double word. It would have helped me to have a link in the help files that routed bit masking to the casting page.

All part of the learing curve, You still have a very powerful processor the more power the larger the learnming curve :)

Senior moment more like senior hour ::)

Do-more is...um...extensive. ;) There really is a lot here. Often the issue isn't whether it can do something, it's which way is best to do it. Our hope is that the power users can do everything they want to, but that it's also comfortable for the folks who have more basic needs. I think it fits that, but I'm probably too close to it to be a good judge.