1732 x 546 ----- _______________________________________________________________
ID: 3576485 • Letter: 1
Question
1732
x 546
-----
________________________________________________________________
MY WORK BELOW-
.data
promptA: .asciiz "Enter number A: "
promptB: .asciiz "Enter number B: "
Result: .asciiz "The multiplication product is: "
.text
main:
li $v0, 4 # System call for print String
la $a0, promptA # load address of prompt in $a0
syscall
li $v0, 5 # system call code for read int
syscall # read num into $v0
move $t1, $v0 # copy num into $t1
li $v0, 4 # System call for print String
la $a0, promptB # load address of prompt in $a0
syscall
li $v1, 5 # system call code for read int
syscall # read num into $v0
move $t2, $v1 # copy num into $t1
initializer:
li $s1, 1 # shift = 1
li $t3, 0 # product = 0
for:
beq
sll $t4, $t2, 1 # shift 1
mul $t4, $t1 # multiply with each digit
mflo $t5 # save that to $t5
add $t6,$t6, $t5 # product + shift * subprod
mul $s1, $s1, 10
b for
End:
li $v0, 1 # system call code for print int
syscall # print prompt
li $v0, 4 # system call code for print string
la $a0, result # load addr of projector in $a0
syscall
li $v0, 1 # system call code for print int
syscall # print prompt
Explanation / Answer
shift = 1
product = zero
for every digit d of b, ranging from the 1's column ten
}
1732
x 546
-----
10392 (1732 * half-dozen * 1)
6928 (1732 * four * 10)
8660 (1732 * five * 100)
------
945672
________________________________________________________________
MY WORK BELOW-
.data
promptA: .asciiz "Enter variety A: "
promptB: .asciiz "Enter variety B: "
Result: .asciiz "The multiplication product is: "
.text
main:
li $v0, four # supervisor call instruction for print String
la $a0, promptA # load address of prompt in $a0
syscall
li $v0, five # supervisor call instruction code for browse int
syscall # browse num into $v0
move $t1, $v0 # copy num into $t1
li $v0, four # supervisor call instruction for print String
la $a0, promptB # load address of prompt in $a0
syscall
li $v1, five # supervisor call instruction code for browse int
syscall # browse num into $v0
move $t2, $v1 # copy num into $t1
initializer:
li $s1, one # shift = one
li $t3, zero # product = zero
for:
beq
sll $t4, $t2, one # shift one
mul $t4, $t1 # multiply with every digit
mflo $t5 # save that to $t5
add $t6,$t6, $t5 # product + shift * subprod
mul $s1, $s1, 10
b for
End:
li $v0, one # supervisor call instruction code for print int
syscall # print prompt
li $v0, four # supervisor call instruction code for print string
la $a0, result # load addr of projector in $a0
syscall
li $v0, one # supervisor call instruction code for print int
syscall # print prompt
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.