delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/06/09:18:47

Newsgroups: comp.os.msdos.djgpp
From: "William A. Barath" <wi534 AT victoria DOT tc DOT ca>
Subject: Re: Integers (4bytes VS 2bytes)
In-Reply-To: <3486F1EC.CBE@ok.com>
Message-ID: <Pine.GSO.3.95.iB1.0.971206012948.7979H-100000@vtn1>
Sender: news AT freenet DOT victoria DOT bc DOT ca (News Manager)
Organization: Victoria Freenet Association
References: <3486F1EC DOT CBE AT ok DOT com>
Mime-Version: 1.0
Date: Sat, 6 Dec 1997 09:37:53 GMT
Lines: 34
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Thu, 4 Dec 1997 thanks AT ok DOT com wrote:

|Hi Everyone,
|
|I have a quick question.  I just downloaded DJGPP and I see that
|the integers are 4 bytes not 2 bytes, like other compilers.  The
|question is why?  ...

Because DJGPP produces "32-bit-clean" binaries, which means they run with
a default data size of 32 bits.  Accessing smaller data actually slows
down the CPU due to misaligned data and as well, in order to do so in
32-bit protected mode a prefix code has to be applied to the instruction
in question which adds (at the least) one more cycle to the execution
time.  This is a 'feature' of the IAPX[3]86.

...
|Also, I created a binary file using TC++ and 
|would like to know if there's any problem with reading in the
|integers from it.

Just read them as shortints.  Ie:

int readshortint(int file)
{
  short d;
  read(f,d,sizeof(d));
  return(d);
}

Wil Barath, aka WseM : "I feel as though I see my pen to write"
Author of VPM, EDITPLN, and other VGA Planets support programs
Visit my homepage! -------------> http://victoria.tc.ca/~wi534


- Raw text -


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