by Isaac Marino Bavaresco
//==============================================================================
// Copyright (c) 2007-2009, Isaac Marino Bavaresco
// All rights reserved
// isaacbavaresco@yahoo.com.br
//==============================================================================
#ifndef __GENERICPOINTER_H__
#define __GENERICPOINTER_H__
//==============================================================================
#define RAM far ram
#define ROM const far rom
#define GENERIC far rom
/** Returns the RAM pointer 'p' converted to a generic pointer to void pointing to the same address.*/
#define MAKE_GEN_PTR_RAM(p) ((void GENERIC*)((unsigned short long)(p)|0x800000))
/** Returns the RAM pointer 'p' converted to a generic pointer to type 't' pointing to the same address.*/
#define MAKE_GEN_PTR_RAM_T(p,t) ((t GENERIC*)((unsigned short long)(p)|0x800000))
/** Returns the ROM pointer 'p' converted to a generic pointer to void pointing to the same address.
NOTE: not necessary, supplied just for completeness. Will waste program words if used.*/
#define MAKE_GEN_PTR_ROM(p) ((void GENERIC*)((unsigned short long)(p)&0x7fffff))
/** Returns the ROM pointer 'p' converted to a generic pointer to type 't' pointing to the same address.
NOTE: not necessary, supplied just for completeness. Will waste program words if used.*/
#define MAKE_GEN_PTR_ROM_T(p,t) ((t GENERIC*)((unsigned short long)(p)&0x7fffff))
/** Reads one char from generic pointer 'p'*/
#define READ_GEN_PTR(p) (((unsigned char RAM*)&(p))[2]&0x80?*(char RAM*)(p):*(char ROM*)(p))
/** Reads one elemet of type 't' from generic pointer 'p'*/
#define READ_GEN_PTR_T(p,t) (((unsigned char RAM*)&(p))[2]&0x80?*(t RAM*)(p):*(t ROM*)(p))
/** Writes one char to the address pointed to by generic pointer 'p'*/
#define WRITE_GEN_PTR(p,c) {if(((unsigned char RAM*)&(p))[2]&0x80)*(char RAM*)(p)=(c);}
/** Writes one element of type 't' to the address pointed to by generic pointer 'p'*/
#define WRITE_GEN_PTR_T(p,t,c) {if(((unsigned char RAM*)&(p))[2]&0x80)*(t RAM*)(p)=(c);}
/** Returns non-zero if generic pointer 'p' points to RAM*/
#define IS_GEN_PTR_TO_RAM(p) (((unsigned char RAM*)&(p))[2]&0x80)
/** Returns non-zero if generic pointer 'p' points to ROM*/
#define IS_GEN_PTR_TO_ROM(p) (!(((unsigned char RAM*)&(p))[2]&0x80))
//==============================================================================
#endif // __GENERICPOINTER_H__
//==============================================================================
file: /Techref/member/IMB-yahoo-J86/genericpointer.h.htm, 2KB, , updated: 2009/7/9 09:04, local time: 2024/11/28 01:20,
owner: IMB-yahoo-J86,
|
| ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/TECHREF/member/IMB-yahoo-J86/genericpointer.h.htm"> Generic Pointers for MPLAB-C18 Compiler - genericpointer.h</A> |
Did you find what you needed?
|