Question: Using the Assembly code for reporting if an integer is positive or negative : . data prompt: . asciiz Enter an Integer: positive: .

Using the Assembly code for reporting if an integer is positive or negative :
.data
prompt: .asciiz "Enter an Integer: "
positive: .asciiz "
Positive number provided"
negative: .asciiz "
Negative number provided"
goodbye: .asciiz "
Rerun program to use it again"
.text
# Print prompt
li $v0,4
la $a0, prompt # address of string to print
syscall
# Get the input
li $v0,5
syscall
# Store the Integer
move $t1, $v0
# Check if positive or negative
blt $t1, $zero, Else
li $v0,4
la $a0, positive # address of string to print
syscall
j Exit
Else: li $v0,4
la $a0, negative # address of string to print
syscall
Exit: li $v0,4
la $a0, goodbye # address of string to print
syscall
li $v0,10
syscall
Run this code in your MARS simulator on your computer. Make sure the program runs and you can enter positive and negative numbers and you will see the output with correct results.
Change the assembly code so that the program can tell if an entered digit is zero or non-zero.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!