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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:37:20+00:00 2026-05-25T19:37:20+00:00

I am working on a simple routine that will loop through a list of

  • 0

I am working on a simple routine that will loop through a list of numbers and return the max. It is always returning 11 and I cannot see what’s wrong with my logic. To test the routine I have a list of numbers (data_items) that I am looping through. What am I doing wrong here?

 .section .data

data_items:    #these are the data items

.long 3,67,34,222,45,75,857,858,983,11,55,43,23,123,785,4356,0

.section .text

.globl _start

_start:

movl $0, %edi                       #move 0 into the index register
movl data_items(,%edi,4), %eax      #load the first byte of data
movl %eax, %ebx                     #since this is the first item, %eax is the biggest


start_loop:
cmpl $0, %eax                       #check to see if we've hit the end
je loop_exit
incl %edi                           #load the next value
movl data_items(,%edi,4), %eax
cmpl %ebx, %eax                     #compare values
jle start_loop                      #jump to the start of the loop if the value is not larger

movl %eax, %ebx                     #move the value as the largest
jmp start_loop                      #jump to the loop beginning

loop_exit:
movl $1, %eax                       #1 is the exit() syscall
int $0x80
  • 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-25T19:37:20+00:00Added an answer on May 25, 2026 at 7:37 pm

    There’s nothing wrong with your logic at all. When I enter that code into qq.s and execute the following:

    pax$ as -o qq.o qq.s
    
    pax$ ld -o qq qq.o
    
    pax$ gdb qq
    GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
    Copyright (C) 2010 Free Software Foundation, Inc.
    ... blah blah blah ...
    Reading symbols from /home/pax/qq...(no debugging symbols found)...done.
    
    (gdb) break loop_exit
    Breakpoint 1 at 0x8048097
    
    (gdb) run
    Starting program: /home/pax/qq 
    Breakpoint 1, 0x08048097 in loop_exit ()
    
    (gdb) info reg ebx
    ebx            0x1104   4356
    
    (gdb) _
    

    In other words, the correct value is being loaded into ebx.

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

Sidebar

Related Questions

I am working on a simple notification service that will be used to deliver
I've been trying to do a simple restful wcf service that will return JSON.
I am working on a simple import routine that translates a text file to
I'm working on a Nelder-Mead optimization routine in C that involves taking the average
Working on a simple API, I noticed that my routing tests were failing because
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
Working on a simple C program I'm stuck with an if test: int line_number
I'm working on a simple ASP.Net page (handler, actually) where I check the value
I'm working on a simple multiplayer game in which 2-4 players are placed at
I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display

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.