answersLogoWhite

0

What is subroutine?

Updated: 8/10/2023
User Avatar

Wiki User

15y ago

Best Answer

Subroutine is an instruction sequence in a machine or assembly language program that can be prewritten and referred to as often as needed. Subroutine is used for controlling thing e.g. traffic lights burglar alarms they all use subroutine

User Avatar

Wiki User

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

Wiki User

15y ago

A set of instructions that performs a specific task for a main routine, requiring direction back to the proper place in the main routine on completion of the task.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

subroutine is nothing but the sub-program or part of that program.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is subroutine?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is subroutine in java?

Subroutine mean what (in java)?


What are subroutine linkages?

The Mechanism that makes possible to transfer control between the calling program and Subroutine is reffered to as SUBROUTINE LINKAGE


What is main difference between macro and subroutins?

marco expand where it invoked ,subroutine will go where the subroutine is defined....


What is a single computer function that initiates a string of commands?

A call to a subroutine. A subroutine is a named/labeled set of commands.


Difference between interrupt and subroutine in computer?

interrupt is a signal caused by I/O devices where as subroutine is a part of the program which is excuted rapidly


What is subroutine in 8085?

in 8085 microprocessor a subroutine is a separate program written aside from main program ,this program is basically the program which requires to be executed several times in the main program. the microprocessor can call subroutine any time using CALL instruction . after the subroutine is executed the subbroutine hands over the program to main program using RET instruction.


What actors and actresses appeared in Could It Be - 2008?

The cast of Could It Be - 2008 includes: Richard Wientzek as Subroutine 1 Klas Yngborn as Subroutine 2


3 What is the difference between a function procedure and a subroutine procedure?

Both a function and a subroutine are examples of out-of-line execution calls to code. The main difference is that a function call can be part of an expression and returns a value, whereas the subroutine can be called standalone and does not return a value.


Difference between delay subroutine and ordinary subroutine in context of 8085?

a subroutine is a portion of the code within a larger program which performs a specific function and is independent of remaining code.....delay routines are subroutines used for maintaining the timings of various operations in microprocessor


Why may you recommend the use of a macro instead of a subroutine inside a loop in a program?

A subroutine call generates additional work for the hardware to perform when activated. A macro in general does not call a subroutine but rather puts the commands in-line inside the loop, resulting in a faster program.


How can a stack be used for implementing a subroutine call?

A stack can be used to implement a subroutine call because the return address is pushed onto the stack, and control transfers to the subroutine. If the subroutine were to then call another subroutine, or even itself, a second return address would be pushed. When the subroutine returns control, the return address is popped off of the stack and control transfers to the return address.In addition, the stack can be used to pass arguments. The caller can push the arguments onto the stack before calling the subroutine. The subroutine can then access the arguments by making references relative to the stack pointer. When the subroutine returns control, the caller then pops the arguments off of the stack.Further, the subroutine can use the stack to store local variables. It adjusts the stack pointer in the direction of pushing things onto the stack, and then make references to that region of memory between the original value of the stack pointer and the new value of the stack pointer.This is exactly how most subroutines work on the 8086/8088 (and higher) processors...The caller pushes arguments on the stackThe caller calls the subroutine, pushing the return address on the stackThe subroutine pushes caller registers onto the stack, if that is the agreed convention for that callThe subroutine pushes the BP register on the stack and then copies the stack pointer (SP) to BPThe subroutine adjusts SP downward, allocating the required local memoryThe subroutine accesses arguments with [BP+offset] addressingThe subroutine accesses local variables with [BP-offset] addressingWhen the subroutine is done, it sets SP back to BP, pops caller's registers off of the stack, pops caller's return address off of the stack, and then returns to the callerThe caller then pops the arguments off of the stack.The structure in memory, representing arguments, return address, saved registers if needed, and local variables, with BP in the center, is called a stack frame.Done properly, a subroutine can be fully recursive, even able to call itself, or be called by other threads, because all local variables and the registers if saved are stored on the stack. The ability to be recursive is also called reentrancy.


Another name for method?

* Function * Subroutine * Procedure