delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/13/12:15:00

From: "Sly" <sly AT antispam DOT aussie DOT net>
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" <sly AT aussie DOT net>
NNTP-Posting-Host: max0ppp01.bne.aussie.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019