Skip to main content

Subroutines and Modules

  • Chapter
  • 1941 Accesses

Part of the book series: Computer Communications and Networks ((CCN))

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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   84.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   119.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD   109.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    From Chambers Science and Technology Dictionary, Cambridge University Press, 1988.

  2. 2.

    Other high-level languages use the terms function (C and Pascal) or procedure (Pascal).

  3. 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. 4.

    Known to C programmers as a DO-WHILE loop.

  5. 5.

    Known to C programmers as a WHILE loop.

  6. 6.

    But see Program 15.5 in The Quintessential PIC® Microcontroller, Springer, 2nd ed. 2005 for an exception.

  7. 7.

    Confusingly, in some devices, including the PIC18F1220, this is called STVR.

  8. 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. 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

Authors

Corresponding author

Correspondence to Sid Katzen .

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics