Omron CJ - REFERENCE MANUAL 02-2010 Reference Manual page 417

Table of Contents

Advertisement

Function
BIN
BIN(023) converts the BCD data in S to binary data and
writes the result to R.
The following diagram shows an example BCD-to-binary conversion.
R
3
2
1
0
10
10
10
10
BINL
BINL(058) converts the 8-digit BCD data in S and S+1 to 8-
digit hexadecimal (32-bit binary) data and writes the result to
R and R+1.
The following diagram shows an example of 8-digit BCD-to-binary conversion.
7
6
5
4
3
2
1
0
10
10
10
10
10
10
10
10
Example Programming
When CIO 0.00 is ON in the following example, the 8-digit BCD value in CIO 0010 and CIO 0011 is
converted to hexadecimal and stored in D200 and D201.
0.00
S+1: CIO 11
0
0
2
7
6
5
10
10
10
0
0
0
7
6
5
16
16
16
R+1: D201
In this example, N words of BCD data is converted to binary data.
If N = 3, the three words of BCD starting from D10 will be converted to binary data one word at a time
when CIO 0.00 turns ON. The resulting binary data will be stored starting from D100.
0.00
MOVR
D10
IR0
MOVR
D100
IR1
FOR
&3
0.00
BIN
,IR0+
,IR1+
NEXT
CS/CJ/NSJ Series Instructions Reference Manual (W474)
3
2
1
0
16
16
16
16
R+1
R
4
7
6
5
3
2
1
0
16
16
16
16
16
16
16
16
0.10
D200
S: CIO 10
0
0
0
5
0
4
3
2
1
0
10
10
10
10
10
3
0
D
7
2
4
3
2
1
0
16
16
16
16
16
R: D200
D10
BCD#0100
D11
BCD#0200
D12
BCD#0300
BCD
BIN
(Hexadecimal #0064)
D100
Decimal &100
D101
Decimal &200
(Hexadecimal #00C8)
D102
Decimal &300
(Hexadecimal #012C)
(BCD)
S+1
S
(BCD)
(BCD)
4
2
1
2000.50=3 16
+13 16
+7 16
3. Instructions
R
(BIN)
R+1
R
(BIN)
(BIN)
0
+2 16
3
381

Advertisement

Table of Contents
loading

Table of Contents