Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question- Why am I receiving this output and not the error label? how can I print the error label using the code in italics that

Question- Why am I receiving this output and not the error label? how can I print the error label using the code in italics that I have written?

.data .align 0

# Define strings used in each of the printf statements msg1: .asciiz "Welcome to Prime Tester " msg2: .asciiz "Enter a number between 0 and 100: " msg3: .asciiz "Error: Invalid input for Prime Tester " msg4: .asciiz "The entered number is prime " msg5: .asciiz "The entered number is not prime " ec_msg: .asciiz " is prime " # Reserved for use in extra credit

.align 2 .text .globl main

# The following macros are provided to simplify the program code # A macro can be thought of as a cross between a function and a constant # The assembler will copy the macro's code to each use in the program code # Display the %integer to the user # Reserved for extra credit .macro display_integer (%integer) li $v0, 1 # Prepare the system for output add $a0, $zero, %integer # Set the integer to display syscall # System displays the specified integer .end_macro # Display the %string to the user .macro display_string (%string) li $v0, 4 # Prepare the system for output la $a0, %string # Set the string to display syscall # System displays the specified string .end_macro

main: # This series of instructions # 1. Displays the welcome message # 2. Displays the input prompt # 3. Reads input from the user display_string msg1 # Display welcome message display_string msg2 # Display input prompt li $v0, 5 # Prepare the system for keyboard input syscall # System reads user input from keyboard move $a1, $v0 # Store the user input in register $a0 j code # Go to the code label

error: display_string msg3 # Display error message j exit isprime: display_string msg4 # Display is prime message j exit notprime: display_string msg5 # Display not prime message exit: li $v0, 10 # Prepare to terminate the program syscall # Terminate the program

# Place all your code below the code label code:

#c code#if(input < 0 || input > 100) # { # printf("Error: Invalid input for Prime Tester "); # exit(0); #} slti $t0, $a1, 0 #right now $t0 is 1 if $a1 is less than zero or 0 if greater sge $t1, $a1, 100 #if $a1 is greater than 100 than $t1 = 1 else = 0 or $t2, $t0, $t1 # now the decision of the if staement is stored in $t2 # if this value is = 1 then move to error message then exit else exit beq $t2, 1, error

....................................................................................................................................

Below is my output:

Welcome to Prime Tester

Enter a number between 0 and 100: 5

-- program is finished running (dropped off bottom) --

....................................................................................................................................

Why am I receiving this output and not the error label? how can I print the error label using the code in italics that I have written?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago