BIT. - Work with Bits

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > BIT. - Work with Bits >

BIT. - Work with Bits

BIT.Store - Set Bit to 1 or 0

Previous Top Next


MiniRobotLanguage (MRL)

 

BIT.Store - Set Bit to 1 or 0

Set Bit to 1 or to 0

 

 

Intention

 

Technically BIT.Store will set or clear a  specified Bit in P1, depending on P3 is 0 or 1.

 

The parameters P1 and P2 can be given as value or as "binary".

The result is in P1. Please see ! Smart Package Robot 's BIT. - Operations

 

VAN.$$LEA=1

VAN.$$P01=(64+16+4)

VAN.$$P02=2

VAN.$$P03=1

VAN.$$P04=$$P01

BIT.Show|v$$P01|$$ERA|$$LEA

BIT.Store|v$$P01|v$$P02|$$P03|$$LEA

BIT.Show|v$$P01|$$ERC|$$LEA

MBX.$$P04 Store $$P02/$$P03 is $$P01$crlf$Bin: $$ERA Store $$P02/$$P03 -> $$ERC

VAN.$$P04=$$P01

VAN.$$P03=0

BIT.Store|v$$P01|v$$P02|$$P03|$$LEA

BIT.Show|v$$P04|$$ERB|$$LEA

BIT.Show|v$$P01|$$ERC|$$LEA

MBX.$$P04 Store $$P02/$$P03 is $$P01$crlf$Bin: $$ERB Store $$P02/$$P03 -> $$ERC

ENR.

 

Bit_Store

 

 

 

Syntax

 

BIT.Store|[b/v]P1|[b/v]P2|P3[|P4]

 

 

 

Parameter Explanation

 

P1 - Variable containing a value or binary number, will also contain the result. For example take the Number "9". It can be an ASC-Code "9" or the numeric number "9".

    You can define this with a prefix of "v" for value and "b" for "binary". If the prefix is omitted, "v" is the default setting for P1.

 

P2 - Variable containing a value or binary number for the bit to get. Depending on P4 this number can be 1 to 8, 1 to 16 or 1 to 32. Unless "b" is prefixed the default type for P2 is "value".

 

P3  - Variable or "0" or "1". P3 will decide whether the Command will "set" or "clear" the specified Bit.

 

P4 - optional, can be 1,2 or 4. Number of Bytes that are used internally. The number of Bits is the number of Bytes times 8.

    1 - 8 Bits

    2 - 16 Bits

    4 - 32 Bits

   

    Do not use the "8" Option. See Limitations below.

 

 

Example

 

'*****************************************************

' EXAMPLE 1:

'*****************************************************

VAN.$$LEA=1

VAN.$$P01=(64+16+4)

VAN.$$P02=2

VAN.$$P03=1

VAN.$$P04=$$P01

BIT.Show|v$$P01|$$ERA|$$LEA

BIT.Store|v$$P01|v$$P02|$$P03|$$LEA

BIT.Show|v$$P01|$$ERC|$$LEA

MBX.$$P04 Store $$P02/$$P03 is $$P01$crlf$Bin: $$ERA Store $$P02/$$P03 -> $$ERC

VAN.$$P04=$$P01

VAN.$$P03=0

BIT.Store|v$$P01|v$$P02|$$P03|$$LEA

BIT.Show|v$$P04|$$ERB|$$LEA

BIT.Show|v$$P01|$$ERC|$$LEA

MBX.$$P04 Store $$P02/$$P03 is $$P01$crlf$Bin: $$ERB Store $$P02/$$P03 -> $$ERC

ENR.

 

 

 

Remarks

-

 

 

Limitations:

 When using the "|8" Parameter, the lower 4 bits are possibly wrong. This is not a bug its due to the way variables are stored internally.

 Therefore we recommend to not use this option.

 

 

See also:

 

•3.5 Hexadezimal, Decimal and Binary and more

•VTH. - Variable to Hexadecimal

•VDC. - Variable Decrement

•CAL. - mathematical CALculation

•VAR. - Variable Set Value/Clear

•VAN. - Variable Numeric

•! Smart Package Robot 's BIT. - Operations

•BIT.16to8 - Split 1 Word into 2 Bytes

•BIT.16to32 - concatenate 2 Words to 32 Bit DWord

•BIT.32to16 - Split 1 DWord into 2 Words

•BIT.8to16 - concatenate 2 Bytes to 16 Bit Word

•BIT.AND - Use logical AND with Bits

•BIT.Clear - Set Bit to 0

•BIT.LShift - Shift Bits to Left, insert 0

•BIT.NOT - Use logical NOT with Bits

•BIT.OR - Use logical OR with Bits

•BIT.RotateLeft - Rotate Bits Left

•BIT.RotateRight - Rotate Bits Right

•BIT.RShift - Shift Bits to Right, insert 0

•BIT.Set - Set Bit to 1

•BIT.Show - Show Bits in Binary-Numbers

•BIT.Store - Set Bit to 1 or 0

•BIT.ToBin - change Parameter to Binary-Format

•BIT.Toggle - Switch Bit

•BIT.ToVal - change Parameter to Value-Format

•BIT.XOR - Use logical XOR with Bits

•BIT.Get - check if Bit is set

•     VDC. - Variable Decrement

•     CAL. - mathematical CALculation

•     VAR. - Variable Set Value/Clear

•     VAN. - Variable Numeric