![background image](http://html1.mh-extra.com/html/omron/sysmac-cs1d-cpu/sysmac-cs1d-cpu_reference-manual_742268490.webp)
451
Symbol Math Instructions
Section 3-11
Precautions
When –CL(413) is executed, the Error Flag will turn OFF.
If as a result of the subtraction, the content of R, R+1 is 00000000 hex, the
Equals Flag will turn ON.
If the subtraction results in a borrow, the Carry Flag will turn ON.
If the result of subtracting a negative number and CY from a positive number
is negative (in the range 80000000 to FFFFFFFF hex), the Overflow Flag will
turn ON.
If the result of subtracting a positive number and CY from a negative number
is positive (in the range 00000000 to 7FFFFFFF hex), the Underflow Flag will
turn ON.
If as a result of the subtraction, the content of the leftmost bit of R+1 is 1, the
Negative Flag will turn ON.
Note
To clear the Carry Flag (CY), execute the Clear Carry (CLC(041)) instruction.
Examples
When CIO 000000 is ON in the following example, D00111, D00110 and CY
will be subtracted from D00101 and D00100 as 8-digit signed binary values,
and the result will be output to D00121 and D00120.
If the result of the subtraction is a negative number (Mi<Su or Mi+1, Mi
<Su+1, Su), the result is output as a 2’s complement. The Carry Flag (CY) will
turn ON. To convert the 2’s complement to the true number, a program which
subtracts the result from 0 is necessary, as an input condition of the Carry
Flag (CY). The Carry Flag turning ON thus indicates that the result of the sub-
traction is negative.
Note 2’s Complement
A 2’s complement is the value obtained by subtracting each binary digit from 1
and adding one to the result.
Example:
The 2’s complement for the binary number 1101 is as follows:
1111 (F hex) – 1101 (D hex) + 1 (1 hex) = 0011 (3 hex).
Example:
The 2’s complement for the 4-digit hexadecimal number 3039 is as
follows:
FFFF hex – 3039 hex + 0001 hex = CFC7 hex.
Accordingly, the 2’s complement for the 4-digit hexadecimal value “a” is as fol-
lows:
FFFF hex – a hex + 0001 hex = b hex.
And to obtain the true number “a” hex from the 2’s complement “b” hex:
a hex + 10000 hex – b hex.
Example:
To obtain the true number from the 2’s complement CFC& hex:
10000 hex – CFC7 hex = 3039 hex.
Summary of Contents for SYSMAC CS1D-CPU**
Page 3: ...iv...
Page 29: ...xxx...
Page 185: ...146 List of Instructions by Function Code Section 2 4...
Page 1389: ...1350 CJ series Instruction Execution Times and Number of Steps Section 4 2...
Page 1390: ...1351 Appendix A ASCII Code Table ASCII SP Four leftmost bits Four rightmost bits...
Page 1391: ...1352 ASCII Code Table Appendix A...