Mail Archives: djgpp/1997/03/13/12:15:00
Dave Smith <nizea AT es DOT co DOT nz> wrote in article <5g8poh$q7u AT Chaos DOT es DOT co DOT nz>...
> Heya peoples,
>
> I have a simple question (I hope) for some of you out there :)
> How in C (esp. GCC) do I find the high order of a byte, in Turbo
> pascal I would do this... a := Hi($1234) which would return ($12),
> how can I do this in DJGPP?
>
You could simulate the Hi function with a macro, like such:
#define Hi(x) (unsigned char)(((x) >> 8) & 0x00FF)
Shifts the word 8 bits to the right, which puts the upper 8 bits into the
lower 8 bits, then masks off the upper 8 bits to remove any junk that may
be there. Then use it the same way, eg:
unsigned char a;
a = Hi(0x1234);
will return 0x12 in a.
--
TTFN
Sly (Steve)
sly AT aussie DOT net
- Raw text -