1

Hi i am working on Tmote sky motes (MSP430 microprocessor) with contiki os. I want to know the number of instruction cycles used when I do a multiplication operation in my programming (software).

Thank you, Avijit

aviian7
  • 55
  • 6
  • For what type of data, integers or floats? – Ross Feb 20 '15 at 18:10
  • Hi, it is for unsigned integers only. also will it matter if the integer is 8 bit or 16 or 32 bit?. as i have result (32bit) = x (32bit) * y(8bit) * z(8bit). – aviian7 Feb 20 '15 at 18:37
  • That depends on if and how the compiler uses the hardware multiplier. Show the assembler code. – CL. Feb 20 '15 at 19:06

2 Answers2

0

The msp430 is a 16-bit system, so 32-bit values are not supported directly. A 32-bit operation is typically translated to assembly code as a sequence of 16-bit ops.

The execution times of 8-bit and 16-bit operations can be found in TI application report "The MSP430Hardware Multiplier":

Table 4. CPU Cycles Needed With Different Multiplication Modes

OPERATION: Unsigned Multiply (MPY)
SOFTWARE LOOP: 139...171
HARDWARE MPYer: 8
SPEED INCREASE: 17.4...21.4

OPERATION: Unsigned multiply-and-accumulate (MAC)
SOFTWARE LOOP: 137...169
HARDWARE MPYer: 8
SPEED INCREASE: 17.1...21.1

OPERATION: Signed Multiply (MPYS)
SOFTWARE LOOP: 145...179
HARDWARE MPYer: 8
SPEED INCREASE: 18.1...22.4

OPERATION: Signed multiply-and-accumulate (MAC)
SOFTWARE LOOP: 143...177
HARDWARE MPYer: 17
SPEED INCREASE: 8.4...10.4

The HW multiplier should be active with default compilation settings, but check the generated object file with msp430-objdump to make sure.

kfx
  • 8,136
  • 3
  • 28
  • 52
0

You can use naken_asm by Michael Kohn to disaemble an Intel hex or ELF file and it will calculate the cycle counts for each instruction. I've used it in the past and the cycle counter is OK for CPU (such as in your Tmote) but not fully supported in CPUX.

You can invoke it from the command line as simply as:

naken_util -disasm <infile>

where <infile> is the name of your hex or ELF file. The default processor is MSP430, but you'd need the assembly listing from your compiler in order to be able to match up the original code with the disassembled code which includes cycle counts.

Another alternative would be to use MSPDebug's tracer option which can track running software and provide an up-to-date instruction cycle count. However, I've never used it for that purpose so cannot provide an example.

tinman
  • 6,348
  • 1
  • 30
  • 43
  • From the source at `https://github.com/mikeakohn/naken_asm/blob/master/disasm/msp430.c` it does not look like that it handles arithmetical operations. Interesting nevertheless. – kfx Mar 08 '15 at 08:50
  • @kfx: I think it does handle them. I've used it in the past and don't remember it missing arithmetic instructions. You need to look at the code as well as [https://github.com/mikeakohn/naken_asm/blob/master/table/msp430.c](https://github.com/mikeakohn/naken_asm/blob/master/table/msp430.c) but for example an `ADD.w R6,R7` _should_ be handled by disasm_msp430()'s `case OP_TWO_OPERAND`. Only special instructions are handled directly in the source you linked to. – tinman Mar 09 '15 at 11:45