MCMP32 MRa, MRb
32-Bit Integer Compare for Equal, Less Than or Greater Than
Operands
MRa
CLA floating-point source register (MR0 to MR3)
MRb
CLA floating-point source register (MR0 to MR3)
Opcode
LSW: 0000 0000 0000 bbaa
MSW: 0111 1111 0010 0000
Description
Set ZF and NF flags on the result of MRa - MRb where MRa and MRb are 32-bit integers.
For a floating point compare refer to
Note
A known hardware issue exists in the MCMP32 instruction. Signed integer
comparisons using MCMP32 by itself will set the status bits in a way that
is not useful for comparison when the difference between the two operands
is too large, such as when the inputs have opposite sign and are near the
extreme 32-bit signed values. This affects both signed and unsigned integer
comparisons.
The compiler (version 18.1.5.LTS or higher) has implemented a workaround for
this issue. The compiler checks the upper bits of the operands by performing
a floating point comparison before proceeding to do the integer comparison or
subtraction.
The compiler flag --cla_signed_compare_workaround enables this workaround.
Flags
This instruction modifies the following flags in the MSTF register:
Flag
TF
ZF
NF
LUF
LVF
Modified
No
Yes
Yes
No
No
The MSTF register flags are modified based on the integer results of the operation.
If(MRa == MRb) {ZF=1; NF=0;}
If(MRa > MRb) {ZF=0; NF=0;}
If(MRa < MRb) {ZF=0; NF=1;}
Pipeline
This is a single-cycle instruction.
Example
; Behavior of ZF and NF flags for different comparisons
;
; Given A = (int32)1
; B = (int32)2
; C = (int32)-7
;
MMOV32 MR0, @_A ; MR0 = 1 (0x00000001)
MMOV32 MR1, @_B ; MR1 = 2 (0x00000002)
MMOV32 MR2, @_C ; MR2 = -7 (0xFFFFFFF9)
MCMP32 MR2, MR2 ; NF = 0, ZF = 1
MCMP32 MR0, MR1 ; NF = 1, ZF = 0
MCMP32 MR1, MR0 ; NF = 0, ZF = 0
See also
Control Law Accelerator (CLA)
614
TMS320x2806x Microcontrollers
SPRUH18I – JANUARY 2011 – REVISED JUNE 2022
Copyright © 2022 Texas Instruments Incorporated
Summary of Contents for TMS320 2806 Series
Page 2: ......