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
|
PACKET konvert DEFINES (* Copyright (C) 1986 *)
(* Frank Klapper *)
(* 28.10.86 *)
high byte,
low byte,
word,
change low byte,
change high byte,
dint,
high word,
low word:
INT PROC high byte (INT CONST value):
TEXT VAR x := " ";
replace (x, 1, value);
code (x SUB 2)
END PROC high byte;
INT PROC low byte (INT CONST value):
TEXT VAR x := " ";
replace (x, 1, value);
code (x SUB 1)
END PROC low byte;
INT PROC word (INT CONST low byte, high byte):
TEXT CONST x :: code (low byte) + code (high byte);
x ISUB 1
END PROC word;
PROC change low byte (INT VAR word, INT CONST low byte):
TEXT VAR x := " ";
replace (x, 1, word);
replace (x, 1, code (low byte));
word := x ISUB 1
END PROC change low byte;
PROC change high byte (INT VAR word, INT CONST high byte):
TEXT VAR x := " ";
replace (x, 1, word);
replace (x, 2, code (high byte));
word := x ISUB 1
END PROC change high byte;
REAL PROC dint (INT CONST low word, high word):
real low word + 65536.0 * real high word.
real low word:
real (low byte (low word)) + 256.0 * real (high byte (low word)).
real high word:
real (low byte (high word)) + 256.0 * real (high byte (high word)).
END PROC dint;
INT PROC high word (REAL CONST double precission int):
int (double precission int / 65536.0)
END PROC high word;
INT PROC low word (REAL CONST double precission int):
string of low bytes ISUB 1.
string of low bytes:
code (int (double precission int MOD 256.0)) +
code (int ((double precission int MOD 65536.0) / 256.0)).
END PROC low word;
END PACKET konvert;
|