.globl main # Defines .eqv PRINT_INT 1 .eqv PRINT_STR 4 .eqv EXIT_CODE 93 .data input: .word 5 output: .word 0 result_str: .asciz "!= " .text # The location for the input data # allocates 4 byte set to 5 # The location for the output data # allocates 4 byte set to 0 # The location for the result string data # allocates 1 byte per chacter plus null character

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

pleaseeeeee solve parts 1, 2

.globl main
# Defines
.eqv PRINT_INT 1
.eqv PRINT_STR 4
.eqv EXIT_CODE 93
.data
input:
.word 5
output:
.word 0
result_str:
.asciz "!= "
.text
main:
lw a0, input
jal fact_func
la to, output
sw a0, 0(t0)
exit:
lw a0, input
li a7, PRINT_INT
ecall
la a0, result_str
li a7, PRINT_STR
ecall
lw a0, output
li a7, PRINT_INT
ecall
li a0, 0
li a7, EXIT_CODE
ecall
ebreak
li to, 1
ble a0, to, done_fact
addi to, a0,-1
li a0,1
li t2,1
blez to,done_fact
addi t2, t2,1
mul a0, a0, t2
addi to, t0,-1
j do_fact
fact_func:
do_fact:
done_fact:
ret
# The location for the input data
# allocates 4 byte set to 5
# The location for
the output data
# allocates 4 byte set to 0
# The location for the result string data
# allocates 1 byte per chacter plus null character
# Label for start of program
# Load input Value
#
Jump and link (save return address) to factorial function
# Load output address to to
# Save output value to output memory location
# Load Input value into ao
# System call code for print_int code 1
# Make system call
# Put result_str address in a0
# System call code for print_str code 4
# Make system call
# Load output value into a0
# System call code for print_int code 1
# Make system call
# Exit (93) with code 0
# System call value
#Make system call
# Finish with breakpoint
# Loads the value 1 into a to
# If Input is 1 or less, then skip to end
# Put input-1 into to
# Load 1
# Load 1
# If t0 is less than or equal to zero then jump to end
# Increment t2 by 1
# Mul t2 by a0 to get next factorial
# decrement to
#jump to top of loop to do next factorial until to is 0
# Use return address to get back to main
Transcribed Image Text:.globl main # Defines .eqv PRINT_INT 1 .eqv PRINT_STR 4 .eqv EXIT_CODE 93 .data input: .word 5 output: .word 0 result_str: .asciz "!= " .text main: lw a0, input jal fact_func la to, output sw a0, 0(t0) exit: lw a0, input li a7, PRINT_INT ecall la a0, result_str li a7, PRINT_STR ecall lw a0, output li a7, PRINT_INT ecall li a0, 0 li a7, EXIT_CODE ecall ebreak li to, 1 ble a0, to, done_fact addi to, a0,-1 li a0,1 li t2,1 blez to,done_fact addi t2, t2,1 mul a0, a0, t2 addi to, t0,-1 j do_fact fact_func: do_fact: done_fact: ret # The location for the input data # allocates 4 byte set to 5 # The location for the output data # allocates 4 byte set to 0 # The location for the result string data # allocates 1 byte per chacter plus null character # Label for start of program # Load input Value # Jump and link (save return address) to factorial function # Load output address to to # Save output value to output memory location # Load Input value into ao # System call code for print_int code 1 # Make system call # Put result_str address in a0 # System call code for print_str code 4 # Make system call # Load output value into a0 # System call code for print_int code 1 # Make system call # Exit (93) with code 0 # System call value #Make system call # Finish with breakpoint # Loads the value 1 into a to # If Input is 1 or less, then skip to end # Put input-1 into to # Load 1 # Load 1 # If t0 is less than or equal to zero then jump to end # Increment t2 by 1 # Mul t2 by a0 to get next factorial # decrement to #jump to top of loop to do next factorial until to is 0 # Use return address to get back to main
Part 2.3: Example #2
1. What is the printout when the program is
executed?
2. What is the cycle count when the program
finishes?
3. What system calls are used?
4. In what register does the "jal fact_func"
command store the return address?
5. Change the input value, what is the lowest
positive input that returns a negative output?
why?
Transcribed Image Text:Part 2.3: Example #2 1. What is the printout when the program is executed? 2. What is the cycle count when the program finishes? 3. What system calls are used? 4. In what register does the "jal fact_func" command store the return address? 5. Change the input value, what is the lowest positive input that returns a negative output? why?
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY