If J31 is a status register which is changed when doing COMP(J4, J5)
Howcome the VDSP compiler uses it as having a zero value as in the code
XR4 = [J31 + _startbuff];;
I was not sure of the answer of this so I went searching in the hardware manual for an explanation -- and found this -- page 94
The JSTAT (for the J-IALU) and KSTAT (for the K-IALU) status registers records the state of the ALU flags and is updated as a result of various IALU DAG (data address generator) instructions.
-- meaning -- JSTAT (J31) changes (was last result zero (JZ set) , negative (JN set), caused a carry (JC set -- unsigned result too big to fit into 32 bits) or caused an overflow (JV set -- signed result too big to fit into 32 bits) )
When being written to, the JSTAT register can be referred to as J31. When used as an operand in an IALU arithmetic, logical, or function operation—J31 is treated as zero. The J31/JSTAT (K31/KSTAT ) registers (reset value = 0x0000 0000) appear in Figure 2-5. For information on using the J31/JSTAT (K31/KSTAT ) registers, see the “IALU” chapter of the ADSP-TS201 TigerSHARC Processor Programming Reference.
Which I intreprete as
XR1 = [J1 + J31];; J31 acts as a zero
J1 = J2 + J31;; J31 acts as a zero
J1 = J31;; then J31 acts as JSTAT and provides a copy of the flags JZ, JN JV and JC in lower 4 bits into J1 for later use
The programming manual says this on page 242
The JSTAT (J31) and KSTAT (K31) registers appears in Figure 7-2. These registers have special operations:• When used as an operand in an IALU arithmetic, logical, or function operation, these registers are referred to as J31 and K31 registers, and the register’s contents are treated as zero. If J31 is used as an output of an operation, it does not retain the result of the instruction, but the flags are set.
which I interprete as this
and the extra detail
J4 = 6;; J5 = 6;;
J31 = J4 - J5;; // This sets the JZ flag since 6 -6 = 0; (J31 = 1 (as JZ is bit 0) with J31 acting as JSTAT))
IF JEQ. JUMP XXXX; -- JEQ is a bit in JSTAT
so this instruction is actually IF (JZ bit is JSTAT is set), JUMP XXX
will cause a jump in the same way as
IF JEQ. JUMP XXXX; does
Very loosely you think that we have the following assembler directive defined
#define COMP(A, B) J31 = A - B
meaning that COMP(J4, 6);; is the same as J31 = J4 - 6;;
• When used for an IALU load, store, or move operation (as a sourceor destination, not as a pointer), these registers are referred to asJSTAT and KSTAT, and the operation does not clear the registercontents.
[J1 += 1] = J31;; Now J31 (acts as JSTATUS) stores the values of the status register for later use -- it does not store
Hope that helps
Retrieving data ...