问题
I want to be able to determine the port register for an inline asm function at runtime
asm(""::"I" (_SFR_IO_ADDR(PORTD)));
_SFR_IO_ADDR
only accepts a constant
I have found these options but can't seem to pass register from variable.
asm(""::"m" (PORTD));
asm(""::"n" (&PORTD));
Thought this would be a common issue/request but can't seem to find any answers
回答1:
The AVR IN instruction only supports immediate port number. You might want to try memory mapped access instead, if available. – Jester
来源:https://stackoverflow.com/questions/27581533/avr-gcc-inline-asm-variable-input-operand