Question

Lab 5

1. Download the Assembly Template from Canvas

2. Extract the contents somewhere on your computer. I would recommend making Lab 5 directory

3. Plug in the MSP432 using the USB cable provided into the computer

4. Open Assembly Template Project in the Keil IDE

5. Review Lecture 11 and 12 presented in class. These lectures talk about the Stack, the Stack Pointer,

Subroutines, Parameter Passing Techniques, and Do-No-Damage Paradigm

6. The goal of this Lab is to create two Subroutines, Math1 and Math2 the functions are defined below in C,

you need to write them in assembly.

unsigned int32 Mathl (unsigned int32 a, unsigned int32 b, un

signed int32 e)

{

}

{

if (e==0) {

}

}

else{

}

return (a+b);

unsigned int32 Math2 (unsigned int32 a, unsigned int32 b, unsigned

int32 c,

unsigned int32 d)

return (a-b);

return (Mathl(a,b) * c / d);

Requirements:

1. You must call Math2 from the Main Program, Math2 must call Math1

2. You must use the stack pointer to pass in parameters.

3. You must use the Do-No-Damage Paradigm.

4. You can return values in registers just be sure you do not delete information you still need.

5. You can only use Register 0-3 for the initialization of a,b,c,d and returning data from function.

6. For the lab sign-off a = 78, b = 56, c = 34, d = 12. You must present a visual representation of the stack

during lab sign-off.

Hints

1. The debugger is your best friend. You can track the SP, register values and slowly walk through this lab

with it. The more you use the debugger the easier this lab will be. Remember to use breakpoints as well!

2. 'e' is only used to determine addition or subtraction using 'CMP' and 0 and 1 values.

3. Use Branch instructions to select between addition and subtraction.

4. We are using the stack pointer (predefined as SP) and Link register (predefined as LR) to pass parameters

and store results to the variables/registers.

Question image 1