summaryrefslogtreecommitdiffstats
path: root/tests/550-library/iec/fc9_eq_dt.awl
blob: 4f788b5483e5196b5ccf40c9b8e8a9a22a87d045 (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
DATA_BLOCK DB 1
STRUCT 	
	DT1	: DATE_AND_TIME := DT#1990-1-1-0:0:0.000;
	DT2	: DATE_AND_TIME := DT#1990-1-1-0:0:0.000;
	DT3	: DATE_AND_TIME := DT#1990-1-1-0:0:0.000;
END_STRUCT;
BEGIN
	DT1 := DT#1990-1-1-0:0:0.000; 
	DT2 := DT#1990-1-1-0:0:0.000; 
	DT3 := DT#1990-1-1-0:0:0.000; 
END_DATA_BLOCK


FUNCTION FC 1 : VOID
VAR_TEMP
	DBNR	: INT;
END_VAR
BEGIN
	AUF		DB 1
	LAR1		P#DBX 0.0

	// Rotate DB1.DT1 one bit to the left
	L		D [AR1,P#4.0]
	UD		DW#16#80000000
	L		D [AR1,P#0.0]
	RLDA
	T		D [AR1,P#0.0]
	L		D [AR1,P#4.0]
	RLDA
	T		D [AR1,P#4.0]

	// Rotate DB1.DT2 one bit to the left
	L		D [AR1,P#12.0]
	UD		DW#16#80000000
	L		D [AR1,P#8.0]
	RLDA
	T		D [AR1,P#8.0]
	L		D [AR1,P#12.0]
	RLDA
	T		D [AR1,P#12.0]

	// Clobber DB and DI registers
	L		0
	T		#DBNR
	AUF		DB [#DBNR]
	AUF		DI [#DBNR]

	// Compare DB1.DT1 to DB1.DT2
	// Should be equal
	CALL "EQ_DT" (
		DT1	:= DB1.DT1,
		DT2	:= DB1.DT2,
		RET_VAL	:= M 0.0,
	)
	U		M 0.0
	__ASSERT==	__STW VKE,	1

	// Clobber DB and DI registers
	L		0
	T		#DBNR
	AUF		DB [#DBNR]
	AUF		DI [#DBNR]

	// Compare DB1.DT1 to DB1.DT3
	// Should be not equal
	CALL "EQ_DT" (
		DT1	:= DB1.DT1,
		DT2	:= DB1.DT3,
		RET_VAL	:= M 0.1,
	)
	U		M 0.1
	__ASSERT==	__STW VKE,	0

	// Decrement the test counter.
	// Stop test, if it reaches zero.
	AUF		DB 1
	U		DBX 0.0
	ZR		Z 0
	U		Z 0
	SPB		m003
	CALL		SFC 46 // Stop CPU
m003:	NOP		0
END_FUNCTION


ORGANIZATION_BLOCK OB 1
BEGIN
	CALL		FC 1
END_ORGANIZATION_BLOCK


ORGANIZATION_BLOCK OB 100
BEGIN
	AUF		DB 1
	LAR1		P#DBX 0.0

	// Initialize DB1.DT1 (one bit set)
	L		1
	T		D [AR1,P#0.0]
	L		0
	T		D [AR1,P#4.0]

	// Initialize DB1.DT2 (one bit set)
	L		1
	T		D [AR1,P#8.0]
	L		0
	T		D [AR1,P#12.0]

	// Initialize DB1.DT3 (all bits clear)
	L		0
	T		D [AR1,P#16.0]
	L		0
	T		D [AR1,P#20.0]

	// Initialize the test counter.
	// Run 10 test loops.
	L		C#10
	CLR
	S		Z 0
	SET
	S		Z 0
END_ORGANIZATION_BLOCK
bues.ch cgit interface