plc4good.org.ua

Int64



int64



(PCS7) integer 64 , 32 -9,223,372,036,854,775,808 9,223,372,036,854,775,807 .. , , .

DiToInt64 - int32 - int64
Int64ToDi - int64 - int32
AddInt64 -
NegInt64 -





int64



PIDConR - .



:



{
Scl_ResetOptions ;
Scl_OverwriteBlocks:= 'y' ;
Scl_GenerateReferenceData := 'y' ;
Scl_S7ServerActive:= 'y' ;
Scl_CreateObjectCode:= 'y' ;
Scl_OptimizeObjectCode:= 'y' ;
Scl_MonitorArrayLimits:= 'y' ;
Scl_CreateDebugInfo := 'n' ;
Scl_SetOKFlag:= 'n' ;
Scl_SetMaximumStringLength:= '254'
}





Name: F357
Symbolic Name: DiToInt64
Symbol Comment: Converting from DINT to Int64
Family: System
Version: 2.0
Author: AdvLib80
Last modified: 07/04/2011
Use: UDT23
Size: 144 bytes
Original SCL source name: ExtendedPrecision
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.07.00_01.02.00.01 release



FUNCTION FC1357 : VOID
TITLE ='Converting from DINT to Int64'
AUTHOR : AdvLib80
FAMILY : System
NAME : DiToIn64
VERSION : '2.0'
 
VAR_INPUT
theDInt : DINT ;
END_VAR
 
VAR_OUTPUT
OutInt64 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
END_VAR
 
VAR_TEMP
temp : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
END_VAR
 
BEGIN
temp.LowerDInt:=theDInt;
temp.UpperDInt:=0;

IF theDInt < 0 THEN temp.UpperDInt:=-1; END_IF;

OutInt64.UpperDInt:=temp.UpperDInt;
OutInt64.LowerDInt:=temp.LowerDInt;
 
END_FUNCTION



int64

Block checksum .





Name: F359
Symbolic Name: Int64ToDi
Symbol Comment: Converting from Int64 to DINT
Family: System
Version: 2.0
Author: AdvLib80
Last modified: 07/04/2011
Use: UDT23
Size: 80 bytes
Original SCL source name: ExtendedPrecision
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.07.00_01.02.00.01 release



FUNCTION FC1359 : DINT
TITLE ='Converting from Int64 to DINT'
AUTHOR : AdvLib80
FAMILY : System
NAME : In64ToDi
VERSION : '2.0'
 
VAR_INPUT
TheInt64 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
END_VAR
 
BEGIN
FC1359:=TheInt64.LowerDInt;
END_FUNCTION



int64

Block checksum .





Name: F353
Symbolic Name: AddInt64
Symbol Comment: Addition of two 64-bit integer variables
Family: System
Version: 2.0
Author: AdvLib80
Last modified: 07/04/2011
Use: UDT23
Size: 422 bytes
Original SCL source name: ExtendedPrecision
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.07.00_01.02.00.01 release



FUNCTION FC1353 : VOID
TITLE ='Addition of two 64-bit integer variables'
AUTHOR : AdvLib80
FAMILY : System
NAME : AddInt64
VERSION : '2.0'
//reversed
 
VAR_INPUT
Int64_1 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
Int64_1_dw AT Int64_1 : STRUCT
x0 : DWORD ;
x1 : DWORD ;
END_STRUCT ;


Int64_2 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
Int64_2_dw AT Int64_2 : STRUCT
x0 : DWORD ;
x1 : DWORD ;
END_STRUCT ;
 
END_VAR
 
VAR_OUTPUT
OutInt64 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
END_VAR
 
VAR_TEMP
retval : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
retval_dw AT retval : STRUCT
x0 : DWORD ;
x1 : DWORD ;
END_STRUCT ;
 

TempDINT1 : DINT ;
TempDINT2 : DINT ;
l1_lowbit : DINT ;
l1_lowbit_dw AT l1_lowbit : DWORD ;
 
l2_lowbit : DINT ;
l2_lowbit_dw AT l2_lowbit : DWORD ;
 
AddOne : DINT ;
AddTwo : DINT ;
carry : DINT ;
END_VAR
BEGIN
 
l1_lowbit:=DWORD_TO_DINT(Int64_1_dw.x1 AND DW#16#1);
l2_lowbit:=DWORD_TO_DINT(Int64_2_dw.x1 AND DW#16#1);
 
AddOne:=DWORD_TO_DINT(DINT_TO_DWORD(l1_lowbit) XOR DINT_TO_DWORD(l2_lowbit));
AddTwo:=DWORD_TO_DINT(DINT_TO_DWORD(l1_lowbit) AND DINT_TO_DWORD(l2_lowbit));
carry:=0;
TempDINT1:=DWORD_TO_DINT(SHR(IN:=Int64_1_dw.x1,N:=1));
TempDINT2:=DWORD_TO_DINT(SHR(IN:=Int64_2_dw.x1,N:=1));
 
retval.LowerDInt:=TempDINT1 + TempDINT2 + AddTwo;
 
IF retval.LowerDInt<0
THEN
carry:=1;
END_IF;
 
retval.LowerDInt:=DWORD_TO_DINT(SHL(IN:=retval_dw.x1,N:=1));
retval.LowerDInt:=retval.LowerDInt + AddOne;
 
retval.UpperDInt:=Int64_1.UpperDInt + Int64_2.UpperDInt + carry;
 
OutInt64.UpperDInt:=retval.UpperDInt;
OutInt64.LowerDInt:=retval.LowerDInt;
 
END_FUNCTION



int64

Block checksum .





Name: F362
Symbolic Name: NegInt64
Symbol Comment: Negation of an Int64 variable
Family: System
Version: 2.0
Author: AdvLib80
Last modified: 07/04/2011
Use: UDT23, FC353, FC357
Size: 272 bytes
Original SCL source name: ExtendedPrecision
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.07.00_01.02.00.01 release



FUNCTION FC1362 : VOID
TITLE ='Negation of an Int64 variable'
AUTHOR : AdvLib80
FAMILY : System
NAME : NegInt64
VERSION : '2.0'
 
 
VAR_INPUT
theInt64 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
END_VAR
 
VAR_OUTPUT
OutInt64 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
END_VAR
 
VAR_TEMP
retval : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
Int64_One : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
END_VAR
 
BEGIN
 
retval.LowerDInt:=DWORD_TO_DINT(DINT_TO_DWORD(theInt64.LowerDInt) XOR DW#16#FFFFFFFF);
retval.UpperDInt:=DWORD_TO_DINT(DINT_TO_DWORD(theInt64.UpperDInt) XOR DW#16#FFFFFFFF);
 
DiToInt64(theDInt := 1
,OutInt64 :=Int64_One
);

AddInt64(Int64_1 := retval
,Int64_2 := Int64_One
,OutInt64 := retval
);

OutInt64.UpperDInt:=retval.UpperDInt;
OutInt64.LowerDInt:=retval.LowerDInt;
 
END_FUNCTION



int64

Block checksum .



- NegInt64

 
DiToInt64(theDInt := 1
,OutInt64 :=Int64_One
);



:



int64

-(5 + 7) = -12 .





PCS7 (Advanced Process Library (V8.0 SP2) (zip, 3.5Mb)