Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Consider the following subroutine (this subroutine adds a data item passed to the subroutine to its local RESULT variable): RESULT SUB ORG FCB




imageimage

2. Consider the following subroutine (this subroutine adds a data item passed to the subroutine to its local RESULT variable): RESULT SUB ORG FCB ORG TSX DATA LDAA ADDA STAA PULX INS PSHX RTS $CFFF 0 ORG FCB $D000 ORG 2,X RESULT RESULT A) Name the parameter passing technique that is utilized (name both methods used: e.g.: call-by-value in register). B) Write the main program segment that will call subroutine SUB and pass DATA to the subroutine using the correct parameter passing technique (do not forget to initialize any crucial processor registers.) You may assume the following data section for your main program: (Subroutine Data Section) $B000 10 (Subroutine Executable Section) $C000 (Main Program Data Section) (Main Program Executable Section) 2 (15 points) Design an assembly language subroutine that receives an array of longword- sized integers (in two's complement representation). The subroutine is to determine how many of the integers in the array are even but not multiples of 4. The input array is to be specified using two parameters: a longword-sized starting address of the array, and a longword-sized number of integers in the array. These two parameters are to be pushed onto the stack (in that order: push address first, and then push the number of integers) before the subroutine is called. The output parameter (i.e., the number of integers that are even but not multiples of 4) of the subroutine is to be returned on the stack and should replace the first input parameter (i.e., starting address of the array). Also write a main program that puts input parameters for an array (which has starting address 0x0006000 and has 400 longword-sized integers) on the stack, calls the subroutine, and retrieves the output parameter from the stack after the subroutine ends. In the main program, the output parameter, which is retrieved from the stack, should be store to data register D3. Note that at the beginning of your main program, you do not know the exact initial value in any data or address register. All registers (except A7) used by the subroutine must be preserved. Hint: For an integer in two's complement representation, if the last two bits (Bit #1 and Bit #0) of the integer's binary format are both zeros, then the integer is a multiple of 4.

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

Calculus

Authors: Ron Larson, Bruce H. Edwards

10th Edition

1285057090, 978-1285057095

More Books

Students also viewed these Computer Network questions

Question

Did the researcher display conflicts and value differences?

Answered: 1 week ago