AnsweredAssumed Answered

Benchmark.asm

Question asked by Sisik2205 on Feb 7, 2013
Latest reply on Feb 8, 2013 by CraigG

Hello everyone, one last question from me.

 

I've actually tried to understand (I'm a newbie, yes) the benchmark.asm program used to count cycles in a program. So I think I understand most of them, but there is one thing I'm uncertain off. First of all the code:

 

#include "def21160.h"

#include "asm_sprt.h"

 

 

.section/pm seg_pmco;

.global _count_start;

.global _count_end;

 

_count_start: /* call this to start cycle count */

r1=mode1;

bit clr mode1 IRPTEN;

r0=emuclk;

mode1=r1;

exit;

_count_start.end:

 

_count_end: /* call this to end cycle count */

r2=mode1;

bit clr mode1 IRPTEN;

r0=emuclk;

r0=r0-r4;

r1=14;     /* fudge factor to compensate for overhead */

r0=r0-r1; 

mode1=r2;

exit;

_count_end.end:

 

And now my question. In the first part when we start the count, we use r0 register to read the data from emuclk register. And in the second one when we read the data again we also use the r0 register. But then this line is confusing me r0=r0-r4 ... since we haven't used r4 register anywhere in the code. So I thought it was a mistake and tried to change firstly used register r0 to r4, but then the cycle count got really, really big and in my program it seemed like a mistake. I would be really glad if someone were to tell me how does this program work. Thanks in advance!

 

Regards,

Bartosz

Outcomes