ST10F280-AB
2/4
2.2 - MAC.9 - CoCMP Instruction I nverted Op erands
The ST10 Family Programming Manual describes the CoCMP instruction as: subtracts a 40-bit signed
operand from th 40-bit accumulator content (acc - op2\op1), and updates the N, Z and C fl ags in the MSW
register, leaving the accumulator unchanged. On the device the reverse operation (op2\op1 - acc) has
been implemented in the Mac Unit. Therefore, the N and C flags are set according to the reverse
operation (Z flag is not affected).
Workaround:
Change interpretation of the N and C flags in the MSW register.
Example:
MO V R12, #07h
MO V R13, #06h
MO V R14, #0
CoLOAD R14, R12 ; Accum ul ator = 70000h
CoCMP R14, R13 ; Compares 70000h to 60000h
Here the content of MSW is 0500h, i.e. C = 1, Z = 0 and N = 1.
To test if the Accumulator was greater t han or equal the c omp ared value, the "normal" test, according t o
the descr i ption in the ST10 Programming Ma nual, would be:
JNB MSW. 10, Greater ; If C flag cleared, then greater than or equal
Wi th the i mplementati on, this test does not provide the ex pected resul t.
To obtain the correct comparison, use instead:
JB MSW.10, Greater ; C flag set: 60000h < 70000h (60000h-70000h implemented)
; i.e. the accumulator is greater than or equal co mpared value
2.3 - MA C.10 - E Flag Ev aluation for CoSHR and C oASHR Instructions when Saturation Mode is Enabled
The Logical and the Arithmet ic Right Shif t ins truc tions (CoS HR/CoASHR) are specifif ed not to be affected
by the saturation mode (MS bit of the MCW register): the shift operation is always made on the 40 bits of
the ac cumulator. The result shifted i n the accumulator i s nev er sat urated. Only when the saturation mode
is enabled, the evaluation of the E Flag (in the MSW register) is erroneous.
Comment to the example:
In the example below (Table 1), t he E F lag is kep t c leared however MAE is used: bi t 0 of MAE has be en
shifted into bit 15 of MAH. The MAE part has been used and it contents significant bits but the E Flag has
not been set .
The content of the flags i s given after t he execution of the instruction.
Workaround:
If the MAE flag is used, the saturation mode must be disabled before running Logical and/or Arihmetic
Right Shift instruction s and re-enable just after.
Table 1 : MA C. 10 Example
MS Bit is Set, Saturation Mode is Enabled Status of Flags After Instruction Execution
Code Accu mulator Value
(Hexa.) SL E SV C Z N Remark
MOV R5, #5555h -- ---- ---- -------
CoLOAD R5, R5 00 5555 5555 000000Right
NOP 00 5555 5555 000000Right
MOV MSW, #007Fh 7F 5555 5555 000000Right
NOP 7F 5555 5555 000000Right
CoSHR #1 3F AAAA AAAA 00*0000*E is wrong