www.ti.com
Instructions
CMPF32 RaH, #16FHi
32-bit Floating-Point Compare for Equal, Less Than or Greater Than
Operands
RaH
floating-point source register (R0H to R7H)
#16FHi
A 16-bit immediate value that represents the upper 16-bits of an IEEE 32-bit
floating-point value. The low 16-bits of the mantissa are assumed to be all 0.
Opcode
LSW: 1110 1000
0001 0III
MSW: IIII IIII
IIII Iaaa
Description
Compare the value in RaH with the floating-point value represented by the immediate
operand. Set the ZF and NF flags on (RaH - #16FHi:0).
#16FHi is a 16-bit immediate value that represents the upper 16-bits of an IEEE 32-bit
floating-point value. The low 16-bits of the mantissa are assumed to be all 0. This
addressing mode is most useful for constants where the lowest 16-bits of the mantissa
are 0. Some examples are 2.0 (0x40000000), 4.0 (0x40800000), 0.5 (0x3F000000), and
-1.5 (0xBFC00000). The assembler will accept either a hex or float as the immediate
value. That is, -1.5 can be represented as #-1.5 or #0xBFC0.
The CMPF32 instruction is performed as a logical compare operation. This is possible
because of the IEEE floating-point format offsets the exponent. Basically the bigger the
binary number, the bigger the floating-point value.
Special cases for inputs:
•
Negative zero will be treated as positive zero.
•
Denormalized value will be treated as positive zero.
•
Not-a-Number (NaN) will be treated as infinity.
Flags
This instruction modifies the following flags in the STF register:
Flag
TF
ZI
NI
ZF
NF
LUF
LVF
Modified
No
No
No
Yes
Yes
No
No
The STF register flags are modified as follows:
If(RaH == #16FHi:0) {ZF=1, NF=0}
If(RaH >
#16FHi:0) {ZF=0, NF=0}
If(RaH <
#16FHi:0) {ZF=0, NF=1}
Pipeline
This is a single-cycle instruction
Example
; Behavior of ZF and NF flags for different comparisons
MOVIZF32
R1H, #-2.0
; R1H = -2.0 (0xC0000000)
MOVIZF32
R0H, #5.0
; R0H =
5.0 (0x40A00000)
CMPF32
R1H, #-2.2
; ZF = 0, NF = 0
CMPF32
R0H, #6.5
; ZF = 0, NF = 1
CMPF32
R0H, #5.0
; ZF = 1, NF = 0
; Using the result of a compare for loop control
Loop:
MOV32
R1H,*XAR3++
; Load R1H
CMPF32
R1H, #2.0
; Set/clear ZF and NF
MOVST0
ZF, NF
; Copy ZF and NF to ST0 Z and N bits
BF
Loop, GT
; Loop if R1H > #2.0
See also
SPRUEO2A – June 2007 – Revised August 2008
Instruction Set
45
Содержание TMS320C28 series
Страница 2: ...2 SPRUEO2A June 2007 Revised August 2008 Submit Documentation Feedback ...
Страница 12: ...Introduction 12 SPRUEO2A June 2007 Revised August 2008 Submit Documentation Feedback ...
Страница 20: ...CPU Register Set 20 SPRUEO2A June 2007 Revised August 2008 Submit Documentation Feedback ...
Страница 136: ...Instruction Set 136 SPRUEO2A June 2007 Revised August 2008 Submit Documentation Feedback ...