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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:14:04+00:00 2026-06-15T10:14:04+00:00

I’ve been working on a very basic MIPS program that computes some stuff on

  • 0

I’ve been working on a very basic MIPS program that computes some stuff on ticket sales. I have all the functionality implemented, but when I do my IF statements (blt –> branch if less than) I am running into some errors. I have the following data stored in temporary registers:

- $t0 = # of VIP tickets.
- $t1 = # of General Admission tickets.
- $t2 = # of Box Office tickets.
- $t4 = Average ticket sales.

I have checked that the values are stored accordingly and the code does work if the condition is FALSE, but if the condition is met it will branch and still print the code before the branch. Here is part of my code:

  blt $t0, $t4, VIP_LESS  # if $t0 < $t4 then VIP
  b VIP_GREAT
  VIP_LESS:
    li $v0, 4
    la $a0, less_avg_vip
    syscall 
  VIP_GREAT:
    li $v0, 4
    la $a0, great_avg_vip
    syscall 
  blt $t1, $t4, GEN_LESS # if $t1 < $t4 then GEN
  b GEN_GREAT
  GEN_LESS:
    li $v0, 4
    la $a0, less_avg_general
    syscall
  GEN_GREAT:
    li $v0, 4
    la $a0, great_avg_general
    syscall 
  blt $t2, $t4, BOX_LESS  # if $t2 < $t4 then BOX_LESS
  b BOX_GREAT
  BOX_LESS:
    li $v0, 4
    la $a0, less_avg_box
    syscall 
  BOX_GREAT:
    li $v0, 4
    la $a0, great_avg_box
    syscall 
  li $v0, 4
  la $a0, endl
  syscall

Can anyone see why I am getting a problem with this? The output of my program looks something like this:

VIP: 1349 tickets
General: 5278 tickets
Box: 4367 tickets

Average: 3215 tickets

VIP: Less than average.
General: Greater than average.
General: Less than average.
Box: Greater than average.
Box: Less than average.

EDIT: working code.

 blt $t0, $t4, VIP_LESS  # if $t0 < $t4 then VIP
  li $v0, 4
  la $a0, great_avg_vip
  syscall
  j GENERAL_IF
  VIP_LESS:
    li $v0, 4
    la $a0, less_avg_vip
    syscall 
  GENERAL_IF: 
    blt $t1, $t4, GEN_LESS # if $t1 < $t4 then GEN
    li $v0, 4
    la $a0, great_avg_general
    syscall 
    j BOX_IF
    GEN_LESS:
      li $v0, 4
      la $a0, less_avg_general
      syscall
  BOX_IF:
    blt $t2, $t4, BOX_LESS  # if $t2 < $t4 then BOX_LESS
    li $v0, 4
    la $a0, great_avg_box
    syscall 
    j END_IF
    BOX_LESS:
      li $v0, 4
      la $a0, less_avg_box
      syscall 
  END_IF:
    li $v0, 4
    la $a0, endl
    syscall 
  • 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-15T10:14:05+00:00Added an answer on June 15, 2026 at 10:14 am

    You just need some unconditional branches so that you don’t execute both the “greater than” and “less than” code paths, e.g.

      blt $t0, $t4, VIP_LESS  # if $t0 < $t4 then VIP
      li $v0, 4
      la $a0, great_avg_vip
      syscall 
                    <<< you need an unconditional branch here to VIP_GE
      VIP_LESS:
        li $v0, 4
        la $a0, less_avg_vip
        syscall 
        xor $a0, $a0, $a0
      VIP_GE:       <<< label here so that you can skip previous block
      ...
    

    You need to do this for each of your three if/else blocks.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have been unable to fix a problem with Java Unicode and encoding. The
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all

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.