Page 121 - DCAP507_SYSTEM_SOFTWARE
P. 121

Unit 8: Introduction to Linking and Loading




          Nothing is wrong in it. But from assembler's point of vision while producing the code for B, as  Notes
          B  is not defined in the segment A, the  assembler can not locate  the value of this symbolic
          reference and therefore it will state it as an error. To conquer problem, there should be some
          method by which the assembler should be explicitly learned that segment B is really defined in
          some other segment C.

               !
             Caution  Whenever segment B is used in segment A and if at all B is defined in C, then B
             must be stated as an external routine in A.
          To state such subroutine as external, we can use the assembler directive EXT. Thus, the statement
          such as EXT B should be added at the beginning of the segment A. This really helps to notify
          assembler that B is defined somewhere else. Likewise, if one subroutine or a variable is defined
          in the existing segment and can be pointed by other segments then those should be stated by
          means of pseudo-ops INT. Thus, the assembler could inform loader that these are the subroutines
          or variables used by other segments.



             Did u know?  This general process of establishing the relations among the subroutines can
             be theoretically known as a_ subroutine linkage.


                 Example:

































          At the beginning of the MAIN the subroutine B is stated as external. When a call to subroutine B
          is prepared, before creating the unconditional jump, the recent content of the program counter
          should be accumulated in the system stack preserved internally. Likewise while returning from
          the subroutine B (at RET) the pop is executed to restore the program counter of caller routine
          with the address of next instruction to be implemented.






                                           LOVELY PROFESSIONAL UNIVERSITY                                   115
   116   117   118   119   120   121   122   123   124   125   126