Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/09/05 14:50
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#89337 - Program Linkage
Responding to: ???'s previous message
PUBLIC
The PUBLIC directive allows you to specify the list of symbols to be known and used outside the current source file. If you declare a symbol as PUBLIC then you must define it as well in the same source file. Declaring it public allows it to be referenced in another source file.

For example,

module1.a51
            PUBLIC DELAY,READ_DATA
            . 
            .
DELAY:
            some coding here
            RET
READ_DATA:
            some coding here
            RET

            END


EXTRN
The EXTRN directive allows you to list the symbols which are referenced in the current source file but are defined in some other source file (e.g. DELAY and READ_DATA are defined in above example but referenced in the example below). The list of EXTRN symbols must have a segment type association with each symbol in the list. The segment type indicates the way a symbol may be used (important issue at link time)

In the example below, EXTRN will tell the assembler not to give errors since DELAY and READ_DATA are used in the following program, but are not defined. The definition is in some other module (which must be linked with this main.a51, otherwise linker will give error)

main.a51
            EXTRN CODE(DELAY,READ_DATA)
            . 
            .
            CALL DELAY
            .
            .
            CALL READ_DATA
            .
            .
            END




List of 14 messages in thread
TopicAuthorDate
How to link more than 2 files            01/01/70 00:00      
   Hint            01/01/70 00:00      
      More hints            01/01/70 00:00      
         Link more than two files            01/01/70 00:00      
            PUBLIC and EXTERNAL            01/01/70 00:00      
               correction: PUBLIC and EXTRN            01/01/70 00:00      
               linkining more than one file            01/01/70 00:00      
                  think more            01/01/70 00:00      
                     linking more than one file            01/01/70 00:00      
                        use pair PUBLIC/EXTRN            01/01/70 00:00      
                           Program Linkage            01/01/70 00:00      
   INCLUDE            01/01/70 00:00      
      no include            01/01/70 00:00      
         about include            01/01/70 00:00      

Back to Subject List