The text of a manual · part 16 of 37
Sharp Programmable Controller New Satellite JW10 User's Manual: Chapter 9 Description of Instructions, pages 116 to 125
Pages 116 to 125 of 307, from Sharp Programmable Controller New Satellite JW10 User's Manual
The original document is the PDF (5.0 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Filed in the catalog under the Sharp jW-10CM
Page 116
Subtract register from register (BCD 2 digits) (SUBtract)
F-11 SUB Symbol
F-11 SUB
S1
S2
〔Example for use〕
D
Function
The contents of the register S1 are subtracted by the contents of the register S2 in BCD 2 digits and its result is stored in the register D.
Operation
S1ーS2→D
Range of S1
Range of S2
Range of D
Condition
04001
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777 コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777 コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
・Transition of operational result and flags Input (04001) register (09030)
15 15
43 43
43 43
E5 E5
24 24
(09040)
15 15
11 11
58 58
13 13
9C 9C
(09050)
40 00 (15−15)
00 32 (43−11)
32 85 (43−58)
85 85 85 85 No subtraction No subtraction (09030 not BCD). (09040 not BCD).
Non-carry flag 07354 Error flag 07355 Carry flag 07356 Zero flag 07357
Rising edge of input signal (OFF to ON)
9 1 scan time, max.
・Result
Valid until a flag affecting instruction is met in the program.
Result
If (contents of S1) < (contents of S2) is calculated, the answer will be produced in the complement of 100. 〔Example〕 23−85 = −62 will produce the answer of 38 which is the complement of 100 of 62. (Assume it to be 123−85 = 38.)
Contents ・Unchanged when the contents of registers of D S1 and S2 are not BCD code.
Flag
09030 09040 09050
F-11 09030 09040 09050 SUB
When the input condition 04001 changes from OFF to ON, the contents of the register 09030 are subtracted by the contents of the register 09040 and its result is stored in the register 09050. The contents of registers 09030 and 09040 remain unchanged.
Contents Unchanged of S1 Contents Unchanged of S2 After operation
Instruction 04001
STR F-11
0 1 to 99 Negative value S1 and S2 are not BCD code
Zero 07357
Carry 07356
1 0 0 0
0 0 1 0
Error Non-carry 07354 07355
0 0 0 1
1 1 0 0
Similarity instructions: F-11w, Fc11, Fc11w Reference In case 3 BCD digits or more have to be subtracted, the F-11 instruction must be provided successively. When the F-11 instruction is programmed repeatedly, the contents of the carry flag (07356) is also subtracted after the second instruction. For the F-11 instruction that appears first in succession to the STR instruction, the contents of the carry flag (07356) is not subtracted.
Tens
4
04001
F-11 09030 09040 09050 SUB F-11 09031 09041 09051 SUB
3
Thousands Hundreds 09031 1 0 0 1 0 1 1 0
9
Instruction 04001 STR F-11 09030 09040 09050 F-11 09031 09041 09051
Ones
Tens
09030 0 1 0 0 0 0 1 1
6
Ones
0 1 0 1 1 0 0 0 09040
−
5
8
Thousands Hundreds 0 1 0 0 1 0 0 1 09041
4
9
Tens
Ones
1 0 0 0 0 1 0 1 09050
8
5
Thousands Hundreds 0 1 0 0 0 1 1 0 09051
4
6
・The above example shows the case of 9643−4958=4685. ・If programmed from low order digit, the carry information will be carried on to a higher digit.
9-41
Page 117
F-11w SUB
Subtract register from register (BCD 4 digits) (SUBtract) F-11w SUB
Symbol
S1
S2
〔Example for use〕
D
Function
The 4 digits BCD contents of the registers S1 and S1+1 are subtracted by the contents of the registers S2, S2+1 and its result is stored in the registers D, D+1.
Operation
(S1, S1+1) ー (S2, S2+1) →D, D+1
Range of S1
Range of S2
Range of D
Condition
9
04000
Instruction 04000
STR F-11w F-11w 19000 19002 19004 SUB
19000 19002 19004
When the input condition 04000 changes from OFF to ON, the 4 digits BCD contents of the registers 19000 and 19001 are subtracted by the contents of the registers 19002 and 19003 and its result is stored in the registers 19004 and 19005.
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776 コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776 コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
19001
19000
0110011110001001
6
7
8
9
− 19003
19002
0001001000110100
1
2
3
19005
Rising edge of input signal (OFF to ON)
4 19004
0101010101010101 Contents of S1, S1+1 Contents of S2, S2+1 Contents of D After operation Contents of D+1
Flag
Unchanged
5
Unchanged Lower 2 digits of the result Upper 2 digits of the result
Unchanged when the contents of registers S1, S1+1, S2 and S2+1 are not BCD code.
Result
Zero 07357
Carry 07356
0 1 to 9999
1 0 0 0
0 0 1 0
Negative value Not BCD code
Error Non-carry 07354 07355
0 0 0 1
1 1 0 0
5
5
5
Result will be produced as a complement of 10000, if (contents of S1, S1+1) < (contents of S2, S2+1) is carried out. 〔Example〕 2578−7890 = −5312 will produce the answer of 4688 which is the complement of 10000 of 5312. (Assume it to be 12578−7890=4688.)
Note 1: Be sure to use even addresses for registers S1, S2 and D. Similarity instructions: F-11, Fc11, Fc11w Reference As double length operation is possible for the F-11w instruction, same as the F-11 instruction, write F-11w instruction in succession to subtract 5 digits or more of BCD.
00001
F-11w 19000 19004 19010 SUB
F-11w 19002 19006 19012 SUB
19003
Instruction 00001 STR F-11w 19000 19004 19010 F-11w 19002 19006 19012
19002
19001
19000
10000111011001010100001100100001
8
7
6
5
4
3
2
1
− 19007
19006
19005
19004
10011001100110011001100110011001
9
9
9
19013
9
9
19012
9
9
19011
9
19010
10000111011001010100001100100010
8
9-42
7
6
5
4
3
2
2
Page 118
Subtract constant (2 digits) from register (BCD 2 digits) (SUBtract)
Fc11 SUB Symbol
Fc11 SUB
S1 n
Instruction 04001
〔Example for use〕
D
STR Fc11
Function
The contents of the register S1 are subtracted by 2 digits BCD constant "n" and its result is stored in the register D.
Operation
S1→n→D
Range of S1
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
04001
Fc11 09000 SUB
85
09000 85 09002
09002
When the input condition 04001 changes from OFF to ON, the contents of the register 09000 are subtracted by the BCD constant 85 and its result is stored in the register 09002. It operates in the same timing as the F-11 instruction.
Range of "n" 00 to 99 コ0000 to コ1577 b0000 to b0777 09000 to 09777 Range of D 19000 to 19777 29000 to 29777 39000 to 39777
Condition
After operation
09000
10010100 9
4
− BDC constant 85
Rising edge of input signal (OFF to ON)
00000101 0
10000101 8
9
5
Contents Unchanged of S1 ・Result Contents ・Unchanged when the contents of the of D register S1 are not BCD code. Result
Flag
0 1 to 99 Negative value S1 is not BCD code
Zero 07357
Carry 07356
Error 07355
1 0 0 0
0 0 1 0
0 0 0 1
If (contents of S1) < n is calculated, the answer will be produced in the complement of 100. 〔Example〕 23−85 = −62 will produce the answer of 38 which is the complement of 100 of 62. (Assume it to be 123−85=38.) Non-carry 07354
1 1 0 0
Similarity instructions: F-11, F-11w, Fc11w Reference Similar to the F-11 instruction, it is possible to subtract 3 digits or more of BCD value.
00200
Fc11 09000 SUB
Fc11 09001 SUB
34
12
09050
09051
09002
Instruction 00200 STR Fc11 09000 34 09050 Fc11 09001 12 09051
09001
09000
0101011001111000
5
6
7
8
− BCD constant 1234
0001001000110100
1
2
3
09051
4 09050
0100010001000100
4
9-43
4
4
4
9
Page 119
Subtract constant (4 digits) from register (BCD 4 digits) (SUBtract)
Fc11w SUB
Fc11w SUB
Symbol
S1 n
D
Function
The 4 digits BCD contents of the registers S1, S1+1 are subtracted by 4 digits BCD constant "n" and its result is stored in the registers D, D+1.
Operation
(S1, S1+1) ーn→D, D+1
Range of S1
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
STR Fc11w 02001
Fc11w 19500 2345 SUB
Condition
9
19501
4
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
Contents of D
Lower 2 digits of the result Upper 2 digits of the result
2
1
BDC constant 2345 0010001101000101
2
3
4
5 19600
19601
0001100101110110
1
Unchanged when the contents of registers S1 and S1+1 are not BCD code.
Result
Zero 07357
Carry 07356
0 1 to 9999
1 0 0 0
0 0 1 0
Negative value Not BCD code
3
−
Rising edge of input signal (OFF to ON)
Unchanged
Flag
19500
0100001100100001
Contents of S1,S1+1
Contents After of D+1 operation
19500 2345 19600
19600
When the input condition 02001 changes from OFF to ON, the 4 digits BCD contents of the registers 19500 and 19501 are subtracted by the BCD constant 2345 and its result is stored in the registers 19600 and 19601.
Range of "n" 0000 to 9999
Range of D
Instruction 02001
〔Example for use〕
Error Non-carry 07354 07355
0 0 0 1
1 1 0 0
9
7
6
If (contents of S1, S1+1) < n is calculated, the answer will be produced in the complement of 10000. 〔Example〕 4568−7890 = −3322 will produce the answer of 6678 which the complement of 10000 of 3322. (Assume it to be 14568−7890=6678.)
Note 1: Be sure to use even addresses for registers S1 + D. Similarity instructions: F-11, F-11w, Fc11 Reference As double length operation is possible for the Fc11w instruction, same as the Fc11 instruction, write Fc11w instruction in succession to subtract 9 digits or more of BCD.
00001
Fc11w 19000 8888 SUB
Fc11w 19002 7777 SUB
09006
09010
19003
Instruction STR 00001 Fc11w 19000 8888 19006 Fc11w 19002 7777 19010
19002
19001
19000
10000111011001010100001100100001
8
7
6
5
4
3
2
1
− 01110111011101111000100010001000
7
7
7
19011
7
8
19010
8
8
19007
8
19006
00001001100001110101010000110011
0
9-44
9
8
7
5
4
3
3
Page 120
Compare register with register (1 byte) (CoMPare)
F-12 CMP
F-12 CMP
Symbol
S1
〔Example for use〕
S2
04003
Function
The contents of the register S1 are compared with the contents of the register S2.
Operation
S1< = >S2→Flag
Range of S2
After operation
Contents of S1 Contents of S2
Input 04003 Register 09000 Register 09010
Unchanged
Flag
Zero 07357
Carry 07356
0 1 0
0 0 1
S1 > S2 S1 = S2 S1 < S2
Error Non-carry 07354 07355
0 0 0
23 23
23 23
23 23
11 11
23 23
58 58
Non-carry flag 07354 Carry flag 07356
Unchanged Contents of register
09000 09010
・Transition of register contents and flags
When the input signal is ON (not limited to OFF to ON change)
Condition
F-12 09000 09010 CMP
When the input condition 04003 is ON, the contents of the register 09000 are compared with the contents of the register 09010 and its results are set in the non-carry flag (07354), carry flag (07356), and the zero flag (07357). registers 09000 and 09010 remain unchanged after this operation.
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777 コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
Range of S1
Instruction 04003
STR F-12
Zero flag 07357
1 scan time
1 1 0
So long as the input condition is ON, comparison is done at every scan and the zero flag is tumed ON.
Similarity instructions: F-12w Fc12, Fc12w
Reference
Reference
In case comparison is to be done only at an OFF to ON To compare data of 2 bytes or more, it must be so programmed that comparision should start from a lower order digit, as in transition of the input condition, use the differentiate addition (F-10) and subtraction (F-11). If the F-12 were instruction in conjunction with the input condition. 04003 F-44
F-12 09000 09010 CMP programmed in succession, the contents of the carry flag (07356) are also compared after the second F-12 instruction. For the F-12 instruction that first follows the STR instruction, the contents of the carry flag (07356) are exemption from comparison.
Instruction 04003 STR F-44 09000 F-12 09010
04003
F-12 09000 09010 CMP F-12 09001 09011 CMP
Instruction 04003 STR F-12 09000 09010 F-12 09001 09011
When programmed from a lower digit, the carry-down information is forwarded to an upper digit.
9-45
9
Page 121
F-12w CMP
Compare register with register (1 word) (CoMPare) F-12w CMP
Symbol
S1
〔Example for use〕
S2
04004
Function
The word contents of the registers S1, S1+1 are compared with the word contents of the registers S2, S2+1.
Operation
S1, S1+1< = >S2, S2+1→Flag
Range of S1
Range of S2
Condition
9
After operation
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776 コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
Flag
09000 09002
When the input condition 04004 is ON, the word contents of the registers 09000 and 09001 are compared with the word contents of the registers 09002 and 09003 and its results are set in the non-carry flag (07354), carry flag (07356), and the zero flag (07357). Registers 09000 to 09003 remain unchanged.
register (09000) (09001)
005 124
(09002) (09003)
006 123
005 124 006 123
005 124 005 124
005 124
005 124 004 125
004 125
Non-carry flag (07354) Carry flag (07356)
Unchanged
Zero flag (07357)
Unchanged Contents of Zero register 07357 S1, S1+1>S2, S2+1 0 S1, S1+1=S2, S2+1 1 S1, S1+1<S2, S2+1 0
F-12w 09000 09002 CMP
Input (04004)
When the input signal is ON state (not limited to OFF to ON change)
Contents of S1, S1+1 Contents of S2, S2+1
Instruction 04004
STR F-12w
Carry 07356
0 0 1
Error Non-carry 07354 07355
0 0 0
1 1 0
Note 1: Be sure to use even addresses for registers S1 + S2. Similarity instructions: F-12, Fc12, Fc12w
Reference If the F-12w instruction were used in succession, 3 bytes or more data comparison may be done.
00000
F-12w 09000 09004 CMP F-12w 09002 09006 CMP
9-46
Instruction 00000 STR F-12w 09000 09004 F-12w 09002 09006
Page 122
Fc12 CMP Symbol
Compare register with constant (1 byte) (CoMPare) Fc12 CMP
S1 n
Function
The contents of the register S1 are compared with an octal constant "n".
Operation
S1<=>n→Flag
Range of S1
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
STR Fc12 04001
09000
When the input signal is ON (not limited to OFF to ON change)
Contents of register
Flag
S1>n S1=n S1<n
09000 075
075
Zero 07357
Carry 07356
0 1 0
0 0 1
2
Compare
3
Octal 00111101 constant 075 0 7 5
Error Non-carry 07354 07355
0 0 0
01010011 1
Contents Unchanged of S1 After operation
Fc12 09000 CMP
When the input condition 04001 is ON, the contents of the register 09000 are compared with the octal constant 075 and its results are set in the non-carry flag (07354), carry flag (07356), and zero flag (07357). The contents of the register 09000 remain unchanged after this operation.
Range of "n" 000 to 377(8) Condition
Instruction 04001
〔Example for use〕
1 1 0
Zero
Carry
Error
Non-carry
07357
07356
07355
07354
0
0
0
1
Similarity instructions: F-12, F-12w, Fc12w
9 Reference Use an octal number in writing program with the Fc12 instruction. Octal number can express any bit pattern and it does not require annoying weight calculation. To compare with a BCD constant, convert it to an octal notation
7 9 Represents 79 in the 0 1 1 1 1 0 0 1 BCD notation.
1 7 1 Represents 171 in the 0 1 1 1 1 0 0 1 octal notation.
9-47
Page 123
Fc12w CMP Symbol
Compare register with constant (1 word) (CoMPare) Fc12w CMP
S1
〔Example for use〕 n
Function
The word contents of the registers S1 and S1+1 are compared with an octal constant "n".
Operation
S1, S1+1<=>n→Flag
Range of S1
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
02000
Fc12w 09000 012345 CMP
09001
After operation
9
Flag
S1, S1+1>n S1, S1+1=n S1, S1+1<n
0 1 0
09000
0000100101110111
When the input signal is ON (not limited to OFF to ON change)
Contents of S1, S1+1 Unchanged Contents of Zero Register 07357
09000 012345
When the input condition 02000 is ON, the word contents of the registers 09000 and 09001 are compared with the octal constant 012345 and its results are set in the non-carry flag (07354), carry flag (07356), and zero flag (07357). The contents of the registers 09000, 09001 remain unchanged. Operation takes place in the same timing as F-12w.
Range of "n" 000000 to 177777(8) Condition
Instruction 02000
STR F-12w
0
0
4
5
6
7
Compare
Octal constant 012345 0001010011100101
Carry 07356
0 0 1
0
Error Non-carry 07355 07354
0 0 0
Zero 07357 0
1 1 0
Note 1: Be sure to use even addresses for register S1. Similarity instructions: F-12, F-12w, Fc12
1
2
Carry 07356 1
3
4
5
Error 07355 0
Non-carry 07354 0
Reference If the Fc12w instruction is used in succession, 4 bytes or more data comparison may be done.
00000
Fc12w 19000 033445 CMP
Fc12w 19002 167532 CMP
9-48
Instruction 00000 STR Fc12w 19000 033445 Fc12w 19002 167532
Page 124
F-13 AND Symbol
AND register with register (1 byte) (AND) F-13 AND
S
D
Function
The contents of the register S (8 bits) are ANDed with the contents of the register D (8 bits) and its result is stored in the register D.
Operation
S∩D→D
Range of S
Range of D
Instruction 04002
〔Example for use〕
STR F-13 04002
F-13 AND
09000
09000 09002
09002
When the input condition 04002 changes from OFF to ON, the 8 bits contents of the register 09000 are ANDed with the 8 bits contents of the register 09002 and its result is stored in the register 09002. The contents of the register 09000 remain unchanged.
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777 コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
Before operation
After operation -ditto-
09000 0 1 0 1 0 0 1 1
09002 1 0 1 1 1 0 0 1
Condition
Rising edge of input signal (OFF to ON)
After operation
Contents Unchanged of S Contents Result of D
0 0 0 1 0 0 0 1 09002
AND truth table Symbol A C B
Flag
09000
AND
Unchanged
A 0 1 0 1
B 0 0 1 1
C 0 0 0 1
9
Similarity instructions: F-13w, Fc13, Fc13w
F-13w AND Symbol
AND register with register (1 word) (AND) F-13w AND
S
〔Example for use〕
D
Function
The 16 bits contents of the registers S, S+1 are ANDed with the 16 bits contents of the registers D, D+1 and its result is stored in the registers D, D+1.
Operation
S, S+1∩D, D+1→D, D+1
After operation
04000
F-13w 09000 09002 AND
09000 09002
When the input condition 04000 changes from OFF to ON, the 16 bits contents of the registers 09000 and 09001 are ANDed with the 16 bits contents of the registers 09002 and 09003 and its result is stored in the registers 09002 and 09003. The contents of the registers 09000 and 09001 remain unchaged.
コ0000 to コ1576 b0000 to b0776 to 09776 Range of S 09000 19000 to 19776 29000 to 29776 39000 to 39776 コ0000 to コ1576 b0000 to b0776 09000 to 09776 Range of D 19000 to 19776 29000 to 29776 39000 to 39776
Condition
Instruction 04000
STR F-13w
09001
09000
0101100101011101 AND
Before operation
Rising edge of input signal (OFF to ON)
09002
1101010010100110
Contents of S, S+1
Unchanged
Contents of D, D+1
Result
Flag
09003
09003 After operation
Unchanged
Note 1: Be sure to use even addresses for registers S and D. Similarity instructions: F-13, Fc13, Fc13w
9-49
09002
0101000000000100
Page 125
Fc13 AND Symbol
AND register with constant (1 byte) (AND) Fc13 AND n
D
Function
An octal constant "n" is ANDed with the contents of the register D and its result is stored in the register D.
Operation n∩D→D
04001
Condition
Fc13 AND
123
STR Fc13
コ0000 to コ1577 b0000 to b0777 09000 to 09777 19000 to 19777 29000 to 29777 39000 to 39777
Before operation 09002 1 0 1 0 1 0 1 0
0 0 0 0 0 0 1 0 09002
1 2 3 Octal constant 0 1 0 1 0 0 1 1 (123)
Rising edge of input signal (OFF to ON)
AND truth table
Contents Result of D
Flag
After operation
AND
Symbol
After operation
123 09002
09002
When the input condition 04001 changes from OFF to ON, the octal constant 123 is ANDed with the contents of the register 09002 and its result is stored in the register 09002.
Range of "n" 000 to 377(8)
Range of D
Instruction 04001
〔Example for use〕
A C B
Unchanged
A 0 1 0 1
B 0 0 1 1
C 0 0 0 1
Similarity instructions: F-13, F-13w, Fc13w
9
Fc13w AND Symbol
AND register with constant (1 word) (AND) Fc13w AND n
〔Example for use〕
D
Function
An octal constant "n" is ANDed with the 16 bits contents of the registers D and D+1 and its result is stored in the registers D and D+1.
Operation n∩D, D+1→D, D+1
Range of "n"
000000 to177777(8)
Range of D
コ0000 to コ1576 b0000 to b0776 09000 to 09776 19000 to 19776 29000 to 29776 39000 to 39776
Condition After operation
Rising edge of input signal (OFF to ON) Contents of D, D+1
Flag
04001
Fc13w 026562 コ0040 AND
026562 コ0040
When the input condition 04001 changes from OFF to ON, the octal constant 026562 is ANDed with the16 bits contents of the registers コ0040 and コ0041 and its result is stored in the registers コ0040 and コ0041. Octal constant 026562 0010110101110010
0
2
6
コ0041
5
6
2
コ0040
Before operation
1001100011001000
After operation
0000100001000000
Result Unchanged
Instruction 04001
STR Fc13w
コ0041
Note 1: Be sure to use even addresses for registers D. Similarity instructions: F-13, F-13w, Fc13
9-50
コ0040
AND