answersLogoWhite

0


Best Answer

In computer programming, a subroutine is an identified sequence of instructions with a start and an end point which may be invoked from another part of the program. When a subroutine is called, the processor executes the instructions until it reaches the end of the subroutine, at which point control is returned to the point in the program immediately following the call.

In most programming languages, a set of conventions are followed which allow values to be passed into the subroutine and for a result to be returned, so that the subroutine can be used in many different contexts. This is the most basic form of reusable software.

In higher-level languages, functions and methods are specialized forms of subroutines.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

In computer programming, subroutines are parts of code that can be called to run.

the cool part is that you can then call that part of code by it's subroutine name any time you want it to run.

If you had a list of people to email, you could loop through all the people, and one at a time send them to the email subroutine.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are subroutines?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Computer Science

What are the Advantages of using subroutines?

Subroutines can be used repeatedly without having to be rewritten each time they are used.


What is an absolute loader?

An absolute loader is the simplest type of loader scheme that fits the general model of loaders. The assembler produces the output in the same way as in the "complier and go loader" . The assembler outputs the machine language translation of the source program.Disadvantage:The programmer has to specify the address to the assembler that where the program is to be loaded.It is very difficult to realocate in case of multiple subroutine.Programmer has to remember the address of each subroutine and use that absolute address explicitly in other subroutines to perform subroutine linkage


Difference between open subroutine and closed subroutine?

A closed subroutine is a normal unit like a function in C or a method in Java. When a closed subroutine is called, the program branches to the file/section of code, executes, and then returns to the line after the calling line.For example, if you had the following code in Java:main(...) {int a = 1;int b = 4;multiply(1,4);System.out.println("done!");}multiply(int a, int b) {int answer = 0;for(int i = 0; i < 4; i++)answer*=a;return answer;}Over here, the main method executes until it reaches multiply(1,4) and then jumps to the function (declared below main) and executes that. After it finishes executing multiple, it returns to the line after the function call, which in our case is System.out.println, and executes that.An open subroutine is a subroutine that adds the instruction to the already existing block of code. That is, it replaces the one line call with the entire set of instructions.For example, if you had the following code:startsave 1 in asave 4 in bmultiply a b-timesendThe command "multiply a b-times" is an open subroutine because the command will add lines at compile time to the existing code to return the following (this is best understood when thinking of the code as machine code):(translated from machine code)startsave 1 in asave 2 in bADDED CODEsave a * a in csave c * a in dsave d * a in ereturn eendAs you can see, the "multiply" command has been replaced with the entire set of instructions (under ADDED CODE).In short, an open subroutine adds lines to your main code while a closed subroutine is code stored in a separate block of code. Both subroutines are called with a single line of code.


What is address sequencing in computer organization?

Microinstructions are stored in control memory in groups, with each group specifying routine. Each computer instruction has its own microprogram routine in control memory to generate the microoperations that execute the instruction. The hardware that controls the address sequencing of the control memory must be capable of sequencing the microinstructions within a routine and be able to branch from one routine to another. To appreciate the address sequencing in a microprogram control unit, let us enumerate the steps that the control must undergo during the execution of a single computer instruction. An initial address is loaded into the control address register when power is turned on in the computer. This address is usually the address of the first microinstruction that activates the instruction fetch routine. The fetch routine may be sequenced by incrementing the control address register through the rest of its microinstructions. At the end of the fetch routine, the instruction is in the instruction register of the computer. The control memory next must go through the routine that determines the effective address of the operand. A machine instruction may have bits that specify various addressing modes, such as indirect address and index registers. The effective address computation routine in control memory can be reached through a branch microinstruction, which is conditioned on the status of the mode bits of the instruction. When the effective address computation routine is completed, the address of the operand is available in the memory address register. The next step is to generate the microoperations that execute the instruction fetched from memory. The microoperation steps to be generated in processor register depend on the operation code part of the instruction. Each instruction has its own microprogram routine stored in a given location of control memory. The transformation from the instruction code bits to an address in control memory where the routine is located is referred to as a mapping process. A mapping procedure is a rule that transforms the instruction code into a control memory address. Once the required routine is reached, the microinstructions that execute the instruction may be sequenced by incrementing the control address register, but sometimes the sequence of microoperations will depend on values of certain status bits in processor registers. Micro programs that employ subroutines will require an external register for storing the return address. Return addresses cannot be stored in ROM because the unit has no writing capability. When the execution of the instruction is completed, control must return to the fetch routine. This is accomplished by executing an unconditional branch microinstruction to the first address of the fetch routine. In summary, the address sequencing capabilities required in control memory are: 1. Incrementing of the control address register. 2. Unconditional branch or conditional branch, depending on statues bit conditions. 3. A mapping process from the bits of the instruction to an address for control memory. 4. A facility for subroutine call and return.


Related questions

What are the Advantages of using subroutines?

Subroutines can be used repeatedly without having to be rewritten each time they are used.


What are Submodules also known as?

subroutines


Can we add two subroutines in VBA macro?

Yes.


What has the author Peter J Johnson written?

Peter J Johnson has written: 'FORTRAN subroutines for VAX/VMS block I/O' -- subject(s): Subroutines (Computer programs), FORTRAN (Computer program language)


What are subroutines and are they used in batch files scripts neither or both?

Subroutines are code blocks that can be called from anywhere in your code where the subroutine is within the scope of the caller. They are not used in batch files or command scripts, but they may be emulated by calling one batch file from another and waiting for the external call to return, which may (optionally) return an error level which can be tested by the caller. Subroutines can be used in other scripts, including vbscript and javascript. Subroutines may also be called functions or procedures depending on the type of script.


What are the basic program structures in visual basic?

Classes Structures Subroutines Functions


What has the author S Marlow written?

S. Marlow has written: 'Fortran subroutines for the solution of linear equations, inversion of matrices and evaluation of determinants' 'Fortran subroutines for the solution of linear equations' 'Flexible specialisation and the large enterprise'


Why do people use subroutines?

Subroutines can be used for a set calculation, for instance adding 10 years to today or to return how many seconds have passed since 3.75 hours ago or an APR rate of a specified dollars amount.


What is a function procedure in Visual Basic?

A function is essentially a subroutine that is ment to be used by other subroutines.


What is a term used as a synonym for module in any programming language?

subroutines procedures functions or methods


The OS has several subsystems or OS subroutines that use the user mode and interface with the user and with applications?

modules


What has the author Anne P Ladd written?

Anne P. Ladd has written: 'Subroutines reference guide'