please dont rip this site

Generic Pointers for MPLAB-C18 Compiler

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/23 11:09, owner: IMB-yahoo-J86,
TOP NEW HELP FIND: 
18.219.209.144:LOG IN

 ©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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://techref.massmind.org/Techref/member/IMB-yahoo-J86/genericpointer.h.htm"> Generic Pointers for MPLAB-C18 Compiler - genericpointer.h</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?