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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:44:11+00:00 2026-05-26T16:44:11+00:00

I wanted to write a program that converts a decimal in to binary. For

  • 0

I wanted to write a program that converts a decimal in to binary. For this I would use an array. Please look at the line commented below and tell me why it might not work because the spim simulator says attempting to execute non-instruction

       .text
       .globl __start
    __start:

        la $a0,prompt
        li $v0,4
        syscall

        li $v0,5
        syscall

        move $t1,$v0

        li $t0,0
        la $t2,bin
        #add $t2,$t2,124
            lop:    
            div $t1,$t1,2
        mflo $v0
        sw $v0,($t2) #right here
        add $t2,$t2,4
        add $t0,$t0,1
        ble $t0,32,lop
        j dnn

            ads:    
            la $a0,spc
    li $v0,4
    syscall
    j back

            dnn: 
        la $t0,bin
        li $t3,1
        la $a0,pr2
        li $v0,4
        syscall
        add $t0,$t0,124
            lp2:
        lw $t1,($t0)
        sub $t0,$t0,4
        add $t3,$t3,1
        move $a0,$t1
        li $v0,5
        syscall
        div $t4,$t3,4
        mflo $t4
        ble $t4,0,ads
            back:   
            ble $t3,33,lp2

        li $v0,10
        syscall

        .data
            prompt: .asciiz "Enter decimal: "
            spc:    .asciiz " "
            pr2:    .asciiz "\nbinary value:\n"
            bin:    .space 128

EDIT: I made some changes, like now all the ‘add’s are ‘addi’s and ‘.align 2’ comes after .data
also in The spim simulator (PCSpim) I noticed something interesting:

   [0x00400020]        0x3c011001  lui $1, 4097 [bin]              ; 15: la $t2,bin
   [0x00400024]        0x342a0022  ori $10, $1, 34 [bin]
   [0x00400028]        0x34010002  ori $1, $0, 2                   ; 17: div $t1,$t1,2
   [0x0040002c]        0x0121001a  div $9, $1
   [0x00400030]        0x00004812  mflo $9
   [0x00400034]        0x00001012  mflo $2                         ; 18: mflo $v0
   [0x00400038]        0xad420000  sw $2, 0($10)                   ; 19: sw $v0,($t2)

why is mflo done twice?

  • 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-26T16:44:11+00:00Added an answer on May 26, 2026 at 4:44 pm

    mflo is done twice because the DIV pseudo instruction does it and you’re doing it explicitly right after.

    You can just do:

        div $v0,$t1,2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I wanted to write a program that would export calendar data so that
I wanted to write a program that test if two files are duplicates (have
I wanted to write a function that would take an object and convert it
I wanted to write a Custom Control that would show a family tree... so
I'm a beginner in C++ Programming language. I wanted to write a program that
This is my first time using map/reduce. I want to write a program that
I wanted to write a small Rapid Serial Visual Presentation (RSVP) program for my
I wanted to write a method with an argument that defaults to a member
Wanted to write a program to implement a dictionary of words using Tries Data
I want to write a program in C/C++ that will dynamically read a web

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.