HPlogo System Debug Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 8 System Debug Standard Functions

func bitd

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Bit deposit. Deposits a value into a specified range of bits.

Syntax

   bitd (value position length target)  

Formal Declaration

   bitd:any (value:any position:s16 length:u16 target:any) 

Parameters

value

The value to deposit into the target. Its type is restricted to the INT and PTR classes.

position

This parameter specifies the starting bit position (positive value) or the ending bit position (negative value) of the deposit. Regardless of the size of the target, bit positions are always numbered from left to right. The leftmost bit of the target is bit 0.

length

The number of bits to deposit. This value may not exceed 64.

target

The expression in which to deposit the specified bit pattern. Its type is restricted to the INT and PTR classes.

This function is sensitive to the type of the target parameter. As examples, if a S32 or U32 value is passed, the format of the word (start/end positions) is as follows:

 

                        1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3

    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

   +---------------------------------------------------------------+

   |                                                               |

   +---------------------------------------------------------------+

If a S16 or U16 value is passed, the format of the word (start/end positions) is as follows:

                        1 1 1 1 1 1

    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5

   +-------------------------------+

   |                               |

   +-------------------------------+

Examples

For our example, we use a 32-bit word containing the bit pattern for the hex value 4015381f:

                        1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3

    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

   +---------------------------------------------------------------+

   |0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1 1 1|

   +---------------------------------------------------------------+
   $nmdebug > var xx:u32 4015381f

   $nmdebug > wl bitd(0,#30,2,xx)

   $4015381c

Deposit the value 0 into the last two bits of XX.

   $nmdebug > wl bitd(3,-#1,2,xx)

   $c015381f

Deposit the value 3 (11) into XX, ENDING at bit position 1.

   $nmdebug > wl bitd(2d,-#9,6,xx)

   $4b55381f

Deposit the value 2d (101101) into XX, ending at bit position 9 with a length of 6 (start position would be 4).

Limitations, Restrictions

The value to be deposited is truncated as necessary on the left to fit within the field width of length.

If an extended address target is passed, the deposit location must fall entirely within the 64-bit offset part. Since EADDR types have a total of 96 bits, the valid bit positions are 32 through 95.

Feedback to webmaster