I am coming up to speed on a project that uses a DSP 56303. The project is written completely in assembly, an old project.
I am looking at code that has to do with testing and branching. The DSP Family Manual is a bit unclear to me on a few instructions.
If I have
btst #M_PD5,X:<<M_PDRC
bcc _elsewhere
What value does bit M_PD5 have for the code to branch to '_elsewhere', 0 or 1?
If I have the following
btst #M_PD5,X:<<M_PDRC
bcs _elsewhere
this is branching on the opposite state of bit M_PD5 as the code above, correct?
解決済! 解決策の投稿を見る。
Hi, Keith,
Maybe I did not elaborate it clearly. Firstly, the following assembly instruction "btst" only polls a bit in memory or register, and copy the bit logic to Carry bit in CCR register. for example the following instruction:
btst | #M_PD5,X:<<M_PDRC |
If the #M_PD5 bit is set, the C bit(bit 0 in CCR register) is set in CCR after the btst instruction, if the #M_PD5 bit is cleared, the C bit in CCR is cleared after the instruction. Note that the btst only polls the bit and take effect on the carry bit in CCR, it does not clear or set the bit in memory or register.
The bcc executes the jump based on the Carry bit in CCR register. For the instruction bcc _elsewhere, if the Carry bit in CCR register is cleared, the code beginning with _elsewhere is executed, if the Carry bit is set, the next instruction will be executed.
In conclusion, the btst changes the carry bit in CCR, the bcc instruction will branch based on the carry bit logic in CCR.
Hope it can help you
BR
Xiangjun Rong
Hi,Keith,
Regarding the assembly instruction, pls download the DSP56300 family manual and refer to the instruction.
For the assembly instruction
btst #M_PD5,X:<<M_PDRC
bcc _elsewhere
:
The btst instruction tests the bit specified by the #M_PD5 in the memory location specified by ,X:<<M_PDRC, the "<<" means that the X:M_PDRC address is a short I/O address which ranges from $FFFF80 to $FFFFFF. after the btst instruction, the bit value will change the carry bit(bit 0) in CCR register of the status register.
the bcc means "branch to _elsewhere" if the carry bit is cleared. The bcs instruction means "branch to somewhere" if the carry bit is set.
In conclusion, the btst instruction tests a bit in register and change the carry bit(bit 0) in CCR register, the bcc will branch based on the carry bit in CCR register.
The characters "<<" means it is a short address mode, it means that the btst is a one word instruction.
BR
XiangJun Rong
XiangJun Rong - Yes, I have read the DSP56300 family manual. I have read the paragraph you copied above.
I am still confused about '...the bit value will change the carry bit(bit 0)... bcc means 'branch to _elsewhere' if the carry bit is cleared.'
So...If #M_PD5 is set, and one executes 'btst #M_PD5,X:<<M_PDRC' is the carry bit cleared or set?
Hi, Keith,
Maybe I did not elaborate it clearly. Firstly, the following assembly instruction "btst" only polls a bit in memory or register, and copy the bit logic to Carry bit in CCR register. for example the following instruction:
btst | #M_PD5,X:<<M_PDRC |
If the #M_PD5 bit is set, the C bit(bit 0 in CCR register) is set in CCR after the btst instruction, if the #M_PD5 bit is cleared, the C bit in CCR is cleared after the instruction. Note that the btst only polls the bit and take effect on the carry bit in CCR, it does not clear or set the bit in memory or register.
The bcc executes the jump based on the Carry bit in CCR register. For the instruction bcc _elsewhere, if the Carry bit in CCR register is cleared, the code beginning with _elsewhere is executed, if the Carry bit is set, the next instruction will be executed.
In conclusion, the btst changes the carry bit in CCR, the bcc instruction will branch based on the carry bit logic in CCR.
Hope it can help you
BR
Xiangjun Rong