Mail Archives: djgpp/1998/05/26/11:30:28
[Posted and mailed]
In article <6keg38$mia$1 AT infa DOT central DOT susx DOT ac DOT uk>,
andrewda AT cogs DOT susx DOT ac DOT uk (Andrew Smythe Davidson) writes:
> Basically I'm looing for a way to create a structure full of registers, some
> of which are 16bit, some 8 bit, and some either 8 or 16. Rather than have to
> access it in a regs.?.? way like Union REGS regs would give me I'd like to be
> able to refer to the 8/16 bit registers either as, for example, regs.a or
> regs.ah/regs.al. Is there anyway of doing this without introducing an extra
> level into the structure?
Yes, just #define the double regs reference to a single reference.
So if you want to access regs.a[0] as regs.al, just define
#define al a[0]
(and don't use al anywhere else).
BTW, by using unions in this way you assume a certain memory layout
which is neither portable across different compilers, nor across platforms.
IMHO you'd better think a bit more, and come up with a data structure
which is portable. At least you can then assume that the code might work
on the next version of DJGPP.
Albert
---
The @wtb.tue.nl domain is known to bounce mail incorrectly sometimes.
If you are one of the lucky persons, please try again, and send the log
as well, so I can prove it to our postmaster. Thank you !
- Raw text -