__LPM_word_enhanced__()

Abstract

The _LPM_word_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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#define __LPM_word_enhanced__(addr)         \
(__extension__({                            \
    uint16_t __addr16 = (uint16_t)(addr);   \
    uint16_t __result;                      \
    __asm__ __volatile__                    \
    (                                       \
        "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.

Version

7.3.0-atmel3.6.1-arduino7

Last Update

May 15, 2021

inserted by FC2 system