Skip to content

Instantly share code, notes, and snippets.

@fanoush
Last active October 2, 2019 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fanoush/85ebe50c5c4a54ca15bf2867e27f7cd3 to your computer and use it in GitHub Desktop.
Save fanoush/85ebe50c5c4a54ca15bf2867e27f7cd3 to your computer and use it in GitHub Desktop.

C code

double __attribute__((pcs("aapcs"))) f2d(float f) {
return (double)f;
}

double __attribute__((pcs("aapcs-vfp"))) __hard_f2d(float f){
return (double)f;
}

double __attribute__((pcs("aapcs-vfp"))) __hard_powd(double d){
return d*d;
}
double __attribute__((pcs("aapcs"))) __softfp_powd(double d){
return d*d;
}

can be compiled both ways with same result

arm-none-eabi-gcc -O -c armfloat.c -mfloat-abi=hard 
arm-none-eabi-gcc -O -c armfloat.c -mfloat-abi=softfp 

arm-none-eabi-objdump -d armfloat.o produces


armfloat.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <f2d>:
   0:   ee070a90        vmov    s15, r0
   4:   eeb77ae7        vcvt.f64.f32    d7, s15
   8:   ec510b17        vmov    r0, r1, d7
   c:   e12fff1e        bx      lr

00000010 <__hard_f2d>:
  10:   eeb70ac0        vcvt.f64.f32    d0, s0
  14:   e12fff1e        bx      lr

00000018 <__hard_powd>:
  18:   ee200b00        vmul.f64        d0, d0, d0
  1c:   e12fff1e        bx      lr

00000020 <__softfp_powd>:
  20:   ec410b17        vmov    d7, r0, r1
  24:   ee277b07        vmul.f64        d7, d7, d7
  28:   ec510b17        vmov    r0, r1, d7
  2c:   e12fff1e        bx      lr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment