Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a subroutine which satisfies the following: Name: NElements When the subroutine is entered it expects the stack to look as follows (as looked in

Write a subroutine which satisfies the following:

Name: NElements When the subroutine is entered it expects the stack to look as follows (as looked in word increments):

Top of the stack > PC counter value

Space for output

Input

Runs Properly on MSP430G2553 launch pad using Code Composer w/ Assembly Language

Subroutine expects the Input on the stack as shown above: The input is the starting address of an array consisting of word length elements. The last element of the array is expected to be 999.

Subroutine will place one word of output on the stack in the space as shown above: Output is the number of words in the array (not counting the last word which equals 999) whose starting address is in the input.

The subroutine only works with arrays whose last element is 999. It calculates the number of elements in an array not counting the last element 999.

For example the array: 2, 45, 67,34, 1, 999 has 5 number of elements.

The subroutine should save all local variables on the stack. You will need to use Indirect Register Mode for iterating through the array for which you will need to use a core register. Use R10 for this purpose. As soon as you enter the subroutine, save the existing value of R10 by pushing it on the stack. Just before exiting the subroutine pop the saved value back into R10.

Test this subroutine in main code by using an array Named MyArray with word elements [2, 3, 67, 34, 1, 999] placed in the .text region and storing the output in a variable named "Result". Use loops for repeated tasks.

Include pseudo code (subroutine only), flow chart (subroutine only) and the text of the assembly file (main program + subroutine). Also include a screen shot of the memory browser which shows the variable "Result" clearly.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago

Question

Be familiar with the basic ways to manage capacity.

Answered: 1 week ago