Help please my mips assembly language program does not work, The problem is that it outputs zero no matter what is entered  by user.  It is supposed to  a MIPS assembly program that takes input of an integer and  prints out a string that shows how that integer should be encoded using 16 bits. Please help me find the bug It is supposed to handle both positive and negative valued inputs. The program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.   As an example, if the input is 12, the program should output 0000000000001100.       The code: .datainput: .word 0output: .asciiz ""str1: .asciiz " Please enter an integer: ".text.globl main main: li $v0, 4la $a0, str1syscall   li $v0, 5syscall sw $v0, inputli $t1, 16li $t0, 0 loop:beq $t1, $t0, endlw $t2, inputand $t2, $t2, 1sll $t2, $t2, 31or $t2, $t2, $t3srl $t3, $t3, 1srl $t2, $t2, 1sw $t2, inputaddi $t0, $t0, 1j loop end:move $a0, $t3li $v0, 1syscall li $v0, 10syscall

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Help please my mips assembly language program does not work, The problem is that it outputs zero no matter what is entered  by user. 

It is supposed to 

a MIPS assembly program that takes input of an integer and  prints out a string that shows how that integer should be encoded using 16 bits.

Please help me find the bug

It is supposed to handle both positive and negative valued inputs.

The program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.

 

As an example, if the input is 12, the program should output 0000000000001100.

 

 

 

The code:

.data
input: .word 0
output: .asciiz ""
str1: .asciiz " Please enter an integer: "
.text
.globl main

main:

li $v0, 4
la $a0, str1
syscall

 

li $v0, 5
syscall


sw $v0, input
li $t1, 16
li $t0, 0

loop:
beq $t1, $t0, end
lw $t2, input
and $t2, $t2, 1
sll $t2, $t2, 31
or $t2, $t2, $t3
srl $t3, $t3, 1
srl $t2, $t2, 1
sw $t2, input
addi $t0, $t0, 1
j loop


end:
move $a0, $t3
li $v0, 1
syscall

li $v0, 10
syscall

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education