Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3220198
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:44:02+00:00 2026-05-17T15:44:02+00:00

I have a C function in which I have 4 pointers and each of

  • 0

I have a C function in which I have 4 pointers and each of them point to different locations of a large 2D array of floats.

Because the ARM assembly functions can only be passed with 4 parameters (r0 – r3), I’m not able to understand how to pass the pointer to my return value, which will become the 5th parameter to my assembly function.

So, to overcome this, I thought of putting all the 4 pointers into an array of pointers, so that I will have 3 more free spots, using which I can pass a pointer to my return value as well.

But, I don’t know how I can extract the four individual pointers from my array of pointers, inside the assembly function. I’m failing in my attempts.

Here is a sample of what I’m trying to do.

Program

#include<stdio.h>

void  _my_arm_asm(float32_t *);

float32_t data_array[100][100];

void main()
{
       float32_t *ptr1, *ptr2, *ptr3, *ptr4;

        ptr1 = \\ data_array[value] + (some value);
        ptr2 = \\ data_array[value] + (some other value);
        ptr3 = \\ data_array[value] + (some other value);
        ptr4 = \\ data_array[value] + (some other value);

       float32_t *array_pointers[4];
       array_pointers[0] = ptr1;
       array_pointers[1] = ptr2;
       array_pointers[2] = ptr3;
       array_pointers[3] = ptr4;

       float32x4_t result;

       _my_arm_asm(array_pointers, &result);

        ....
        ....
        ....
       return 0;


}



.text
    .global _my_arm_asm

_my_arm_asm:
            #r0: Pointer to my array of pointers
            #r1: Pointer to my result

        push   {r4-r11, lr}

        # How to access the array of pointers?

        # I previously tried this, is this the right way to do it?

        # mov r4, #0
        # vld4.32 {d0, d1, d2, d3}, [r0, r4]
        # add r4, r4, #1
        # vld4.32 {d4, d5, d6, d7}, [r0, r4] 
        # add r4, r4, #1
        # vld4.32 {d8, d9, d10, d11}, [r0, r4] 
        # add r4, r4, #1
        # vld4.32 {d12, d13, d14, d15}, [r0, r4] 


        ....
        ....
        ....

        pop    {r4-r11, pc}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:44:02+00:00Added an answer on May 17, 2026 at 3:44 pm

    In general, if more than 4 arguments are passed to a function the excess arguments are passed on the stack.

    The ARM EABI specifies how compilers should pass arguments to functions (it also specifies which registers a caller can expect to be unchanged across the function call). Your assembly routine can use the same techniques (and probably should unless you have a good reason not to). If nothing else, that’ll mean that your assembly function can be easily called from C.

    • http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.subset.swdev.abi/index.html

    Chapter 5 (The Base procedure Call Standard) of the “Procedure Call Standard for the ARM Architecture” should have the exact details. It’s pretty complex on the face of it (becuase there’s a lot of detail on alignment, argument size, etc), but I think for your purposes it boils down to that the 5th argument to the function get’s pushed onto the stack.

    • http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf

    Of course, as you suggest in your question, you could avoid all that by packing your 4 pointers into a structure and passing a pointer to the struct – in your assembly routine you simple load that struct pointer into a register and use that to in turn load the pointers you really need.

    I think that the ARM assembly might look something like:

                     // r0 has the 1st parameter
    ldr r4, [r0]     // get array_pointers[0] into r4
    // ...
    
    ldr r5, [r0, #4] // get array_pointers[1] into r5
    // ...
    
    ldr r6, [r0, #8] // get array_pointers[2] into r6
    

    You could also use a ‘load multiple’ instruction to get all 4 pointers in one shot, but I’m not sure what you register usage requirements/restrictions might be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function which parses one string into two strings. In C# I
I have a function which searches an STL container then returns the iterator when
I have an function which decodes the encoded base64 data in binary data but
I have a function which gets a key from the user and generates a
i have a function which retrieves values from a webservice , then loops through
Imagine I have an function which goes through one million/billion strings and checks smth
This is a Windows Forms application. I have a function which captures some mouse
i have a c function which returns a long double . i'd like to
Say I have a C function which takes a variable number of arguments: How
if i have a function A,which can apply a certain rule on a given

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.