PackBitsToDword (FUN) ¶ FUNCTION PackBitsToDword : DWORD Function packs 32 Bits “xBit0” .. “xBit31” into a DWORD. Example: PackBitsToDword ( FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , TRUE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE , FALSE ) = 16#01020304 InOut: Scope Name Type Comment Return PackBitsToDword DWORD function returns the DWORD defined by the BOOL inputs Input xBit31 BOOL Bit 31 of the Dword xBit30 BOOL Bit 30 of the Dword xBit29 BOOL Bit 29 of the Dword xBit28 BOOL Bit 28 of the Dword xBit27 BOOL Bit 27 of the Dword xBit26 BOOL Bit 26 of the Dword xBit25 BOOL Bit 25 of the Dword xBit24 BOOL Bit 24 of the Dword xBit23 BOOL Bit 23 of the Dword xBit22 BOOL Bit 22 of the Dword xBit21 BOOL Bit 21 of the Dword xBit20 BOOL Bit 20 of the Dword xBit19 BOOL Bit 19 of the Dword xBit18 BOOL Bit 18 of the Dword xBit17 BOOL Bit 17 of the Dword xBit16 BOOL Bit 16 of the Dword xBit15 BOOL Bit 15 of the Dword xBit14 BOOL Bit 14 of the Dword xBit13 BOOL Bit 13 of the Dword xBit12 BOOL Bit 12 of the Dword xBit11 BOOL Bit 11 of the Dword xBit10 BOOL Bit 10 of the Dword xBit9 BOOL Bit 9 of the Dword xBit8 BOOL Bit 8 of the Dword xBit7 BOOL Bit 7 of the Dword xBit6 BOOL Bit 6 of the Dword xBit5 BOOL Bit 5 of the Dword xBit4 BOOL Bit 4 of the Dword xBit3 BOOL Bit 3 of the Dword xBit2 BOOL Bit 2 of the Dword xBit1 BOOL Bit 1 of the Dword xBit0 BOOL Bit 0 of the Dword
PackBitsToWord (FUN) ¶ FUNCTION PackBitsToWord : WORD Function packs 16 Bits “xBit0” .. “xBit15” into a WORD. Example: PackBitsToWord ( FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE ) = 16#0102 InOut: Scope Name Type Comment Return PackBitsToWord WORD function returns the WORD defined by the BOOL inputs Input xBit15 BOOL Bit 15 of the Word xBit14 BOOL Bit 14 of the Word xBit13 BOOL Bit 13 of the Word xBit12 BOOL Bit 12 of the Word xBit11 BOOL Bit 11 of the Word xBit10 BOOL Bit 10 of the Word xBit9 BOOL Bit 9 of the Word xBit8 BOOL Bit 8 of the Word xBit7 BOOL Bit 7 of the Word xBit6 BOOL Bit 6 of the Word xBit5 BOOL Bit 5 of the Word xBit4 BOOL Bit 4 of the Word xBit3 BOOL Bit 3 of the Word xBit2 BOOL Bit 2 of the Word xBit1 BOOL Bit 1 of the Word xBit0 BOOL Bit 0 of the Word
PackBytesToDword (FUN) ¶ FUNCTION PackBytesToDword : DWORD Function pack four BYTEs into a DWORD. Example: MEM.PackBytesToDword ( 16#01 , 16#02 , 16#03 , 16#04 ) = 16#01020304 InOut: Scope Name Type Comment Return PackBytesToDword DWORD functions returns the DWORD defined by the BYTE inputs Input byHHByte BYTE HH byte of the Word byHLByte BYTE HL byte of the Word byLHByte BYTE LH byte of the Word byLLByte BYTE LL byte of the Word
PackBytesToWord (FUN) ¶ FUNCTION PackBytesToWord : WORD Function packs low and high BYTE into a WORD. Example: MEM.PackBytesToWord ( 16#01 , 16#02 ) = 16#0102 InOut: Scope Name Type Comment Return PackBytesToWord WORD function returns the WORD defined by the BYTE inputs Input byHighByte BYTE high byte of the Word byLowByte BYTE low byte of the Word
PackWordsToDword (FUN) ¶ FUNCTION PackWordsToDword : DWORD Function packs low and high WORD into a DWORD. Example: MEM.PackWordsToDword ( 16#0102 , 16#0304 ) = 16#01020304 InOut: Scope Name Type Comment Return PackWordsToDword DWORD function returns the DWORD defined by the WORD inputs Input wHighWord WORD high word of the Dword wLowWord WORD low word of the Dword
UnpackArrayOfByte (FUN) ¶ FUNCTION UnpackArrayOfByte : UINT The function unpacks an “ARRAY OF BYTE” in an “ARRAY OF BOOL”. abySource[0].0 -> axDestination[0] abySource[0].1 -> axDestination[1] … abySource[1].0 -> axDestination[8] … abySource[1].7 -> axDestination[15] … The function copies the amount of “uiNumberOfBits” from “abySource” to “axDestination”. The function will return the number of bytes considered in “abySource”. If “pabySource”, “paxDestination” or “uiNumberOfBits” are set to “0”, the copying will not be carried out and the function will return “FALSE”. Example: abySource : ARRAY [0..2] OF BYTE := 16#32 , 16#01 , 16#00 ; axDestination : ARRAY [0..9] OF BOOL ; uiNumberofBytes := MEM.UnpackArrayOfByte ( ADR ( abySource ), ADR ( axDestination ), 10 ) ; -> uiNumberofBytes = 2 axDestination [0] = FALSE axDestination [1] = TRUE axDestination [2] = FALSE axDestination [3] = FALSE axDestination [4] = TRUE axDestination [5] = TRUE axDestination [6] = FALSE axDestination [7] = FALSE axDestination [8] = TRUE axDestination [9] = FALSE Note The size of the array “axDestination” has to be adjusted to the number of bits to be copied! Source and target may not overlap! InOut: Scope Name Type Comment Return UnpackArrayOfByte UINT function returns the number of bytes considered in “abySource” Input pabySource POINTER TO BYTE address of BYTE ARRAY paxDestination POINTER TO BYTE address of BOOL ARRAY uiNumberOfBits UINT number of bits to copy from “abySource” to “axDestination”
UnpackByte (FB) ¶ FUNCTION_BLOCK UnpackByte Function block unpacks “byValue” and returns the 8 bits “xBit0” .. “xBit7”. Prefix: “memuby”. Example: byInput = 16#01 = 2#00000001 -> xBit0 = TRUE xBit1..xBit7 = FALSE InOut: Scope Name Type Comment Input byValue BYTE BYTE to analyse Output xBit0 BOOL Bit 0 of byValue xBit1 BOOL Bit 1 of byValue xBit2 BOOL Bit 2 of byValue xBit3 BOOL Bit 3 of byValue xBit4 BOOL Bit 4 of byValue xBit5 BOOL Bit 5 of byValue xBit6 BOOL Bit 6 of byValue xBit7 BOOL Bit 7 of byValue
UnpackWord (FB) ¶ FUNCTION_BLOCK UnpackWord Function block unpacks “wValue” and returns the 2 bytes contained “byLowByte” and “byHighByte” and the 16 bits “xBit0” .. “xBit15”. Prefix: “memuw”. Example: wValue = 16#0102 = 2#00000001 00000010 -> byLowByte = 16#02 byHighByte = 16#01 xBit1 , xBit8 = TRUE remain bits = FALSE InOut: Scope Name Type Comment Input wValue WORD WORD to analyse Output byLowByte BYTE low byte of wValue byHighByte BYTE high byte of wValue xBit0 BOOL Bit 0 of wValue xBit1 BOOL Bit 1 of wValue xBit2 BOOL Bit 2 of wValue xBit3 BOOL Bit 3 of wValue xBit4 BOOL Bit 4 of wValue xBit5 BOOL Bit 5 of wValue xBit6 BOOL Bit 6 of wValue xBit7 BOOL Bit 7 of wValue xBit8 BOOL Bit 8 of wValue xBit9 BOOL Bit 9 of wValue xBit10 BOOL Bit 10 of wValue xBit11 BOOL Bit 11 of wValue xBit12 BOOL Bit 12 of wValue xBit13 BOOL Bit 13 of wValue xBit14 BOOL Bit 14 of wValue xBit15 BOOL Bit 15 of wValue
UnpackDWord (FB) ¶ FUNCTION_BLOCK UnpackDWord Function block unpacks “dwValue” and returns the two contained “wLowWord”, “wHighWord”, the 4 contained bytes “byLLByte” .. “byHHByte” and the 32 bits “xBit0” .. “xBit31”. Prefix: “memudw”. Example: dwValue = 16#01020304 = 2#00000001 00000010 00000011 00000100 -> byLowWord = 16#0304 byHighWord = 16#0102 byLLByte = 16#04 byLHByte = 16#03 byHLByte = 16#02 byHHByte = 16#01 xBit2 , xBit8 , xBit9 , xBit17 and xBit24 = TRUE remaining bits = FALSE InOut: Scope Name Type Comment Input dwValue DWORD DWORD to analyse Output wLowWord WORD low word of dwValue wHighWord WORD high word of dwValue byLLByte BYTE byte LL of dwValue byLHByte BYTE byte LH of dwValue byHLByte BYTE byte HL of dwValue byHHByte BYTE byte HH of dwValue xBit0 BOOL Bit 0 of dwValue xBit1 BOOL Bit 1 of dwValue xBit2 BOOL Bit 2 of dwValue xBit3 BOOL Bit 3 of dwValue xBit4 BOOL Bit 4 of dwValue xBit5 BOOL Bit 5 of dwValue xBit6 BOOL Bit 6 of dwValue xBit7 BOOL Bit 7 of dwValue xBit8 BOOL Bit 8 of dwValue xBit9 BOOL Bit 9 of dwValue xBit10 BOOL Bit 10 of dwValue xBit11 BOOL Bit 11 of dwValue xBit12 BOOL Bit 12 of dwValue xBit13 BOOL Bit 13 of dwValue xBit14 BOOL Bit 14 of dwValue xBit15 BOOL Bit 15 of dwValue xBit16 BOOL Bit 16 of dwValue xBit17 BOOL Bit 17 of dwValue xBit18 BOOL Bit 18 of dwValue xBit19 BOOL Bit 19 of dwValue xBit20 BOOL Bit 20 of dwValue xBit21 BOOL Bit 21 of dwValue xBit22 BOOL Bit 22 of dwValue xBit23 BOOL Bit 23 of dwValue xBit24 BOOL Bit 24 of dwValue xBit25 BOOL Bit 25 of dwValue xBit26 BOOL Bit 26 of dwValue xBit27 BOOL Bit 27 of dwValue xBit28 BOOL Bit 28 of dwValue xBit29 BOOL Bit 29 of dwValue xBit30 BOOL Bit 30 of dwValue xBit31 BOOL Bit 31 of dwValue
Reverse Bit, Swap Byte,Word order ¶ ReverseBYTEsInDWORD (Function) ReverseBYTEsInWORD (Function) ReverseBitsInBYTE (Function) ReverseBitsInDWORD (Function) ReverseBitsInWORD (Function) ReverseWORDsInDWORD (Function)