CM3 支持 64 位整数, LDRD STRD

 1 ;CM3 在一定程度上支持 64 位整数。
 2 ;其中 LDRD/STRD 就是为 64 位整数的数据传送而设的,语法 格式为:
 3 
 4     LDRD.W RL, RH, [Rn, #+/-offset] {!}
 5     STRD.W RL, RH, [Rn, #+/-offset] {!}
 6     LDRD.W RL, RH, [Rn],#+/-offset
 7     STRD.W RL, RH, [Rn],#+/-offset
 8 
 9     LDR R2, =0x1000     ;(0x1000)= 0x1234_5678_ABCD_EF00 : 00 EF CD AB 78 56 34 12
10     LDRD.W R0, R1,[R2]  ;R0= 0xABCD_EF00, R1=0x1234_5678
11     STRD.W R1, R0,[R2]  ;(0x1000)=0xABCD_EF00_1234_5678 : 78 56 34 12 00 EF CD AB 

Memory : [ RL ] [ RH ]

For example, the following piece of code stores the 64-bit value 0x0123456789ABCDEF to address 0xA0000000:
void perip_64bitaccess(void)
{
  unsigned long long value = 0x0123456789ABCDEF;
  *((volatile unsigned long long*) (0xA0000000)) = value;
}

 

 

__asm void stm_llout(unsigned long long* addr, unsigned long long value)
{
  STM r0, {r2,r3}
  BX LR
}

__asm unsigned long long ldm_llin(unsigned long long* addr)
{
  LDM r0, {r0,r1}
  BX LR
}

unsigned long long perip_64bitaccess(void)
{
  unsigned long long ullvalue = ldm_llin((unsigned long long*)0x40004000);
  stm_llout((unsigned long long*)0x40000000, ullvalue);
  return ullvalue;
}

 

你可能感兴趣的:(支持)