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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:56:09+00:00 2026-05-20T07:56:09+00:00

I thought I correctly implemented a while loop, but why am I not getting

  • 0

I thought I correctly implemented a while loop, but why am I not getting any output?

My book isn’t that great of a help, and I haven’t been able to find a resource online.

##### The Data Segment #########

.data
strFirstNumber:     .asciiz  "Enter the first number (0-63): "
strSecondNumber:    .asciiz  "Enter the second number (0-63): "
strError:           .asciiz  "That number is not in the 0-63 range.\n\n"

#### The Text Segment ##########

.text
.globl main

main:
    li $t2, 0
#First Number
    li $10, 64
    li $v0, 4
    la $a0, strFirstNumber
    syscall
    li $v0, 5
    syscall
    blez $v0, in_error
    bgeu $v0, $10, in_error
    j DoneIf

in_error:
    li $v0, 4
    la $a0, strError
    syscall
    li $v0, 4
    la $a0, strFirstNumber
    syscall
    li $v0, 5
    syscall
    bltz $v0, in_error
    bgeu $v0, $10, in_error

DoneIf:
    move $t0, $v0

#Second Number
    li $v0, 4
    la $a0, strSecondNumber
    syscall
    li $v0, 5
    syscall
    bltz $v0, in_error2
    bgeu $v0, $10, in_error2
    j DoneIf2

in_error2:
    li $v0, 4
    la $a0, strError
    syscall
    li $v0, 4
    la $a0, strSecondNumber
    syscall
    li $v0, 5
    syscall
    blez $v0, in_error2
    bgeu $v0, $10, in_error2

DoneIf2:
    move $t1, $v0

Loop:
    beq    $t2, $t0, Exit
    add    $t3, $t1, $t1
    add    $t2, $t2, 1

    j    Loop        # go to Loop

Exit:
    li $v0, 1
    add    $a0, $0, $t3
    syscall

    jr    $31
  • 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-20T07:56:09+00:00Added an answer on May 20, 2026 at 7:56 am

    It’s nearly impossible to say what’s wrong:

    1. we don’t know what’s happen in syscalls.
    2. you are using $t registers to store value. This is bad because MIPS define them as scratch regiters. Use $s0 to $s7 instead
    3. we don’t know your target. Is this real HW or emulator ?
    4. we don’t know if the code complete

    BTW, if you correctly entered both numbers, your code must run into the loop. Again, given that syscalls probably trashed registers, it may run for a … long … time.

    Try to change register allocation first, then remove the loop that does not change the result computed into $t3. And possibly check that your syscall to print work correctly.

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

Sidebar

Related Questions

I do not currently have this issue , but you never know, and thought
I thought I heard that py2exe was able to do this, but I never
I thought that there was some way in .net 3.0 to give an array
I'm going to make a long story short. It's been a while that I
I'm struggling with an AudioQueue audio player I implemented. I initially thought it was
I've implemented the jQzoom plugin in my Joomla based website. It works great on
currently, I am looking deeper into testing techniques, even though I am not sure
I thought .Net code gets compiled into MSIL, so I always wondered how do
I thought jQuery Intellisense was supposed to be improved with SP1. I even downloaded
I thought I had seen a bug report about this on the jQuery site,

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.