inline asm get pin states pin 0 to 7
Hello
How to get pin states from pin 0 to 7 ,
in simple ide c inline asm.
I found this on the net
Is this for one pin or can i also use it for mutliple pin's.
kind regards.
How to get pin states from pin 0 to 7 ,
in simple ide c inline asm.
I found this on the net
Is this for one pin or can i also use it for mutliple pin's.
static __inline__ int getpin(int pin)
{
uint32_t value[COLOR=#666600];
[/COLOR]__asm__ [COLOR=#000088]volatile[/COLOR] [COLOR=#666600](
[/COLOR] "getp %[_pin] wc\n\t"
"mov %[_value], #0\n\t"
"rcl %[_value], #1"
: /* outputs */
[_value] "=r" (value)
: /* inputs */
[_pin] "r" (pin)
: /* no clobbered registers */
);
return value;
}
kind regards.

Comments
I wrote a new code.
i don't know it works.
__asm__( "mov r8, #0xff\n\t" "shl r20, #0xff\n\t" "andn outa, r20\n\t" "mov %[_value], ina wc\n\t" : /* outputs */ [_value] "=r" (value) : /* inputs */ : /* no clobbered registers */ );Hope this wil work
I try it out in the morning it's past midnight over here.
good night.
As usual down to the point. I love it.
If life ever brings me down to Japan - I hope I can meet you.
Enjoy!
Mike
I try it, but i am very critical in time.
Thanks
Mart
In PASM you'd do the following: with the mask insn being optional when you write the byte to hub anyway (wrbyte does that for you). The C example I gave compiles down to the same sequence. IOW there is no need to go near inline assembly (for something as simple as this).
result = INA & 0xFF;
Works for me