Mail Archives: djgpp/1998/11/30/20:34:45
Tal Lavi wrote:
>
> Just a couple of misc questions, thanks in advance:
>
> 1)Can I define an extended asm command as a macro,
> with one of the outputs value returned?
You can, using GCC's statement-expressions extension. Example:
#define TEST_BIT(n, b) ({ \
char c; \
asm("btl %1, %2; " \
"setcb %0" \
: "=rm" (c) \
: "rI" (b), "rm" (n)); \
c; \
})
See also the info nodes "Statement Exprs" and "Extended Asm" in the GCC
docs.
> 2)I need to access a word size union in two forms: as the entire 16-bit word,
> and as the first 5 bits, next 6 and last 5.
> Can this be done in DJGPP?
You can try:
union word {
unsigned short s;
struct {
unsigned low : 5;
unsigned mid : 6;
unsigned high : 5;
} bits;
};
I'm not sure what order GCC allocates bitfields in, so that might be
wrong.
You can also do some macros with shifting and masking; that will also be
more portable.
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -