6F3B0253
7. Instructions
FUN 182
NEG
2’s complement
Expression
Input − [ A NEG B ]− Output
Function
When the input is ON, this instruction finds the 2’s complement value of A, and stores it in B.
Execution condition
Input |
| Operation | Output |
OFF | No execution |
| OFF |
ON | Execution |
| ON |
Operand
| Name |
|
| Device |
|
|
|
|
|
|
|
| Register |
|
|
|
|
| Constant | Index | ||
|
| X | Y | R | S | T. | C. | XW | YW | RW | SW | T | C | D | I |
| J | K |
|
| ||
A | Source |
|
|
|
|
|
| √ | √ | √ | √ |
| √ | √ | √ | √ | √ | √ |
| √ |
|
|
B | Destination |
|
|
|
|
|
|
| √ |
| √ | √ | √ | √ | √ | √ | √ |
| √ |
|
|
|
Example
When X007 is ON, the 2’s complement value (sign inverted data) of RW39 is stored in D0122. For example, if RW38 is 4660, the 2’s complement value
2’s complement data is calculated as follows.
| F E D C B A 9 8 7 6 5 4 3 2 1 0 | |||||||||||||||
RW39 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 |
|
|
|
|
|
|
|
|
| Bit inverse |
|
|
|
| |||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 |
|
|
|
|
|
|
|
|
| + 1 |
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
D0122 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
(4660)
Note
•The data range of A is
232