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 8402759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:09:17+00:00 2026-06-09T22:09:17+00:00

for (int i = 0; i < 10000; i++) a[i] = b[i] + c[i]

  • 0
for (int i = 0; i < 10000; i++)
  a[i] = b[i] + c[i]

What does the ARM assembly for this high level language look like?

Edit:
I’m also assuming the base address of A is in R8, the base
address of B is in R9, and the base address of C is in R10
and A,B,C are all int arrays

Much appreciated

I tried:

MOV  R0, #0  ; Init r0 (i = 0)

Loop:

        a[i] = b[i] + c[i]   //How to fix this? 

        ADD  R0, R0, #1 ;Increment it

        CMP  R0, #1000 ;Check the limit

        BLE  Loop  ;Loop if not finished
  • 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-06-09T22:09:19+00:00Added an answer on June 9, 2026 at 10:09 pm

    Assuming this high level language doesn’t have anything conflicting with C, you can use an arm C compiler to create assembly code from your snippet. For example if you have the following in test.c,

    void test() {
            register int i asm("r0");
            register int *a asm("r8");
            register int *b asm("r9");
            register int *c asm("r10");
    
            for (i = 0; i < 10000; i++) {
                    a[i] = b[i] + c[i];
            }
    }
    

    you can run

    arm-linux-androideabi-gcc -O0 -S test.c
    

    to create a test.s file, which will contain assembly code for your test function as well as some extra stuff. You can see how your loop got compiled into to assembly below.

    <snipped>
    .L3:
            mov     r2, r8
            mov     r3, r0
            mov     r3, r3, asl #2
            add     r3, r2, r3
            mov     r1, r9
            mov     r2, r0
            mov     r2, r2, asl #2
            add     r2, r1, r2
            ldr     r1, [r2, #0]
            mov     ip, sl
            mov     r2, r0
            mov     r2, r2, asl #2
            add     r2, ip, r2
            ldr     r2, [r2, #0]
            add     r2, r1, r2
            str     r2, [r3, #0]
            mov     r3, r0
            add     r3, r3, #1
            mov     r0, r3
    .L2:
            mov     r2, r0
            ldr     r3, .L5
            cmp     r2, r3
            ble     .L3
            sub     sp, fp, #12
            ldmfd   sp!, {r8, r9, sl, fp}
            bx      lr
    <snipped>
    

    Now the problem with this approach is trusting the compiler generates the optimal code for your study, which might not be always the case but what you’ll get is fast answers to your questions like above instead of waiting for people 🙂

    — extra —

    GCC allows you to put variables into certain registers, see related documentation.

    You can get arm instruction cheat sheet here.

    Newer versions of GCC creates better arm code as one would expected. Above snipped is generated by version 4.4.3, and I can confirm Linaro‘s 4.7.1 proves my claim. So if you take my approach use the most recent tool chain you can get.

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

Sidebar

Related Questions

I want to have a large 2 dimensional array such like int myArray[10000][2]; I
Say I have a loop that looks like this: for(int i = 0; i
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i <
Why does this code not parallelize std::for_each() when it works perfectly fine with std::sort()?
Assume UAC is ON. This does not create a problem with it off. I
Question goes like this.. Input n [the number of multiplications <= 1000] l1 l2
following code for partition #include<iostream> using namespace std; #define maxn 10000 int x[maxn]; void
Why does this loop freeze the GUI? How can I solve this? -(void)freeze {
Observe the following code: private List<List<Place>> m_grid = constructGrid(10000); private static List<List<Place>> constructGrid(int size)
The msdn documentation states that a static generic Queue is thread-safe. Does this mean

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.