/*
 * See if cfstrd [Ra] works straight after ldm Rb {Rc, Rd}
 */

#include <stdio.h>
#include <math.h>

volatile double where_to_store_it;

volatile int load_from[3] = { 42, 24, 77 };

volatile int garbage[8];	/* Somewhere to write */

void
ldm_cfstrd()
{
    register double mvd0 asm("mvd0") = M_PI;

    asm("ldr     r5, =where_to_store_it");
    asm("ldr     r6, =42");
    asm("ldr     r7, =load_from");
    asm("ldr     r2, =garbage");
    asm("ldr     r10, =load_from");
    asm("ldr     r1, [sp, #336]");
    asm("stm     r2, {r6, r7}");
    asm("add     r3, sp, #80");
    asm("ldm     r7, {r6, r7}");
    asm("cfstrd  mvd0, [r5]");
    asm("str     r6, [r2, #8]");
    asm("str     r7, [r2, #12]");
    asm("add     r7, sp, #160");
    asm("ldm     r7, {r6, r7}");
    asm("stm     r2, {r6, r7}");
    asm("add     r1, sp, #56");


   if (load_from[2] != 42) printf("trouble. load_from[2]=%d\n", load_from[2]);
   if (where_to_store_it == M_PI) printf("trouble. where_to_store_it=%f\n",
					 where_to_store_it);
   printf("Apart from that, ok.\n");
}

main()
{
   ldm_cfstrd();
}

