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
Help please my mips assembly language
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
Step by step
Solved in 2 steps