forked from simsum/oscat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBYTE_TO_STRB.EXP
More file actions
executable file
·62 lines (48 loc) · 1.23 KB
/
Copy pathBYTE_TO_STRB.EXP
File metadata and controls
executable file
·62 lines (48 loc) · 1.23 KB
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
(* @NESTEDCOMMENTS := 'Yes' *)
(* @PATH := '\/String' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
FUNCTION BYTE_TO_STRB : STRING(8)
VAR_INPUT
IN : BYTE;
END_VAR
VAR
i: INT;
pt : POINTER TO BYTE;
END_VAR
(*
version 1.3 20. jun. 2008
programmer hugo
tested by oscat
BYTE_TO_STRINGB converts a Byte to a String of Bits represented by '0' and '1' s.
The lowest order bit will be on the right and the high order bit on the left.
*)
(* @END_DECLARATION := '0' *)
(* pointer für die ausgabe ermitteln *)
pt := ADR(BYTE_TO_STRB);
(* die 8 ausgabecharacter ermitteln und schreiben *)
FOR i := 1 TO 8 DO
pt^ := BOOL_TO_BYTE(in.7) + 48;
in := SHL(in,1);
pt := pt + 1;
END_FOR;
(* der ausgabestring muss noch mit 0 abgeschlossen werden *)
pt^ := 0;
(* code before rev 1.1
FOR i := 1 TO 8 DO
IF in.0 = 0 THEN temp := CONCAT('0', temp); ELSE temp := CONCAT('1', temp); END_IF;
in := SHR(in, 1);
END_FOR;
BYTE_TO_STRB := temp;
*)
(* revision history
hm 9.6.2007 rev 1.0
original version
hm 15. dec 2007 rev 1.1
inprooved code for higher performance
hm 29. mar. 2008 rev 1.2
changed STRING to STRING(8)
hm 20. jun. 2008 rev 1.3
performance improvement
*)
END_FUNCTION