
/*
* Andy Neil, Antronics Ltd.
* Portable.h
* Comments: This file contains the compiler-specific definitions allowing
*           the rest of the code to be compiler-independent.
*
* Portable version by Andy Neil, Antronics Ltd:
* Of necessity, this code uses compiler-specific extensions to the ANSI 
* standard language. This version uses conditional compilation to
* automatically use the appopriate extensions.
* Compilers currently supported are:
*    Keil C51 v7;
*    Tasking 8051 C v7.1.
*
*  This is presented "as-is" and without any warranty whatsoever.
*  You may do with it as you wish, entirely at your own risk.
*/

#if defined( _CC51 )
/* Tasking 8051 Compiler */

/*
* Memory-Space specifiers.
* Note: The terms "internal" and "external" originate with the original
*       Intel 8051 devices, in which "external" RAM was literally outside
*       the 8051 IC package; this RAM is accessed by the MOVX instruction.
*
*       Modern 8051 derivates often include on-chip RAM accessed by MOVX; 
*       this is still sometimes referred to as "external" RAM, which can
*       get a little confusing!
*
*/
#define DATA _data /* directly-addressable   "internal" RAM */
#define BDAT _bdat /* bit-addressable        "internal" RAM */
#define IDAT _idat /* indirectly-addressable "internal" RAM */
#define PDAT _pdat /* 256-byte paged         "external" RAM */
#define XDAT _xdat /*                        "external" RAM */
#define CODE _rom  /* Code space  - internal or external    */

/*
* A single bit.
* Effectively, this is both a Type and a Memory-Space specifier.
*/
#define BIT  _bit

/*
* Specify and Absolute Address location
*/
#define ABS_ADR(adr) _at( adr )

/*
* A Function with a Register Bank specification, and the corresponding
* Prototype.
* (The separate Prototype definition is because some Compilers (eg Keil)
*  do not allow 'using' in the Prototype)
*/
#define FN_USING( fn, rb ) using( rb ) fn
#define FN_USING_PROTO( fn, rb ) using( rb ) fn

/*
* An Interrupt-Service Routine with a Vector Number specification
*/
#define ISR_NUM( fn, vn ) interrupt( vn ) fn

/*
* An Interrupt-Service Routine with Vector Number & Register Bank specification
*/
#define ISR_NUM_USING( fn, vn, rb ) interrupt( vn ) using( rb ) fn

#elif defined( __C51__ )
/* Keil C51 Compiler */


/*
* Memory-Space specifiers.
* Note: The terms "internal" and "external" originate with the original
*       Intel 8051 devices, in which "external" RAM was literally outside
*       the 8051 IC package; this RAM is accessed by the MOVX instruction.
*
*       Modern 8051 derivates often include on-chip RAM accessed by MOVX; 
*       this is still sometimes referred to as "external" RAM, which can
*       get a little confusing!
*
*/
#define DATA data  /* directly-addressable   "internal" RAM */
#define BDAT bdata /* bit-addressable        "internal" RAM */
#define IDAT idata /* indirectly-addressable "internal" RAM */
#define PDAT pdata /* 256-byte paged         "external" RAM */
#define XDAT xdata /*                        "external" RAM */
#define CODE code  /* Code space  - internal or external    */

/*
* A single bit.
* Effectively, this is both a Type and a Memory-Space specifier.
*/
#define BIT  bit

/*
* Specify and Absolute Address location
*/
#define ABS_ADR(adr) _at_ adr 

/*
* A Function with a Register Bank specification, and the corresponding
* Prototype.
* (The separate Prototype definition is because some Compilers (eg Keil)
*  do not allow 'using' in the Prototype)
*/
#define FN_USING( fn, rb ) fn using rb
#define FN_USING_PROTO( fn, rb ) fn

/*
* An Interrupt-Service Routine with a Vector Number specification
*/
#define ISR_NUM( fn, vn ) fn interrupt vn

/*
* An Interrupt-Service Routine with Vector Number & Register Bank specification
*/
#define ISR_NUM_USING( fn, vn, rb ) fn interrupt vn using rb
#define ISR_NUM_USING( fn, vn, rb ) fn interrupt vn using rb




#else
#error Unsupported Compiler!
#endif
