๐Subroutine
๐Call instruction
๐Nested loop
✏️SUBROUTINE
๐In assembly language programming it is common to have one main program and many sub routines that are called from the main program.
๐The is allows to make separate module of program known as subroutine.
๐Each module can be tested separately and brought together in main program.
๐More importantly, in a large program the modules can be assigned to different programmers to shorten development time.
✏️CALL INSTRUCTIONS
๐LCALL (long call)
๐ACALL (absolute call)
๐LCALL (LONG CALL)
๐It is a 3 byte instruction.
๐The first byte is the opcode and second and third are used address of target subroutine.
๐This can be used to call subroutines located anywhere within the 64K-byte address space of 8051.
๐When a subroutine is called, control is transferred to that subroutine, processor saves the program counter and begins to fetch instructions from new location.
๐ After execution the subroutine, thee instruction RET (return) control back to the caller.
Syntax : LCALL LABEL
✏️ACALL (ABSOLUTE CALL)
๐ACALL is a 2-byte instruction.
๐Only 11 bits are used as address.
๐While the target address of ACALL must be within a 2K-byte range. In variation of the 8051, on-chip ROM is as low as 1K byte.
๐ In such cases, the use of ACALL instead of LCALL can save a number of bytes of ROM space.
Syntax : ACALL LABEL
✏️NESTED LOOPS
๐A loop within a loop, an inner loop within the outer one
๐The first pass of outer loop triggers the inner loop which executes to completion.
๐Then the second pass of outer loop of outer loop triggers inner loop again
๐This repeats till outer loop FINISHES.
๐SYNTAX
for (initialize counter; test condition; ++ or –)
{
for (initialize counter; test condition; ++ or --)
{
.// inner loop
}
.//outer loop
}
No comments:
Post a Comment
If you have any doubts or clarification you need in my blog topics, I would ๐ฏ try to clear it in an efficient manner as possible. I will also accept your suggestions.