.extrn

Name

.extrn --  specifies symbols that are public to other modules

Syntax

.extrn symbol [:type] [:section type] [,symbol [:type] [:section type]...]

Description

The .extrn specifies symbols that are defined public in other modules, with the .public directive, but used in this module. The external is given the byte or word attribute by specifying :BYTE (or :B) or :WORD (or :W). If no type is specified, the size attribute is null. The default section type of an external is the same as the section in which it is defined. This section type may be overridden by specifying :BASE, :RAM, :EERAM, :REG, :SEG; :SEGB, and :ROM; these section types are explained for .sect directives.

For best error checking and most efficient code, externals should be given the same byte/word type and section type as the public symbol. Local symbols (symbols which start with $) may not be used with .extrn.

Description

Module 1

		.extrn	Z:ROM:WORD	; word type, ROM type

		.sect	CODE,ROM

		.extrn	Q:BYTE		; byte type, ROM type

		.extrn	LABEL		; no size type, ROM type (label)

			ld A, Q
			jmp LABEL
	

Module 2

		.public	Z, LABEL, Q
		.sect	CODE,ROM
	Z:		.dw 2		; word type, ROM section type
	Q:		.db 3		; byte type, ROM section type
	LABEL:		nop		; no size type, ROM section type (label)
	

Note: It is highly recommended to place absolute value symbols (e.g., Q=2:WORD or Z=3) in an include file and include the file in an assembly rather than pass the symbols externally using .extrn. If .extrn is used with an absolute value, the appropriate sect type should be used with it, e.g., :BASE for value 0-0f, :REG for value f0-ff, no sect type for other values. Even so, the .extrn value may generate less efficient code than an absolute value.