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
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
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
Reverse Bit, Swap Byte,Word order ¶ ReverseBYTEsInDWORD (Function) ReverseBYTEsInWORD (Function) ReverseBitsInBYTE (Function) ReverseBitsInDWORD (Function) ReverseBitsInWORD (Function) ReverseWORDsInDWORD (Function)
ReverseBYTEsInDWORD (FUN) ¶ FUNCTION ReverseBYTEsInDWORD : DWORD Function returns the DWORD “dwInput” with a reversed byte-order. Example: dwInput = 16#01020304 -> MEM.ReverseWORDsInDWORD ( dwInput ) = 16#04030201 InOut: Scope Name Type Comment Return ReverseBYTEsInDWORD DWORD function returns a DWORD with reversed byte-order of “dwInput” Input dwInput DWORD DWORD to reverse
ReverseBYTEsInWORD (FUN) ¶ FUNCTION ReverseBYTEsInWORD : WORD Function returns the WORD “wInput” with a reversed byte-order (Low-Byte<->High-Byte). Example: wInput = 16#0102 -> MEM.ReverseBYTEsInWORD ( wInput ) = 16#0201 InOut: Scope Name Type Comment Return ReverseBYTEsInWORD WORD Input wInput WORD WORD to reverse