A subroutine is a set of instructions that will be used repeatedly in different locations of the program. Instead of repeating the same instructions several times, they can be combined into a subroutine that is called from various locations. A subroutine in Assembly language can exist anywhere in the code. However, It is a common practice to separate subroutines from the main program.
The 8085 microprocessor has two instructions to implement subroutines. The CALL
instruction is used to redirect program execution to a subroutine. The RET
instruction is used to return the execution to the calling routine. They are described in the following table.
MNEMONIC | DESCRIPTION |
---|---|
CALL 16-bit address | 3-byte instruction. Jumps unconditionally to the memory location specified. |
RET | 1-byte instruction. Unconditionally returns from the subroutine. |
When the CALL
instruction has been executed the contents of the program counter is saved to the top of the stack. This return address is retrieved from the stack when the RET
instruction is executed.
my teacher take class by using this post
this is very use full.
thank you for posting this
by the by my name is suryadas
lot of thanks
Thank you for your comment, Suryadas! We’re glad to hear that the post was helpful for you and that your teacher was able to use it in their class. It’s great to know that the information provided was useful to both you and your teacher. Thanks again for your kind words!
yeah…in my college also our faculties used to teach from this website it is very usefull.
My name is devraj from kolkata.
and i am in brainware university