7. What is the value at the "output" address at the end of the program?

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 part 7

Part 2.2: Example #1
1. How many extended (pseudo) instructions are
there in this example?
2. What does the last instruction do?
3. Why does "lw a0,input" use the auipc
command when assembled?
4. What are ".globl,.data,.text, and .word" and
what do they mean?
5. What instruction does "j do_fact" translate to?
why does it use x0?
6. What is the cycle count when the simulator
gets to the first "j exit_loop"? (step through the
program)
7. What is the value at the "output" address at
the end of the program?
Transcribed Image Text:Part 2.2: Example #1 1. How many extended (pseudo) instructions are there in this example? 2. What does the last instruction do? 3. Why does "lw a0,input" use the auipc command when assembled? 4. What are ".globl,.data,.text, and .word" and what do they mean? 5. What instruction does "j do_fact" translate to? why does it use x0? 6. What is the cycle count when the simulator gets to the first "j exit_loop"? (step through the program) 7. What is the value at the "output" address at the end of the program?
###
####
# example_1.s
# Name: Andrew E Wilson
# Date: 1/22/2020
# Simple Factorial Program
#
######### ###########
.globl main
data
input:
.word 4
output:
.word 0
.text
main:
lw a0, input
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, to, -1
j do_fact
la to, output
sw a0,0(to)
j exit_loop
#
do_fact:
done_fact:
exit_loop:
# The location for the input data
# allocates 4 byte set to 4
# The location for the output data
# allocates 4 byte set to 0
# Label for start of program
# Loads the input value from memory
# 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 to 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
# Load output address to to
# Save output value to output memory location
# Loop Exit
Transcribed Image Text:### #### # example_1.s # Name: Andrew E Wilson # Date: 1/22/2020 # Simple Factorial Program # ######### ########### .globl main data input: .word 4 output: .word 0 .text main: lw a0, input 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, to, -1 j do_fact la to, output sw a0,0(to) j exit_loop # do_fact: done_fact: exit_loop: # The location for the input data # allocates 4 byte set to 4 # The location for the output data # allocates 4 byte set to 0 # Label for start of program # Loads the input value from memory # 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 to 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 # Load output address to to # Save output value to output memory location # Loop Exit
Expert Solution
steps

Step by step

Solved in 3 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