LD06: Macros and The Stack due Thu 24 Oct 13:20

Purpose

In this lab you will learn/practice:

Preparation for Lab Day

Do these steps to get ready for lab day:

Lab Day

  1. At the beginning of the period show your prep work to the instructor.

  2. Take time to read carefully the provided labday.asm code and consider:
    1. Observe the values in RSP and be sure you can explain its changes throughout the code segment.
    2. Observe the values in RAX and RDI and be sure you can explain their changes throughout the code segment.
    3. Why did the contents of RAX and RDI end up being swapped from the original values?

  3. You can comment out or remove the commands you just observed.

  4. Add a macro at the top of the program called madd (short for “memory-to-memory add”). The ultimate goal of the macro is to have it behave exactly like the add command except that it will also work if its parameters are both memory references. Here are some issues/steps to consider:
    1. For this exercise let's make madd work assuming 32-bit integer values.
    2. To support a memory-to-memory add you'll need to put the parameters into registers ... then add the registers ... then put the answer back in the destination.
    3. Your macro should not destroy any registers. Since you need to use registers for temporary work in your macro you'll need to save contents of those regsiters on the stack and then restore them after the macro is finished.
    4. Be sure to test memory-to-memory adds.
    5. Also test register-to-register adds.
    6. Also test what happens if the registers being added are the same as the parameters that are passed to the macro.

  5. Show the instructor your completed and tested madd macro.

  6. If you finish early, work on your homework assignment until the end of the lab period.

Assembly Language

Segmentation Fault Counter

1779740194