MEM_VAL_SET_xxx()

These macros encode data values to any CPU memory address.

Files

lib_mem.h

Prototypes

          MEM_VAL_SET_INT08U_BIG(addr);
          MEM_VAL_SET_INT16U_BIG(addr);
          MEM_VAL_SET_INT32U_BIG(addr);
           
          MEM_VAL_SET_INT08U_LITTLE(addr);
          MEM_VAL_SET_INT16U_LITTLE(addr);
          MEM_VAL_SET_INT32U_LITTLE(addr);
           
          MEM_VAL_SET_INT08U(addr);
          MEM_VAL_SET_INT16U(addr);
          MEM_VAL_SET_INT32U(addr);


Arguments

addr

Lowest CPU memory address to encode the data value.

val

Data value to encode.

Returned Value

None.

Required Configuration

None.

Notes / Warnings

CPU memory addresses/pointers not checked for NULL.

Encode data values based on the values’ data-word order in CPU memory:

MEM_VAL_SET_xxx_BIG()

Encode big-endian data values — data words’ most significant octet at lowest memory address

MEM_VAL_SET_xxx_LITTLE()

Encode little-endian data values — data words’ least significant octet at lowest memory address

MEM_VAL_SET_xxx()

Encode data values using CPU’s native or configured data-word order

MEM_VAL_SET_xxx() macros encode data values without regard to CPU word-aligned addresses. Thus for processors that require data word alignment, data words can be encoded to any CPU address, word-aligned or not, without generating data-word-alignment exceptions/faults. However, val data value to encode must start on appropriate CPU word-aligned address.

MEM_VAL_COPY_SET_xxx() macros are more efficient than MEM_VAL_SET_xxx() macros and are also fully independent of CPU data-word-alignment and should be used whenever possible.

MEM_VAL_SET_xxx() macros are not atomic operations and must not be used on any non-static (i.e., volatile) variables, registers, hardware, etc.; without the caller of the macros providing some form of additional protection (e.g. mutual exclusion).

Example Usage

          CPU_INT08U  *pval;
          CPU_INT16U   val;


          pval = &SomeAddr;              /* Any CPU address */
          val =  0xABCDu;
          MEM_VAL_SET_INT16U(pval, val);