4.7.21.  __ldrt

This intrinsic inserts an assembly language instruction of the form LDR{size}T into the instruction stream generated by the compiler. It enables you to load data from memory in your C or C++ code using an LDRT instruction.

Syntax

unsigned int __ldrt(const volatile void *ptr)

Where:

ptr

Points to the address of the data to be loaded from memory. To specify the size of the data to be loaded, cast the parameter to an appropriate integral type.

Table 4.9. Access widths supported by the __ldrt intrinsic

Instruction[a]Size of data loadedC cast
LDRSBTsigned byte(signed char *)
LDRBTunsigned byte(char *)
LDRSHTsigned half word(signed short int *)
LDRHTunsigned halfword(short int *)
LDRTword(int *)

[a] Or equivalent.


Return value

The __ldrt intrinsic returns the data loaded from the memory address pointed to by ptr.

Errors

The compiler does not recognize the __ldrt intrinsic when compiling for a target that does not support the LDRT instruction. The compiler generates either a warning or an error in this case.

The __ldrt intrinsic does not support access to doubleword data. The compiler generates an error if you specify an access width that is not supported.

Example

int foo(void)
{
    int loc = 0xff;
    return __ldrt((const volatile int *)loc);
}

Compiling this code with the default options produces:

||foo|| PROC
    MOV      r0,#0xff
    LDRBT    r1,[r0],#0
    MOV      r2,#0x100
    LDRBT    r0,[r2],#0
    ORR      r0,r1,r0,LSL #8
    BX       lr
    ENDP

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential