1

In a university lab, we are using a TI6713 processor for signal processing purposes. I have often found myself in a position where I need to do an action based on a flag bit located in one of the 32-bit registers. Some of these flags trigger interrupts when they are changed, whereas some do not.

So far I have been able to do my work by shifting left and right till the bit of interest is the least significant and sign extended. For example:

SHL A0, 14, A0 ;Shift the 17th bit 14 times left
SHR A0, 31, A0 ;Shift the bit 31 times right
[A0] B LOOP ;Branch if it's not 0

where A0 contains the flag bit 17. The problem with this is that I need to alter the register, or use more registers (which might already be in use). Also the amount of shifting I have to do has to be calculated, and although it's fairly straightforward, I'm usually in no state of mind to perform it. The instruction guide is vast, and so far I have not been able to find an instruction that fits my needs.

Is there a better/more robust way to perform this task?

VlassisFo
  • 650
  • 1
  • 8
  • 26

1 Answers1

2

I'm totally new to the TMS320C6713x and its VelociTI architecture but usually DSP have instructions to handle bit fields.
In this case I've found these one:

  • ext extracts a bit field and sign extends it in a 32-bit register.
  • extu same as above but zero extends it.
  • clr clear a bit field.
  • set set a bit field.

The ext/u instructions work exactly like your code (a left shift followed by a right shift) to the point that the immediate operands are the same.

A possible code to extract the bit 17 (note that bit 17 is the 18th bit) could be:

EXT A0, 14, 31, A0
[A0] B LOOP

Note this code is untested.

CLR and SET can be useful to clear and set a set of bits respectively.
The operand are more straightforward then the ext/u ones, they are the LSb and the MSb (both inclusive) of the bit field.

CLR A0, 0, 3, A0   ;Clear the lowest nibble of A0
SET A0, 4, 7, A0   ;Set the high nibble of the lowest byte of A0

As suggested in the comment an AND will also do but if I've understood the datasheet correctly you can only use a register-register or a register-immediate AND, where the immediate is 5 bits.
So for extracting bits above bit 4 you need to pre-load a register.

Margaret Bloom
  • 41,768
  • 5
  • 78
  • 124