The starter file is below: #################################### # Name: # ##################################### # # This is the starter code for # the copy array problem in #
The starter file is below:
####################################
# Name:
#
#####################################
#
# This is the starter code for
# the "copy array" problem in
# assignment 4. Note that
# the first 32 lines contain the
# halt instruction. Your job is to
# replace instructions starting at
# the beginning with your own
# instructions to solve part 1. You
# should need fewer than 32
# instructions, so you shouldn't
# have to worry about running out
# of space.
#
# The data for this program starts
# at address 0x20 (or 32 in
# decimal). DO NOT ALTER THE
# LOCATION OF THE DATA GIVEN. The
# autograder will rely on ARRAY_SIZE
# being at address 0x20, ARRAY
# starting at address 0x22, and
# OTHER_ARRAY starting at
# address 0x32.
#
#####################################
#
# Original C Code
# -----------------
# for (int i = 0; i
# {
# OTHER_ARRAY[i] = ARRAY[i];
# }
#
# OR, a better way to think about it:
#
# for (int i = 0; i
# {
# TEMP = ARRAY[i];
# OTHER_ARRAY[i] = TEMP;
# }
#
#####################################
#
# Your program starts here.
0x0 # (ADDR=0x0)
0x0 # (ADDR=0x1)
0x0 # ...
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0 # (ADDR=0xA)
0x0
0x0
0x0
0x0
0x0
0x0 # (ADDR=0x10)
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0 # (ADDR=0x1f)
# Data starts here.
0x0005 # (ADDR=0x20) ARRAY_SIZE
0x0000 # (ADDR=0x21) TEMP
0x0006 # (ADDR=0x22) ARRAY[0]
0xffff # (ADDR=0x23) ARRAY[1]
0xfff7 # (ADDR=0x24) ARRAY[2]
0x0002 # (ADDR=0x25) ARRAY[3]
0x0010 # (ADDR=0x26) ARRAY[4]
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0 # (ADDR=0x32) OTHER_ARRAY[0]
0x0 # (ADDR=0x33) OTHER_ARRAY[1]
0x0 # (ADDR=0x34) OTHER_ARRAY[2]
0x0 # (ADDR=0x35) OTHER_ARRAY[3]
0x0 # (ADDR=0x36) OTHER_ARRAY[4]
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
Part 2 - Copy Array In this problem, you will write a Simple Machine program that copies an array. Start by copying the starter file to your current directory: cp /pub/cs/jpotter/cs270/sim/copy_array Take a look at the starter file. Note that it has each address from Ox0 to Ox22 filled in. Your job is to replace as many lines at the beginning as you need to solve the problem. You should not add any lines, except possibly at the very end Your program should implement the following algorithm, given in a high-level language: for (int i = e; ARRAY-SIZE; i++) OTHER-ARRAY[i] ARRAY[i]; = Note that in the data section of the starter file, ARRAY SIZE is at address Ox20 (decimal 32). I've also put a variable called TEMP at address Ox21 (decimal 33). Each time you put an array value into the accumulator, you'll need to store it in TEMP so that you can start computing the address in OTHER ARRAY where you'll put the value. Once you have the address register set to the address in OTHER ARRAY, you can load TEMP back into the accumulator and store it to the address in the address register. It might help to think of the code like this: for (int 1-0; 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started