delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/08/26/10:06:53

From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Optimizing 8 bit variables?
Date: 26 Aug 2003 13:30:44 GMT
Organization: Ericsson Erisoft AB, Sweden
Lines: 33
Message-ID: <bifne4$6c9$1@antares.lu.erisoft.se>
References: <d2ad330a DOT 0308260427 DOT 49b6ab37 AT posting DOT google DOT com>
NNTP-Posting-Host: lws256.lu.erisoft.se
X-Newsreader: TIN [version 1.2 PL2]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Carlo (cbramix AT libero DOT it) wrote:
: I have this little problem: GCC doesn't seem to optimize very well a
: piece of code I wrote with 8 bit variables.

Really? You did turn on optimisations? Show us some code and what
you'd expect optimisationwise.

: So, I was thinking to use a local register variable.
: On the documentation I read that GCC can do that:

: register int *foo asm ("ebx");

: But what should I do if I need to use BH or BL registers?
: I tried to use BH or BL instead of ebx:

: register unsigned char myvar asm ("bl");

: GCC doesn't give me error messages, but it generates the same code I
: got without the 'asm' keyword.

Yes. That's because you misunderstood what that asm statement does. It
tells gcc to use the name "ebx" or "bl" for the assembly while you use
"foo" or "myvar" in C. Note that "ebx" and "bl" are names of variables,
not registers. So if it wasn't for the usual prepending of "_" saying
"int *ebx;" would be the same.

I'm unsure if the "register" keyword affects this, but I doubt it
does.


Right,

						MartinS

- Raw text -


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