> ## Appendix A. Macros and Global Variables

> This appendix contains many macros and global variables the user may want to know about. It is not a list of all the macros and global variables available in Dynamic C.

> ### A.1 Compiler-Defined Macros

> ###

> Macro Name | Definition and Default
> _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 `default.h`.
> _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, ie. 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 soure code file name as a character string literal.
> _FLASH_ | These are used for conditional compilation of the BIOS to distinguish between compiling to RAM and compiling to flash. These are set in the Options | Compiler menu.
> _RAM_
> _FLASH_SIZE_ | These are used to set the MMU registers and code and data sizes available to the compiler. The values given by these macros represent the number of 0x1000 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_ | 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. The baud rate can be changed in the Options | Communications menu.
> USE_2NDFLASH_CODE | Uncomment this macro at the top of the BIOS to allow compilation of a program into two flash chips. The macro is commented out by default.

> ### A.2 Global Variables

> ### 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:

> - 0x88 = debug mode

> - 0x80 = run mode

> ### 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 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.

> #### 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 Rabbit 2000 registers are write only.

Z-World http://www.zworld.com Voice: (530) 757-3737 FAX: (530) 757-3792 sales@zworld.com