Chapter13Writing Your Own Functions¶
Good software engineering practice generally includes breaking problems down into functionally distinct subproblems. This leads to software solutions with many functions, each of which solves a subproblem. This “divide and conquer” approach has some distinct advantages:
It is easier to solve a small subproblem.
Previous solutions to subproblems are often reusable.
Several people can be working on different parts of the overall problems simultaneously.
The main disadvantage of breaking a problem down like this is coordinating the many partial solutions so that they work together correctly to provide a correct overall solution. In software, this translates to making sure that the interface between a calling function and a called function works correctly. In order to ensure correct operation of the interface, it must be specified in a very explicit way.
In Section 10.1 you learned how to pass arguments to a function and call it. In this chapter you will learn how to use these arguments inside the called function. You will also learn how to pass more arguments to a function than can be done with the four registers specified in Table 10.1.1.