EMBSYS100 Module 6- pass-by-value nature of C Solved

30.00 $ 15.00 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


Rate this product

The goals for the assignment this week:

  1. To gain in depth understanding of the pass-by-value nature of C.
  2. To gain hands on experience with the ARM Cortex-M4 assembly language.


  1. Create a function that allows swapping of two pointers.
    1. Explain what the “main” function does to the CSTACK in order setup the input arguments prior to calling the swap_pointer() function?
    2. And what are the values in R0 & R1 when swap_pointer() is called?
    3. Share a screen shot of the local variables inside of “main” after the function swap_pointer() returns, showing the values of the pointers and what they are pointing to, similar to the picture below:
  1. Run sqrAsm code from the class demo:
    1. Copy HelloWorld from Assignment 1.
    2. Download the file s and copy it to the project directory.
    3. In IAR, add sqrAsm.s file to your project. Now you should be able to see the file from the Workspace Window.
    4. Modify main.c to call sqrAsm function.
    5. Run your program on the board, and capture a snapshot image of the output from TeraTerm.
  2. Create a new file s and add the file to the same HelloWorld project above.
    1. Write the assembly code to take an input argument, divide it by 2, and return the result.
    2. Invoke the function “PrintString” from within divAsm before doing the division computation.
    3. Add a comment for every statement in your assembly function code.
    4. In the main.c, invoke dev2Asm(foo) and capture the screen output from TeraTerm.
  1. Implement a swap function in assembly and call it “swapCharsAsm”:
    1. It takes as input two variables of char data type and swaps the two chars
    2. Add a comment for every statement in your assembly function code.
    3. Bonus: Returns 0 if the two chars are identical; otherwise, return 1.
  1. Bonus: Implement the swap_pointer() function from #1 above in assembly and call it swapPointersAsm().
    1. Add a comment for every statement in your assembly function code.
    2. Take a snap shot of the output after invoking the swapPointerAsm() subroutine.
  • module06-njuvfb.zip