<< Previous | Index | Next >>

Appendix A: Macros and Global Variables

This appendix contains many macros and global variables that may be of interest. This is not an exhaustive list of the macros and global variables that are available.

A.1 Compiler-Defined Macros

The macros in the following table are defined internally. Where applicable, default values are given, as well as directions for changing values.

Table A-3. Macros Defined by the Compiler
Macro Name Definition and Default
_BIOSBAUD_

This macro was introduced in Dynamic C 7.25. It is the debug baud rate. The baud rate can be changed in the Options | Communications menu.

_BOARD_TYPE_

This is read from the System ID block or defaulted to 0x100 (the BL1810 JackRabbit board) if no System ID block is present. This can be used for conditional compilation based on board type. Board types are listed in boardtypes.lib.

_CPU_ID_

This macro identifies the CPU type, e.g. R3000 is the Rabbit 3000 microprocessor.

CC_VER

Gives the Dynamic C version in hex, i.e. version 7.05 is 0x0705.

DC_CRC_PTR

Reserved.

__DATE__

The compiler substitutes this macro with the date that the file was compiled (either the BIOS or the .c file). The character string literal is of the form Mmm dd yyyy. The days of the month are as follows: "Jan," "Feb," "Mar," "Apr," "May," "Jun," "Jul," "Aug," "Sep," "Oct," "Nov," "Dec." There is a space as the first character of dd if the value is less than 10.

DEBUG_RST

In the Compile pull-down menu, check "Include Debug Code/RST 28 Instructions" to set DEBUG_RST to 1. Debug code will be included even if #nodebug precedes the main function in the program.

__FILE__

The compiler substitutes this macro with the current source code file name as a character string literal.

_FAST_RAM_

These are used for conditional compilation of the BIOS to distinguish between the three options:

  • compiling to flash and running in RAM (available starting with Dynamic C 7.30)
  • compiling to and running in flash
  • compiling to and running in RAM

The compile mode choice is made in the Options | Compiler dialog box. The default is compiling to and running in flash.

Starting with Dynamic C version 7.26, the BIOS defines FAST_RAM_COMPILE, FLASH_COMPILE and RAM_COMPILE. These macros are defined to 0 or 1 as opposed to the corresponding compiler-defined macros which are either defined or not defined. This difference makes possible statements such as:


#if FLASH_COMPILE || FAST_RAM_COMPILE
_FLASH_
_RAM_
_FLASH_SIZE_

These are used to set the MMU registers and code and data sizes available to the compiler. The values of the macros are the number of 4K blocks of memory available.

_RAM_SIZE_
__LINE__

The compiler substitutes this macro with the current source code line number as a decimal constant.

NO_BIOS

Boolean value. Tells the compiler whether or not to include the BIOS when compiling to a .bin file. This is set in the Compile menu

_SECTOR_SIZE_

In all versions prior to Dynamic C 7.02, this macro (near the top of LIB\BIOSLIB\FLASHWR.LIB) needs to be hard-coded to the sector size of the first flash in bytes.

_TARGETLESS_COMPILE_

Boolean value. This is set in the Compile menu. It defaults to 0.

__TIME__

The compiler substitutes this macro with the time that the file (BIOS or .c) was compiled. The character string literal is of the form hh:mm:ss.

_USE115KBAUD_

Boolean value. Tells BIOS to use 115k baud if value is 1. This macro is not available starting with Dynamic C version 7.25. It was replaced with _BIOSBAUD_. The baud rate can be changed in the Options | Communications menu.

A.2 Global Variables

These variables may be read by any Dynamic C application program.

dc_timestamp

This internally-defined long is the number of seconds that have passed since 00:00:00 January 1, 1980, Greenwich Mean Time (GMT) adjusted by the current time zone and daylight savings of the PC on which the program was compiled. The recorded time indicates when the program finished compiling.


printf("The date and time: %lx\n", dc_timestamp);

OPMODE

This is a char. It can have the following values:

SEC_TIMER

This unsigned long variable is initialized to the value of the real-time clock (RTC). If the RTC is set correctly, this is the number of seconds that have elapsed since the reference date of January 1, 1980. The periodic interrupt updates SEC_TIMER every second. This variable is initialized by the Virtual Driver when a program starts.

MS_TIMER

This unsigned long variable is initialized to zero. The periodic interrupt updates MS_TIMER every millisecond. This variable is initialized by the Virtual Driver when a program starts.

TICK_TIMER

This unsigned long variable is initialized to zero. The periodic interrupt updates TICK_TIMER 1024 times per second. This variable is initialized by the Virtual Driver when a program starts.

A.3 Exception Types

These macros are defined in errors.lib:

#define ERR_BADPOINTER
#define ERR_BADARRAYINDEX
#define ERR_DOMAIN
#define ERR_RANGE
#define ERR_FLOATOVERFLOW
#define ERR_LONGDIVBYZERO
#define ERR_LONGZEROMODULUS
#define ERR_BADPARAMETER
#define ERR_INTDIVBYZERO
#define ERR_UNEXPECTEDINTRPT
#define ERR_CORRUPTEDCODATA
#define ERR_VIRTWDOGTIMEOUT
#define ERR_BADXALLOC
#define ERR_BADSTACKALLOC
#define ERR_BADSTACKDEALLOC
#define ERR_BADXALLOCINIT
#define ERR_NOVIRTWDOGAVAIL
#define ERR_INVALIDMACADDR
#define ERR_INVALIDCOFUNC

228
229
234
235
236
237
238
239
240
241
243
244
245
246
247
249
250
251
252

A.4 Rabbit 2000/3000 Internal registers

Macros are defined for all of the Rabbit's I/O registers. A listing of these register macros can be found in the Rabbit 2000 Microprocessor User's Manual and the Rabbit 3000 MIcroprocessor User's Manual.

A.4.1 Shadow Registers

Shadow registers exist for many of the I/O registers. They are character variables defined in the BIOS. The naming convention for shadow registers is to append the word Shadow to the name of the register. For example, the global control status register, GCSR, has a corresponding shadow register named GCSRShadow.

The purpose of the shadow registers is to allow the program to reference the last value programmed to the actual register. This is needed because a number of the registers are write only.


<< Previous | Index | Next >>
Z-World, Inc.
www.zworld.com
Phone: 1.530.757.3737
Fax: 1.530.757.3792
Rabbit Semiconductor
www.rabbitsemiconductor.com
Phone: 1.530.757.8400
Fax: 1.530.757.8402