6/29/2012 8:15 AM | |
Posts: 1064 Rating: (72) |
you can do the same in lad use cmp ==d and compare each word to zero if the equal turn on your bit |
6/29/2012 7:40 PM | |
Joined: 1/28/2009 Last visit: 5/20/2024 Posts: 6840 Rating: (1359)
|
Hello again, You need a function to combine all arrays automatically to some DWORD parameters.Function is in SCL but there is no need to know the flow of program.It gets 256 array of type bool and combine them to DWORDs in order. I upload the project for furthur reference. [code] FUNCTION FC2 : void VERSION: '1.0' AUTHOR: hdhosseini NAME: ar_dw FAMILY: data_man // Block Parameters VAR_INPUT // Input Parameters hd:ARRAY[0..255]OF BOOL; END_VAR VAR_IN_OUT // I/O Parameters i:INT; J:INT; k:INT; END_VAR VAR_OUTPUT // Output Parameters // aus:DWORD:=0; AUS:ARRAY[0..7]OF DWORD; END_VAR VAR_TEMP // Temporary Variables temp:DWORD; temp1:DWORD; temp2:DWORD; END_VAR // Statement Section ; k:=0; FOR J:= 0 TO 7 BY 1 DO //temp2:=0; FOR i:= 0 TO 31 BY 1 DO // Statement Section temp:=DINT_TO_DWORD(BOOL_TO_DINT (hd[k+i]));//make INT out of BOOL temp1:= SHL (in:=temp , n:=i);//shift to proper position temp2:= ((SHL (in:=dw#16#1 , n:=i))XOR (dw#16#ffffffff)) AND aus[J] ; aus[J]:= temp2 OR (temp1) ;//combine ; END_FOR; k:=k+32;//next 32 bits END_FOR; END_FUNCTION [/code] Hope this helps Best regards Hamid Hosseini Attachmentarray_to_dword.zip (139 Downloads) |
6/29/2012 7:51 PM | |
Joined: 1/28/2009 Last visit: 5/20/2024 Posts: 6840 Rating: (1359)
|
And this is the source project
AttachmentTest.zip (526 Downloads) |
This contribution was helpful to1 thankful Users |
Follow us on