Question about DSP 56K Assembly Syntax

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Question about DSP 56K Assembly Syntax

Jump to solution
1,758 Views
Keith4DSmith
Contributor V

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?

Labels (1)
Tags (2)
0 Kudos
1 Solution
1,507 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

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

View solution in original post

0 Kudos
3 Replies
1,507 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,Keith,

Regarding the assembly instruction, pls download the DSP56300 family manual and refer to the instruction.

http://tinyurl.com/qjgst3l


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

0 Kudos
1,507 Views
Keith4DSmith
Contributor V

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?

0 Kudos
1,508 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

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

0 Kudos