Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a hint for this?

Status
Not open for further replies.

TheGreyBeast

Programmer
Apr 8, 2005
19
RO
I use a lot of byte variables (5 in fact) and I want to achieve the most performant code with Visual C++ 6.0

I want to load all of them in registers, but the compiler isn't as smart as I thought... It loads three of them in registers al, bl and cl, but it doesn't want to load the others in ah, bh or ch... I don't know why it doesn't use the ah, bh, ch and dh registers (if I create my own assembly version it works fine with the ah and bh registers). Is there a keyword or hint specific to Visual C++ 6 that makes it use those registers?

By the way - I really want to make this in C because I'll significally introduce new things to this code, and introducing these new things in Optimized assembly is really hard.

Thanks. Any help is appreciated.
 
Use int or unsigned int variables. You don't really save anything by using byte variables. In fact, it sometimes generates more code. If you do any indexing of any sort, it will increase the code with byte variables.
 
From your other posts, it seems to me that you're writing 16-bit assembler code for a 32-bit processor.

The newer processors don't like this at all AFAIK - sure it may be "compatible", but don't assume that also means "efficient".

The whole point about using a higher level language is you don't have to worry about all that low level register stuff.

Not only that, your code gets a boost each time you recompile your code with a better compiler - one say for example which is capable of making best use of say pipelining and branch prediction (which you really have to be a red-hot ASM programmer to make best use of that).

--
 
Ok thanks. I didn't know it was less efficient, because all I wanted to do is keep a very temporary variable in registers to increase speed of a inner loop, but I guess I'll have to write the function in assembler if I want that.

Thanks anyway.
 
Some systems/compilers change byte type to int types now days.. Most of these are on the unix side however so really doesnt apply that much to this.

However, from my understanding of current processor/memory that even if you use a byte type, it still allocates the memory for an int.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top