Please help me find the bug 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 error I get is Error in H:\Downloads\hw2221 line 24 column 10: "input": operand is of incorrect type The program is .datainput: .word 0output: .asciiz ""str1: .asciiz " Please enter an integer: ".text.globl main main: li $v0, 5syscall sw $v0, inputli $t1, 16li $t0, 0loop:beq $t1, $t0, endlw $t2, inputand $t2, $t2, 1sll $t2, $t2, 31or $t2, $t2, $t3srl $t3, $t3, 1srl $t2, input, 1sw $t2, inputaddi $t0, $t0, 1j loopend:move $a0, $t3li $v0, 1syscallli $v0, 10syscall
Please help me find the bug
a MIPS assembly
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 error I get is
Error in H:\Downloads\hw2221 line 24 column 10: "input": operand is of incorrect type
The program is
.data
input: .word 0
output: .asciiz ""
str1: .asciiz " Please enter an integer: "
.text
.globl main
main:
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, input, 1
sw $t2, input
addi $t0, $t0, 1
j loop
end:
move $a0, $t3
li $v0, 1
syscall
li $v0, 10
syscall
Unlock instant AI solutions
Tap the button
to generate a solution