www.digitalmars.com         C & C++   DMDScript  

c++.chat - Fast variables (8/16/32 bit)

reply Keith Fuller <Keith_member pathlink.com> writes:
Hello.

I have a question that I have been curious about for some time.

Let's say I have to represent an integer that can only have values between 1 and
10.  

In general, which would be the fastest?

8-bit byte
16-bit short 
32-bit integer

Cheers!

Keith Fuller

keithfx hawtmail.com (<--you know what I mean)
May 05 2003
parent reply "Walter" <walter digitalmars.com> writes:
On later intel processors, 32 bits.

"Keith Fuller" <Keith_member pathlink.com> wrote in message
news:b9689u$n73$1 digitaldaemon.com...
 Hello.

 I have a question that I have been curious about for some time.

 Let's say I have to represent an integer that can only have values between

 10.

 In general, which would be the fastest?

 8-bit byte
 16-bit short
 32-bit integer

 Cheers!

 Keith Fuller

 keithfx hawtmail.com (<--you know what I mean)

May 05 2003
next sibling parent reply "Javier Gutiérrez" <nikkho NOSPAM hotmail.com> writes:
    The general rule is that the natural word machines are the faster.
    16 bit for 286 or lower, 32 bit for 386+.

"Walter" <walter digitalmars.com> escribió en el mensaje
news:b96hk1$10dq$1 digitaldaemon.com...
 On later intel processors, 32 bits.

 "Keith Fuller" <Keith_member pathlink.com> wrote in message
 news:b9689u$n73$1 digitaldaemon.com...
 Hello.

 I have a question that I have been curious about for some time.

 Let's say I have to represent an integer that can only have values


 1 and
 10.

 In general, which would be the fastest?

 8-bit byte
 16-bit short
 32-bit integer

 Cheers!

 Keith Fuller

 keithfx hawtmail.com (<--you know what I mean)


May 07 2003
parent roland <nancyetroland free.fr> writes:
hello

Javier Gutiérrez a écrit:
     The general rule is that the natural word machines are the faster.
     16 bit for 286 or lower, 32 bit for 386+.

hum .. it seems to me that it depend on the model too. manipulating 32 bit datas with 16 bit registers is quite slow ! at least 16 bit datas should be aligned on 32 bit boundary using 32 bit registers on 16 bit model ? it works (use assembly) i don't know if it is faster but i know it adds a 8 bit opcode. roland
 "Walter" <walter digitalmars.com> escribió en el mensaje
 news:b96hk1$10dq$1 digitaldaemon.com...

On later intel processors, 32 bits.

"Keith Fuller" <Keith_member pathlink.com> wrote in message
news:b9689u$n73$1 digitaldaemon.com...

Hello.

I have a question that I have been curious about for some time.

Let's say I have to represent an integer that can only have values


1 and

10.

In general, which would be the fastest?

8-bit byte
16-bit short
32-bit integer

Cheers!

Keith Fuller

keithfx hawtmail.com (<--you know what I mean)



May 08 2003
prev sibling parent reply "Shawn Poulson" <spoulson2 comcast.net> writes:
"Walter" <walter digitalmars.com> wrote in message
news:b96hk1$10dq$1 digitaldaemon.com...
 On later intel processors, 32 bits.

My understanding is that 386 and newer processors are well optimized for simple algebra with 8/16/32-bit registers. Any add/sub operation will only take 1 clock (or close to it) regardless if it's using AL, AX, or EAX. However, I'm not sure how it reacts with div/mul. I would be interested in seeing someone profile these types of operations.
Jun 20 2003
parent reply Keith Fuller <Keith_member pathlink.com> writes:
I think it is more a matter of memory access.  
Inside the CPU, yes, it probably doesn't matter.

keithfx h*tmail.com

In article <bd0kr0$mq2$1 digitaldaemon.com>, Shawn Poulson says...
My understanding is that 386 and newer processors are well optimized for
simple algebra with 8/16/32-bit registers.  Any add/sub operation will only
take 1 clock (or close to it) regardless if it's using AL, AX, or EAX.
However, I'm not sure how it reacts with div/mul.

I would be interested in seeing someone profile these types of operations.

Jun 24 2003
parent "Javier Gutiérrez" <nikkho NOSPAM hotmail.com> writes:
    Yes, it is a memory issue.
    You can get the complete info at
http://www.penguin.cz/~literakl/intel/intel.html

"Keith Fuller" <Keith_member pathlink.com> escribió en el mensaje
news:bd9pv0$1klh$1 digitaldaemon.com...
 I think it is more a matter of memory access.
 Inside the CPU, yes, it probably doesn't matter.

 keithfx h*tmail.com

 In article <bd0kr0$mq2$1 digitaldaemon.com>, Shawn Poulson says...
My understanding is that 386 and newer processors are well optimized for
simple algebra with 8/16/32-bit registers.  Any add/sub operation will


take 1 clock (or close to it) regardless if it's using AL, AX, or EAX.
However, I'm not sure how it reacts with div/mul.

I would be interested in seeing someone profile these types of




Jun 25 2003