Page 188 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 188
Introduction to Microprocessors
Notes In the HP 2100, the JSB instruction would perform a similar task, except that the return address
was stored in the memory location that was the target of the branch. Execution of the procedure
would actually begin at the next memory location. In the HP 2100 assembly language, one
would write, for example
...
JSB MYSUB (Calls subroutine MYSUB.)
BB ... (Will return here after MYSUB is done.)
to call a subroutine called MYSUB from the main program. The subroutine would be coded
as
MYSUB NOP (Storage for MYSUB's return address.)
AA ... (Start of MYSUB's body.)
...
JMP MYSUB,I (Returns to the calling program.)
The JSB instruction placed the address of the NEXT instruction (namely, BB) into the location
specified as its operand (namely, MYSUB), and then branched to the NEXT location after that
(namely, AA = MYSUB + 1). The subroutine could then return to the main program by
executing the indirect jump JMP MYSUB,I which branched to the location stored at location
MYSUB.
Compilers for Fortran and other languages could easily make use of these instructions when
available. This approach supported multiple levels of calls; however, since the return address,
parameters, and return values of a subroutine were assigned fixed memory locations, it did
not allow for recursive calls.
Incidentally, a similar technique was used by Lotus 1-2-3, in the early 1980s, to discover the
recalculation dependencies in a spreadsheet. Namely, a location was reserved in each cell to
store the "return" address. Since circular references are not allowed for natural recalculation
order, this allows a tree walk without reserving space for a stack in memory, which was very
limited on small computers such as the IBM PC.
Questions:
1. Define Self-modifying code in the term of subroutines.
2. Explain the concept of jumping in the subroutines.
13.5 Summary
• A subroutine is a block of code that can be called from anywhere in a program to accomplish
a specific task.
• The discipline of object-oriented programming is based on objects and methods.
• The name of a subroutine should adequately describe what the subroutine is for.
• You can call subroutines by using the Call keyword or just entering the name of the subroutine
on a line of code.
• The Microprocessor activates the INTA signal. This signal will enable the Tri-state buffers,
which will place the value EFH on the data bus.
182 LOVELY PROFESSIONAL UNIVERSITY