-
Notifications
You must be signed in to change notification settings - Fork 5
/
ShLeIn64.scl
89 lines (75 loc) · 1.89 KB
/
ShLeIn64.scl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Name: FС370
// Symbolic Name: ShLeIn64
// Symbol Comment: Left shift of an Int64 variable
// Family: System
// Version: 2.0
// Author: AdvLib80
// Last modified: 07/04/2011
// Use: UDT23
// Size: 326 byte
// Signature: compiled by SCL compiler version: SCLCOMP K05.03.07.00_01.02.00.01 release
FUNCTION FC1370 : VOID
TITLE ='Left shift of an Int64 variable'
AUTHOR : AdvLib80
FAMILY : System
NAME : ShLeIn64
VERSION : '2.0'
//reversed
VAR_INPUT
IN : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
Shift : INT ;
END_VAR
VAR_OUTPUT
OutInt64 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
END_VAR
VAR_TEMP
N : INT ;
TempInt64 : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
TempInt64_dw AT TempInt64: STRUCT
UpperDInt : DWORD ;
LowerDInt : DWORD ;
END_STRUCT ;
retval : STRUCT
UpperDInt : DINT ;
LowerDInt : DINT ;
END_STRUCT ;
retval_dw AT retval : STRUCT
UpperDInt : DWORD ;
LowerDInt : DWORD ;
END_STRUCT ;
Mask : DWORD ;
BitsFromLowerDWord : DWORD ;
END_VAR
BEGIN
retval.UpperDInt:=0;
retval.LowerDInt:=0;
N:=Shift;
IF N>=0 AND N<=63
THEN
TempInt64.UpperDInt:=IN.UpperDInt;
TempInt64.LowerDInt:=IN.LowerDInt;
IF N>=32
THEN
TempInt64.UpperDInt:=TempInt64.LowerDInt;
TempInt64.LowerDInt:=0;
N:=N-32;
END_IF;
retval_dw.UpperDInt:=SHL(IN:=TempInt64_dw.UpperDInt,N:=N);
Mask:=SHL(IN:=DW#16#FFFFFFFF,N:=32-N);
BitsFromLowerDWord:=Mask AND TempInt64_dw.LowerDInt;
BitsFromLowerDWord:=SHR(IN:=BitsFromLowerDWord,N:=32-N);
retval_dw.UpperDInt:=BitsFromLowerDWord OR retval_dw.UpperDInt;
retval_dw.LowerDInt:=SHL(IN:=TempInt64_dw.LowerDInt,N:=N);
END_IF;
OutInt64.UpperDInt:=retval.UpperDInt;
OutInt64.LowerDInt:=retval.LowerDInt;
END_FUNCTION