Make sure you have the most recent version of the homework repository which
included a hw09 directory in which you will do your work.
For these exercises you will make use of the provided display.c and
callc.asm files.
Open display.c and look at the function called displayNums.
Observe the syntax and try to interpret the function of the code.
Open callc.asm and notice:
use of the extern keyword
how the displayNums function is called
Follow the compilation instructions at the top of callc.asm to
compile and run the program.
At the beginning of the period show your prep work to the instructor.
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?
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?
In callc.asm issue the call findSuccPos(ints,n,40). Display
to the screen the index and the array value at the index.
Spend some time playing around with various calls to findSuccPos
until you feel comfortable with calling C-language functions.
Show the instructor your completed and working code.
If you finish early, work on your homework assignment until the end of
the lab period.