Question: Factorial iterative.asm .include ./cs47_macro.asm .data msg1: .asciiz Enter a number ? msg2: .asciiz Factorial of the number is charCR: .asciiz .text

 Factorial iterative.asm .include "./cs47_macro.asm" .data msg1: .asciiz "Enter a number ?

Factorial iterative.asm

.include "./cs47_macro.asm"

.data

msg1: .asciiz "Enter a number ? "

msg2: .asciiz "Factorial of the number is "

charCR: .asciiz " "

.text

.globl main

main: print_str(msg1)

read_int($t0)

# Write body of the iterative

# factorial program here

# Store the factorial result into

# register $s0

#

# DON'T IMPLEMENT RECURSIVE ROUTINE

# WE NEED AN ITERATIVE IMPLEMENTATION

# RIGHT AT THIS POSITION.

# DONT USE 'jal' AS IN PROCEDURAL /

# RECURSIVE IMPLEMENTATION.

print_str(msg2)

print_reg_int($s0)

print_str(charCR)

exit

cs47_macro.asm

## # Macro : print_str # Usage: print_str(

) .macro print_str($arg) li $v0, 4 # System call code for print_str la $a0, $arg # Address of the string to print syscall # Print the string .end_macro # Macro : print_int # Usage: print_int() .macro print_int($arg) li $v0, 1 # System call code for print_int li $a0, $arg # Integer to print syscall # Print the integer .end_macro # Macro : exit # Usage: exit .macro exit li $v0, 10 syscall .end_macro .macro read_int($reg) li $v0,5 syscall move $reg,$v0 .end_macro .macro print_reg_int($reg) li $v0, 1 move $a0, $reg syscall .end_macro

.macro swap_hi_lo($temp1,$temp2) mfhi $temp1 mflo $temp2 move $t2, $temp1 move $t3, $temp2 mthi $t3 mtlo $t2 .end_macro .macro print_hi_lo($strHi, $strEqual, $strComma, $strLo) print_str($strHi) print_str($strEqual) li $v0,1 mfhi $a0 syscall print_str($strComma) print_str($strLo) print_str($strEqual) li $v0,1 mflo $a0 syscall .end_macro .macro lwi ($reg, $ui, $li) lui $reg, $ui ori $reg, $li .end_macro

Instructions: . Download Factorial Iterative.asm n in a directory. Copy your updated cs47_macro.asm from PA03 in the same directory. . Complete the Factorial_Iterative.asm to implement iterative factorial calculation . Assemble and execute Factorial_Iterative.asm This should create following sample output Enter a number? 10 Factorial of the number is 3628800 Upload updated Factorial_Iterative.asm (do not change the file name) Outline of high level iterative factorial. int product 1; for (int j-1; jN; j++) product *= j; Instructions: . Download Factorial Iterative.asm n in a directory. Copy your updated cs47_macro.asm from PA03 in the same directory. . Complete the Factorial_Iterative.asm to implement iterative factorial calculation . Assemble and execute Factorial_Iterative.asm This should create following sample output Enter a number? 10 Factorial of the number is 3628800 Upload updated Factorial_Iterative.asm (do not change the file name) Outline of high level iterative factorial. int product 1; for (int j-1; jN; j++) product *= j

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 Databases Questions!