delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/13/10:39:04

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Simple Question
Date: 13 Mar 1997 14:21:26 GMT
Organization: Oxford University, England
Lines: 21
Message-ID: <5g92h6$crb@news.ox.ac.uk>
References: <5g8poh$q7u AT Chaos DOT es DOT co DOT nz>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Dave Smith (nizea AT es DOT co DOT nz) wrote:
: 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?

That's a word, not a byte...

Anyway, to find the high order byte of a word you would shift it right by
8 places, e.g.

(((0x1234) >> 8) == (0x12)) is true.

If there are higher bits in the number (e..g it is an int) you will need
to & this with 0xff as well, to extract just that byte.

-- 
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford

- Raw text -


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