CS250 Lab 5: Practice with Functions
Due Monday, March 10
For this lab, write a function called "square", that takes as a parameter a number, and returns the square of that number.
We haven't discussed multiplication yet. As part of this lab, please look at the documentation from Intel on this (page 1376 of this .pdf document): https://software.intel.com/en-us/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4
Remember, Intel syntax uses a different register order than the AT&T syntax used in our book. In particular, pay attention to the note that the destination operand is in eax, and the result is stored there as well. This is different than add, which can be done on any two registers.
Write some kind of test code to show that your function works. You'll have to use small values for now, because the way we've been returning numbers with exit only allows values up to 255. If you remember how to use GDB, you can test with a larger number, stop execution before the end, and look at the register values to see if it worked. Appendix F in the book explains how to use GDB with assembly.