DSPRelated.com
Forums

conditional jump problem

Started by carr...@hotmail.com April 14, 2009
Hi all,

I am using the Soundbite development board, with DSP56371 chip. I'm using the Symphony Studio, to write the code and to debug.

I am having trouble with this piece of code, I wrote:

...
CLR a
CMP x0,a ; (0-x0)

JMI label ; jump to label if x0 is positive, else just go to next operation

...

label:
...
For the conditional jump, I use "JMI label" (Jump if Minus) .

So, there has to be jumped if there is generated a minus-sign with the previous ALU operation, no? (so if the "zero-bit" in the Status Reg is set)

But, when I debug, they always jump to "label". Also, when the zero-bit is not set. (In the debugger I can see that the zero-bit always get set correct.)

I don't get this.

Is there something that I'm interpreting wrong?

Please help me out. I have been trying to find my mistake for days and days.

Thanks...
--- In m..., carrejans@... wrote:
>
> Hi all,
>
>
>
> I am using the Soundbite development board, with DSP56371 chip. I'm using the Symphony Studio, to write the code and to debug.
>
> I am having trouble with this piece of code, I wrote:
>
>
> ...
> CLR a
> CMP x0,a ; (0-x0)
>
> JMI label ; jump to label if x0 is positive, else just go to next operation
>
> ...
>
> label:
> ...
> For the conditional jump, I use "JMI label" (Jump if Minus) .
>
> So, there has to be jumped if there is generated a minus-sign with the previous ALU operation, no? (so if the "zero-bit" in the Status Reg is set)
>
> But, when I debug, they always jump to "label". Also, when the zero-bit is not set. (In the debugger I can see that the zero-bit always get set correct.)
>
> I don't get this.
>
> Is there something that I'm interpreting wrong?
>
> Please help me out. I have been trying to find my mistake for days and days.
>
>
>
> Thanks...
>
Hi,

I tested that code in the SIM56300 (an old simulator) and it worked as expected.

1)x0>0: jump to label
clr a
move #>$400000,x0 ;x0=+0,5
cmp x0,a
jmi label
;x0<=0

--------
label:
;x0>0

CCR=0x19 N=0 Z=0
2)x0<0: go to next operation
clr a
move #>$C00000,x0 ;x0=-0,5
cmp x0,a
jmi label
;x0<=0

--------
label:
;x0>0

CCR=0x01 N=1 Z=0

3)x0=0: go to next operation
clr a
move #>$0,x0 ;x0=0
cmp x0,a
jmi label
;x0<=0

--------
label:
;x0>0

CCR=0x14 N=0 Z=1

Hope this helps,
Pablo
Hi,

the jmi instruction is used correctly in your case.

Please insert a 'debug' instruction into a new code line where you want to read the registers. The code is stopped then and all registers are read into the debugger software correctly. If the code behaves strangely please ask again. In that case please forward the complete code snippet to enable me to test it properly.

On the other hand stopping the code from the debugger software sometimes may lead to 'unexpected' behaviour caused by interfering interrupts especially caused by the serial audio interfaces (those interrups have the highest probability in an audio system).

The best measure to test new code snippets is just using the simulator instead running it on hardware firstly for that reason, you have no side effects from interrupted code here.

Best regards

Christian

> Hi all,
>
>
>
> I am using the Soundbite development board, with DSP56371 chip. I'm using
> the Symphony Studio, to write the code and to debug.
>
> I am having trouble with this piece of code, I wrote:
>
>
> ...
> CLR a
> CMP x0,a ; (0-x0)
>
> JMI label ; jump to label if x0 is positive, else just go to next
> operation
>
> ...
>
> label:
> ...
> For the conditional jump, I use "JMI label" (Jump if Minus) .
>
> So, there has to be jumped if there is generated a minus-sign with the
> previous ALU operation, no? (so if the "zero-bit" in the Status Reg is set)
>
> But, when I debug, they always jump to "label". Also, when the zero-bit is
> not set. (In the debugger I can see that the zero-bit always get set
> correct.)
>
> I don't get this.
>
> Is there something that I'm interpreting wrong?
>
> Please help me out. I have been trying to find my mistake for days and
> days.
>
>
>
> Thanks...
c...@hotmail.com wrote:

> Hi all,
>
> I am using the Soundbite development board, with DSP56371 chip. I'm
> using the Symphony Studio, to write the code and to debug.
>
> I am having trouble with this piece of code, I wrote:
>
> ...
> CLR a
> CMP x0,a ; (0-x0)
>
> JMI label ; jump to label if x0 is positive, else just go to next operation
>
> ...
>
> label:
> ...
>
> For the conditional jump, I use "JMI label" (Jump if Minus) .
>
> So, there has to be jumped if there is generated a minus-sign with the
> previous ALU operation, no? (so if the "zero-bit" in the Status Reg is set)
>
> But, when I debug, they always jump to "label". Also, when the zero-bit
> is not set. (In the debugger I can see that the zero-bit always get set
> correct.)
>
> I don't get this.
>
> Is there something that I'm interpreting wrong?

I'm not familiar with the 56371 architecture, but usually "JMI" checks the
negative "N" flag, not the zero "Z" flag.

Regards,
-- Carlo.
Hi all,

Checked on the simulator, correct usage should like below:
move x0,a
tst a
jmi label
Johnny

Hi all,
>
>I am using the Soundbite development board, with DSP56371 chip. I'm using the Symphony Studio, to write the code and to debug.
>
>I am having trouble with this piece of code, I wrote:
>
>...
>CLR a
>CMP x0,a ; (0-x0)
>
>JMI label ; jump to label if x0 is positive, else just go to next operation
>
>...
>
>label:
>...
>For the conditional jump, I use "JMI label" (Jump if Minus) .
>
>So, there has to be jumped if there is generated a minus-sign with the previous ALU operation, no? (so if the "zero-bit" in the Status Reg is set)
>
>But, when I debug, they always jump to "label". Also, when the zero-bit is not set. (In the debugger I can see that the zero-bit always get set correct.)
>
>I don't get this.
>
>Is there something that I'm interpreting wrong?
>
>Please help me out. I have been trying to find my mistake for days and days.
>
>Thanks...