This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can't pass pointer parameters correctly.Why?

Hi,

I wrote a test function as;

// Task definitions
OS_TID T_Test;

U64 Test_stack[13312/8];
__task void init       (void);
__task void Test (void) ;

// Function definition
uint16_t TestFunc(
   uint8_t a0,
   uint8_t a1,
   uint8_t a2,
   uint16_t a3,
   uint8_t a4,
   uint8_t a7,
   uint16_t a9,
   uint16_t a10,
   uint8_t* a5,
   uint8_t* a6,
   uint8_t* a8,
   uint8_t* a11,
   uint8_t* a12,
   uint8_t* a13)
{
   uint16_t x;
   //........
   return 0;
}
__task void init (void)
{
   /* Initialize Tasks */
   T_Test        = os_tsk_create_user (Test, 1, &Test_stack, sizeof(Test_stack));
   os_tsk_delete_self();
}
// Call Function
__task void Test (void)
{
   uint8_t x=9,*y;
   uint16_t z=0x1001;
   y=&x;
   x = TestFunc(x,x,x,z,x,x,z,z,y,y,y,y,y,y);
   os_tsk_delete_self();
}

The last two "y" are not equal to the address of the x. I need to know passing argument limitations and the reasons of this unexpected(according to me) condition.

Need help! (asap.)

Thanks.

Parents
  • I need to know passing argument limitations and the reasons of this unexpected(according to me) condition.

    The way in which all ARM compilers (should) pass arguments is defined in the "ARM Architecture Procedure Call Standard" (AAPCS).

    infocenter.arm.com/.../IHI0042D_aapcs.pdf

    That being said, I don't see any reason why your function call wouldn't work. Is there any reason why you aren't wrapping the arguments in a structure and simply passing a pointer to the structure? The reason I ask is because, as defined by the AAPCS, passing more than 4 arguments involves stack access (slow) and should be avoided if possible.

Reply
  • I need to know passing argument limitations and the reasons of this unexpected(according to me) condition.

    The way in which all ARM compilers (should) pass arguments is defined in the "ARM Architecture Procedure Call Standard" (AAPCS).

    infocenter.arm.com/.../IHI0042D_aapcs.pdf

    That being said, I don't see any reason why your function call wouldn't work. Is there any reason why you aren't wrapping the arguments in a structure and simply passing a pointer to the structure? The reason I ask is because, as defined by the AAPCS, passing more than 4 arguments involves stack access (slow) and should be avoided if possible.

Children