Page 182 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 182

Introduction to Microprocessors                                Dinesh Kumar, Lovely Professional University


                  Notes                                   Unit 13: Subroutines



                                   CONTENTS

                                   Objectives
                                   Introduction
                                   13.1 Subroutine
                                   13.1.1 Definition
                                   13.1.2 Calling a Subroutine
                                   13.1.3 Exiting a Subroutine
                                   13.2 Restart Sequence
                                   13.3 Conditional Call Instruction

                                   13.3.1 Subroutine call
                                   13.3.2 Trap subroutine call activation/deactivation
                                   13.4 Return Instruction
                                   13.5 Summary
                                   13.6 Keywords
                                   13.7 Self-Assessment Questions

                                   13.8 Review Questions
                                   13.9 Further Reading


                                 Objectives

                                 After studying this unit, you will able to understand the following:
                                 •  Explain the definition of subroutine

                                 •  Describe how to create a subroutine
                                 •  Explain the procedure to call a subroutine
                                 •  Describe about restart sequence

                                 •  Define conditional call instruction and its uses; and
                                 •  Explain return instruction

                                 Introduction

                                 A subroutine is a container that holds a series of VBScript statements. Suppose you'd like to
                                 create a block of code that accomplishes some specific task. Maybe you need to accomplish that
                                 task in various places throughout your code. All you need to do is create, or declare, the subroutine
                                 in your script. Once you've declared the subroutine, you can call it anywhere within your code.
                                 When your program calls a subroutine, the flow of the code is temporarily diverted to the
                                 statements within the subroutine.
                                 Once the subroutine has finished executing, control returns to the code that called the subroutine
                                 and execution picks up from there. A subroutine is a block of code that can be called from anywhere
                                 in a program to accomplish a specific task. Subroutines can accept starting data through subroutine



        176                              LOVELY PROFESSIONAL UNIVERSITY
   177   178   179   180   181   182   183   184   185   186   187