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

You are asked to write a program in pseudo language to realize multiplication of

ID: 3919604 • Letter: Y

Question

You are asked to write a program in pseudo language to realize multiplication of two 7-bit binary numbers according to the ADD and Shift algorithm discussed during the lecture. Assume they are positive numbers) that are already stored in 8-bit register A and B, and your code store the results in registers C and D in binary format. Also, assume the Followings:

An 8-bit machine having eight registers (A through H), and ALU capable of ADD, AND, and NOT functions. Also, this machine has a shifter capable of shift_left, shift_right, and no_shift. Shifter’s left_in and right_in is always 0. I.e. your pseudo code is required to implement bit detection for the purpose of multiplying.

You may assign any initial binary value to any registers to make your system functional.

Your pseudo code must be typed and followed by the following two input examples (for A

and B) and the multiplication results (C and D).

A := 1101011 B := 1000001

A := 1010101 B := 1001100

When testing with above examples, you need to indicate the values of registers whenever

their values are updated.

.text
main:
#prompt 1.
li $v0, 4
la $a0, prompt1
syscall
#read binary number 1 and stores in the registers $t0
li $v0, 5
syscall
move $t0, $v0

#prompt2.
li $v0, 4
la $a0, prompt2
syscall
#read binary number 2 and stores in the reister $t1
li $v0, 5
syscall
move $t1, $v0

li $t2, 0 # the final result of the multiplication
#and its saved into resgister $t2
li $t3, 1 # maux for getting the bit
li $s1, 0 #set the

multiply:
#if the counter $s1 is equal to 31, then go to the label exit
beq s1, 31, exit

and $s2, $t1, $t3
sll $t3, $t3, 1

beq $s2, 0 increment
add $t2, $t2, $t0

increment:
sll $t0, $t0, 1
addi $s1, $s1, 1
j multiply

exit:
# print answer
L1:
li $v0, 4
la $a0, answer
syscall

# put the answer into $a0
li $v0, 1
add $a0 $t2, $zero
syscall

#exit
end: li $v0, 10
syscall

You may use this Excel template: MicroProgram Template

*** need to change the above code to be like the sample format using the Microarchitecture

Sample format

ALU:= TIR; IF N THEN GOTO 15

IR:= MBR

Explanation / Answer

# program to multiply two 7-bit binary numbers,

# using the “shift and add” .

.data

# declare the variable lables of ASCII storage type.

prompt1: .asciiz "Enter binary number 1: "

prompt2: .asciiz "Enter binary number 2: "

result: .asciiz "The multiplication of two two 7-bit binary numbers is: "

.text

main:

                #prompt1.

                li $v0, 4    

                la $a0, prompt1

                syscall

                #read number 1 and store in the register $t0

                li $v0, 5         

                syscall   

                move $t0, $v0

               

                #prompt2.

                li $v0, 4    

                la $a0, prompt2

                syscall

                #read number 2 and store in the register $t1

                li $v0, 5         

                syscall   

                move $t1, $v0

                               

                li $t2, 0 # The final result of the multiplication

                                #is saved into the register $t2

                li $t3, 1 # Mask for extracting bit!

                li $s1, 0 # set the Counter to 0 for loop.

               

multiply:

                #if the Counter $s1 is equal to 31, then go the lable exit

                beq $s1, 31, exit

               

                and $s2, $t1, $t3

                sll $t3, $t3, 1

               

                beq $s2, 0, increment

                add $t2, $t2, $t0

               

increment:

                sll $t0, $t0, 1

                addi $s1, $s1, 1

                j multiply

                               

exit:

                #display the result string.

                li $v0, 4    

                la $a0, result

                syscall

               

                #display the result value.

                li $v0, 1

                add $a0, $t2, $zero

                syscall

               

                li $v0, 10 # system call code for exit = 10

                syscall   # call operating sys

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote