C251 User's GuideC251 Introduction Compiling Programs Language Extensions Preprocessor Advanced Programming Customization Files Startup Code Variable Initialization Code Basic I/O Memory Allocation Optimizer General Optimizations 251-Specific Optimizations Options for Code Generation Global Register Coloring Segment Naming Conventions Segment Types Initialization Segments Function Symbols Parameter Passing Symbols Hardware Stack Calculating Stack Size Interfacing C Programs to Assembler Global Variables Function Parameters Passing in Memory Passing in Registers Function Return Values Using the SRC Directive Register Usage Overlaying Segments TINY Model XTINY Model SMALL Model XSMALL Model LARGE Model Data Storage Formats Bit Variables 1-Byte Scalars 2-Byte Scalars 4-Byte Scalars Floating-point Numbers Floating-point Errors Double Numbers Double Errors Absolute Memory Locations Absolute Access Macros Linker Location Controls The _at_ Keyword Debugging Error Messages Library Reference Appendix
The global variables that you create in your C programs are stored either in the memory area specified or in the default memory area implied by the memory model. The variable's assembly label is the variable name. For example, for the following global variables:
unsigned int bob; unsigned char jim;
the compiler generates the following assembler code:
?DT?MAIN SEGMENT DATA PUBLIC jim PUBLIC bob RSEG ?DT?MAIN bob: DS 2 jim: DS 1 ; unsigned int bob; ; unsigned char jim;
To access these variables in assembler, you must create an extern declaration that matches the original declaration. For example:
If you use in-line assembler, you may simply use C extern variable declarations to generate the assembler EXTERN declarations.
You may access global variables in assembler using their label names. For example:
of your data.