//==============================================================================
// 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__
//==============================================================================
See also:
| file: /Techref/member/IMB-yahoo-J86/genericpointer.h.htm, 2KB, , updated: 2009/7/9 10:04, local time: 2013/6/19 14:45,
owner: IMB-yahoo-J86,
54.242.233.11:LOG IN |
| ©2013 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://www.piclist.com/techref/member/IMB-yahoo-J86/genericpointer.h.htm"> Generic Pointers for MPLAB-C18 Compiler - genericpointer.h</A> |
| Did you find what you needed? |
|
o List host: MIT, Site host massmind.org, Top posters @20130619 RussellMc, IVP, alan.b.pearce, veegee, Bob Blick, John Gardner, Isaac Marino Bavaresco, Sean Breheny, John Ferrell, Carl Denk, * Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: None at this time. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
Welcome to www.piclist.com! |
.