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

  • SEARCH
  • Home
  • 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 8730343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:00:06+00:00 2026-06-13T09:00:06+00:00

This is a homework question, but I’m stuck. The assignment is to find the

  • 0

This is a homework question, but I’m stuck.

The assignment is to find the largest integer in an array. Here’s the C code we’re given:

#include <stdio.h>
#include <stdlib.h>

extern int mybig( int array[] ) ;

void main( char * argv[], int argc )
{
int array[] = { 5, 15, 100, 25, 50, -1 } ;

int biggest ;

biggest = mybig( array ) ;

printf( "Biggest integer in array: %d\n", biggest ) ;

}

I’ve made about a dozen versions of the assembly so far, but this is the closest I’ve gotten

.global mybig
 mybig:  stmfd sp!, {v1-v6, lr}
    mvn v1, #0
 loop:  ldrb a4, [a1], #4
    MOVLT a4, a1
    cmp a1, v1
    bne loop
    ldmfd sp!, {v1-v6, pc}
    .end

Every time I link it together, I hit an infinite loop, and I’m not sure why. Any help would be majorly appreciated, the professor didn’t teach us anything in an introductory course, just told us to do it, and gave us a link to a toolchain to compile and assemble.

EDIT: This is where I’ve gotten to. Program doesn’t run, just hits an infinite loop.

    .global mybig
mybig:  stmfd sp!, {v1-v6, lr}
    mvn v1, #0
    mov a3, a1
loop:   ldr a4, [a1], #4
    cmp a4, a1
    MOVMI a3, a1
    cmp a1, v1
    bne loop
    mov a1, a4
    ldmfd sp!, {v1-v6, pc}
    .end

C code hasn’t changed

  • 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-13T09:00:07+00:00Added an answer on June 13, 2026 at 9:00 am

    That would be my solution:

    .global mybig
     mybig:
       // a1 = Highest word, defaults to 0x80000000 = −2,147,483,648
       // a2 = Pointer to array
       // a3 = current word
        mov a2, a1
        mov a1, #0x80000000
     .Lloop:
        ldr   a3, [a2], #4 // Load word and advance pointer by 4 bytes
        cmn   a3, #1       // Compare with -1
        bxeq  lr           // Return if endmarker was found
        cmp   a1, a3       // Compare current highest word and new word
        movlt a1, a3       // Replace highest word if it was smaller
        b     .Lloop       // Loop again
        .end
    

    While this is not the best possible code in regards of performance it should be self explaining.

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

Sidebar

Related Questions

Ok, this is a C programming homework question. But I'm truly stuck. I ask
Disclaimer: This is for a homework assignment, but the question is not regarding the
This is a homework question, but I think there's something missing from it. It
Ok this is a homework questions, but I cannot find the answer anywhere, not
I'm trying to solve this problem, its not a homework question, its just code
this feels like a do my homework for me kind of question but I'm
DISCLAIMER: This question is related to homework. I am not expecting a solution, but
This is NOT a homework question, actually I am doing this for fun. Here
yes, this is a homework-type question but could you please help me out? In
This is a homework question, I got the basics down, but I can't seem

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.