Abstract
Modular design of software circuits is the fundamental organization of choice.
The subroutine is introduced as the means of implementating program modules. Properties of the PIC18 Hardware stack and its interaction with the call-return mechanism are used to illustrate the operation of both simple and nested subroutines. The concept and execution of transparent subroutines, together with the use of Hardware and Software stack structures and the optional Extended instruction set, to pass and return parameters, is also covered.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
From Chambers Science and Technology Dictionary, Cambridge University Press, 1988.
- 2.
Other high-level languages use the terms function (C and Pascal) or procedure (Pascal).
- 3.
The 12-bit base-range core devices have only two 11-bit stack registers and the mid-range core has an 8-deep 13-bit Hardware stack.
- 4.
Known to C programmers as a DO-WHILE loop.
- 5.
Known to C programmers as a WHILE loop.
- 6.
But see Program 15.5 in The Quintessential PIC® Microcontroller, Springer, 2nd ed. 2005 for an exception.
- 7.
Confusingly, in some devices, including the PIC18F1220, this is called STVR.
- 8.
The instruction movff should not be used with the TOS or PC registers as destination as corruption may occur if interrupts are in use, but they can be used as source data.
- 9.
Note that movff cannot be used to do this copy operation into the PCL in one, as the PC, TOS and INTCON registers are forbidden as destination for this instruction.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2010 Springer-Verlag London Limited
About this chapter
Cite this chapter
Katzen, S. (2010). Subroutines and Modules. In: The Essential PIC18® Microcontroller. Computer Communications and Networks. Springer, London. https://doi.org/10.1007/978-1-84996-229-2_6
Download citation
DOI: https://doi.org/10.1007/978-1-84996-229-2_6
Publisher Name: Springer, London
Print ISBN: 978-1-84996-228-5
Online ISBN: 978-1-84996-229-2
eBook Packages: Computer ScienceComputer Science (R0)