Thanks Chris!
that's nice! "critical" actually generates 2 bytes less and it doesn't
make use of a register.
most of my routines will benefit from this!
However, if a routine is _really_ time critical and you have a
register to spare (I only have two such creatures ), that macro will
be more efficient:
instruction ---> cycles
mov r2, r14 ---> 1
dint ---> 1
and #8, r14 ---> 1 (this also saves us the nop instruction)
...
bis r14, SR ---> 1
ret ---> 3
which is a total of 7 cycles (without stack usage), while "critical"
generates the following:
push r2 ---> 3
dint ---> 1
nop ---> 1
...
reti ---> 5
which is a total of 10 cycles (with 2 bytes stack).
Roberto
2005/11/15, Chris Liechti <[email protected]>:
> Roberto Padovani schrieb:
> > Ok. Then I'll add another def to my own collection. I think it's quite
> > useful to have something like:
> >
> > __BIS_SR_reg2reg(x) __asm__ __volatile__( "bis %0, r2" : : "r"
> > ((uint16_t)x) );
> >
> > for example i use it in routines that cannot be interrupted, this way:
> >
> > int_status = READ_SR & GIE; // read status register and mask GIE
> > dint(); // ensure this
> > routine in unninterruptible
> > ...
> > ...stuff...
> > ...
> > __BIS_SR_reg2reg(int_status) // = eint() if irqs were enabled
> >
> > so that the interrupt status is unaltered at the end of the routine
> > and no test and jump is required.
>
> you could also use the "critical" function attribute that is provided by
> mspgcc (which generates less code that your solution)
>
> crititcal void some_function_with_disabled_interrupts(void) {}
>
> chris
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
> Register for a JBoss Training Course. Free Certification Exam
> for All Training Attendees Through End of 2005. For more info visit:
> http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>