Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

EVEN A LITTLE HELP WOULD BE HELPFUL! THX! --------------------------------------

ID: 3621728 • Letter: E

Question

EVEN A LITTLE HELP WOULD BE HELPFUL! THX!

-----------------------------------------------------------------------

Write an unsigned 16-bit implementation of multiplier and divider architectures. You need to follow the Multiply and Divide algorithms to implement this. YOU MUST NOT USE MIPS MULTIPLICATION OR DIVISION INSTRUCTIONS.

The output of the program must include product, quotient and remainder. Also, the program must check for “0” as an input and must give error message for divide-by-zero operation.

Example:
Enter an integer (a): 14
Enter another integer (b): 3
Product: 42
Quotient (a/b): 4
Remainder (a/b): 2
Quotient (b/a): 0
Remainder (b/a): 3
Divide-by-zero

Example:
Enter an integer: 14
Enter another integer: 0
Product: 0
Quotient (a/b): Sorry, divide-by-zero not allowed
Quotient (b/a): 0
Remainder (b/a): 0



Try using the andi instruction: andi $t5, $t2, x. x is the number of bits (lsbs) you want to put in $t5. So if you have x set to 1, it will put the lsb of $t2 in $t5.

andi $t5, $t2, x. x is the value with which the value in $t2 is "anded" (bitwise and). And the result is put in $t5.

So if you have value 14 in $t2 and x is set to 3, you will have 10 (binary) in reg $t5.

If you and it with x=1, it will tell whether the lsb is 1 or 0.

PLEASE HELP!

 

WILL RATE LIFESAVER!

Explanation / Answer

Dear, Here is the code ###### Data segment ############ .data Prompt1:.asciiz "Enter an Integer (a):" Prompt2:.asciiz"Enter another Integer (b):" Pro_msg: .asciiz "product:" Quo1_msg: .asciiz "Quotient (a/b):" Quo2_msg: .asciiz "Quotient (b/a):" Rem1_msg: .asciiz "Quotient (a/b):" Rem2_msg: .asciiz "Quotient (b/a):" Error_msg:.asciiz "Sorry, divide-by-zero not allowed" ######## Code segment ######## .text .globl main main: la $a0,prompt1 # display prompt string li $v0,4 syscall li $v0,5 # read 1st integer into $t0 syscall move $t0,$v0 la $a0,prompt2 #display prompt string li $v0,4 syscall li $v0,5 # read 1st integer into $t0 syscall move $t1,$v0 #calculate product mul $t3,$t0,$t1 #accumulate the product move $a0,$t3 # output product li $v0,1 syscall beqz $t2,else beqz $t1,else div $t4,$t0,$t1 #accumulate quotient and reminder la $a0,Quo1_msg # display prompt string li $v0,4 syscall move $a0,$tl4 # output quotient li $v0,1 syscall la $a0,Rem1_msg # display prompt string li $v0,4 syscall move $a0,$th4 # output quotient li $v0,1 syscall la $a0,Rem1_msg # display prompt string li $v0,4 syscall move $a0,$th4 # output quotient li $v0,1 syscall beqz $t1,else div $t4,$t0,$t1 #accumulate quotient and reminder la $a0,Quo2_msg # display prompt string li $v0,4 syscall move $a0,$tl4 # output quotient li $v0,1 syscall else: la $a0,Error_msg # display prompt string li $v0,4 syscall li $v0,10 # exit syscall Hope this will help you..