From: "Sly" Newsgroups: comp.os.msdos.djgpp Subject: Re: Simple Question Date: 13 Mar 1997 14:53:16 GMT Organization: Sly Lines: 27 Message-ID: <01bc2fbe$d54cc080$83081ecb@sly> References: <5g8poh$q7u AT Chaos DOT es DOT co DOT nz> Reply-To: "Sly" NNTP-Posting-Host: max0ppp01.bne.aussie.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Dave Smith 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