创客百科

姿势共享,有节操无门槛参与的创客百科,创客动力之源 \ (^_^) /

用户工具

站点工具


arduino:avrgcc:lpm_word_enhanced

__LPM_word_enhanced__()

Abstarct

The __LPM_enhanced() is an assembler code that reads a word of data stored in a specified address(PROGMEM area).

Source Code

The __LPM_word_enhanced() is defined in hardware/tools/avr/avr/include/avr/pgmspace.h as below.

#define __LPM_word_enhanced__(addr)         \
(__extension__({                            \
    uint16_t __addr16 = (uint16_t)(addr);   \
    uint16_t __result;                      \
    __asm__                                 \
    (                                       \
        "lpm %A0, Z+"   "\n\t"              \
        "lpm %B0, Z"    "\n\t"              \
        : "=r" (__result), "=z" (__addr16)  \
        : "1" (__addr16)                    \
    );                                      \
    __result;                               \
}))

The lpm, short for Load Program Memory, is a instruction that reads a byte of data from PROGMEM area. In this macro, the lpm instruction is called twice to get two bytes of data. It substitue a data at addr for __result, then returns the __result.

本页面的其他翻译:
arduino/avrgcc/lpm_word_enhanced.txt · 最后更改: 2016/12/25 22:15 (外部编辑)