| ??? 12/18/03 21:22 Read: times |
#60998 - macros indeed! Responding to: ???'s previous message |
That is just how I'm doing it on my current project, and the _only_ way of (efficiently) abstracting the SFRs of a multichannel peripheral into something resembling an array of single channel widgets.
I'm working in C, and using its preprocessor, and so the following details are from that perspective. If you're working in assembler, Oleg, then you'll have to read up on the particulars of your tool's macro processor, if any. In my macros, one of the arguments (formal parameters) is a PCA channel number, e.g. "Chan": #define MyPcaMacro(Chan, ... When actually calling the macro, the actual parameter has to evaluate to a numeric literal, e.g. via #define ThisParticularPcaChan 3 MyPcaMacro(ThisParticularPcaChan, ... or explicitly, e.g. MyPcaMacro(3, ... you can't use an enumeration constant, e.g. "typedef enum {ThisParticularPcaChan = 3} PcaChanNames;" MyPcaMacro(ThisParticularPcaChan, ... Now, in the body of the macro, I use the "##" operator to paste Chan and an SFR name together to form a single token that is then used in further macro processing and in actually compiling the code, e.g. "PCA0CPM##Chan" becomes "PCA0CPM3" Et voila! C'est magique fricken'! Indeed, I've gone way off the deep end with macros to try to bend the 8051 architecture into something a little more orthogonal and VonNeumannesque without incurring a loss of efficiency, e.g. as compared to assembler code; I've achieved a fairly high degree of success, but I suspect that I've taken advantage of one or more areas where my tool doesn't seem to conform properly to the C preprocessor specification... Anyhow, good luck with this, David |
| Topic | Author | Date |
| How can access SFR via lookup table? | 01/01/70 00:00 | |
| RE: How can access SFR via lookup table? | 01/01/70 00:00 | |
| RE: How can access SFR via lookup table? | 01/01/70 00:00 | |
| RE: How can access SFR via lookup table? | 01/01/70 00:00 | |
| RE: How can access SFR via lookup table? | 01/01/70 00:00 | |
| macros indeed! | 01/01/70 00:00 | |
| RE: macros indeed! | 01/01/70 00:00 | |
| RE: macros indeed! | 01/01/70 00:00 | |
| RE: How can access SFR via lookup table? | 01/01/70 00:00 | |
| Eureka | 01/01/70 00:00 | |
| RE: Eureka | 01/01/70 00:00 | |
RE: Eureka | 01/01/70 00:00 |



