LD07: Register-Based Calling Conventions due Thu 07 Nov 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. Modify callc.asm so that:
    • At the beginning of the program put -1 into RAX, RBX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, R12, R13, R14, and R15.
    • Call dump_regs just before and just after your call to displayNums.
    Study the output of the two calls to dump_regs. What does this illustrate?

  3. Modify callc.asm so that it calls the findSuccPos function defined in display.c. Notice the required parameters and return type. Some questions to ponder:
    • How/where do we pass a third parameter?
    • When the function issues return sPos; where is the return value stored?
    • If I call the function like this: findSuccPos(ints,n,40) then what number should be returned?

  4. In callc.asm issue the call findSuccPos(ints,n,40). Display to the screen the index and the array value at the index.

  5. Spend some time playing around with various calls to findSuccPos until you feel comfortable with calling C-language functions.

  6. Show the instructor your completed and working code.

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

Assembly Language

Segmentation Fault Counter

1779740160