Last visit was: It is currently Mon Dec 10, 2018 12:24 am


All times are UTC-05:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Data types: 64-bits or 64-bit?
PostPosted: Tue Aug 18, 2009 7:40 pm 
User avatar
 

Joined: Sun Feb 12, 2006 8:56 pm
Posts: 1019
Website: http://eddieringle.com
Location: Detroit, MI
Ever since I checked out the wiki page for data types I've wondered about the 64-bits row.
Does it mean for use only on a 64-bit architecture, or that it uses 64-bits of data (and is usable on a 32-bit architecture)?

_________________
-- Eddie Ringle

Check out Elysian Shadows and consider backing us on Kickstarter!

====================================

Image


Top
Offline   
 Post subject: Re: Data types: 64-bits or 64-bit?
PostPosted: Tue Aug 18, 2009 10:30 pm 
 

Joined: Thu Apr 28, 2005 3:57 pm
Posts: 175
AOL: DKWiz214
It uses 64 bits. The thing about a 64 bit architecture is that pointers are longs instead of ints. However, longs can be used on a 32 bit architecture to store a number, but not a pointer.

_________________
The light shall be your demise.


Top
Offline   
 Post subject: Re: Data types: 64-bits or 64-bit?
PostPosted: Thu Aug 20, 2009 4:53 pm 
Just so you know, you brought this upon yourself. Dancefight.
User avatar
 

Joined: Sat Apr 02, 2005 3:31 pm
Posts: 1171
Location: The vicinity of an area adjacent to a location.
On GCC, a 64-bit integer can be explicitly used with 'long long', and on MSVC++, you can use '__int64'. Note that 64-bit math in 32-bit code is very slow. For example, let's say you compile this for x86 and x86_64:
Code:
#ifdef _MSC_VER typedef __int64 int64_t; #else typedef long long int64_t; #endif int64_t add64(int64_t x, int64_t y) { return x + y; }
x86_64, with GCC 4.1.2 (-O2 -fno-strict-aliasing -masm=intel -S):
Code:
add64: lea %rax, [%rdi+%rsi] ret
x86, with GCC 4.1.2 (-m32 -O2 -fno-strict-aliasing -masm=intel -S):
Code:
add64: push %ebp mov %ebp, %esp mov %eax, DWORD PTR [%ebp+8] add %eax, DWORD PTR [%ebp+16] mov %edx, DWORD PTR [%ebp+12] adc %edx, DWORD PTR [%ebp+20] leave ret
So on 64-bit, it's literally one add. With 32-bit, it's 3 moves, an add, and an add with carry. Much more work.

_________________
- Tycho

Image


Top
Offline   
 Post subject: Re: Data types: 64-bits or 64-bit?
PostPosted: Sat Aug 22, 2009 7:15 am 
 

Joined: Sun Jan 18, 2009 4:20 am
Posts: 40
So, looking at it from the surface - all x64 code is compatible with x86 architectures, just slower?


Top
Offline   
 Post subject: Re: Data types: 64-bits or 64-bit?
PostPosted: Sat Aug 22, 2009 8:32 am 
User avatar
 

Joined: Sun Feb 12, 2006 8:56 pm
Posts: 1019
Website: http://eddieringle.com
Location: Detroit, MI
Quote:
So, looking at it from the surface - all x64 code is compatible with x86 architectures, just slower?
I wish that were the other way around, all the stinking assembly tutorials and informational sites deal with x86, and half of the code doesn't even work on x64 for some reason.

_________________
-- Eddie Ringle

Check out Elysian Shadows and consider backing us on Kickstarter!

====================================

Image


Top
Offline   
 Post subject: Re: Data types: 64-bits or 64-bit?
PostPosted: Sat Aug 22, 2009 3:54 pm 
Just so you know, you brought this upon yourself. Dancefight.
User avatar
 

Joined: Sat Apr 02, 2005 3:31 pm
Posts: 1171
Location: The vicinity of an area adjacent to a location.
No, don't confuse 64-bit integers with 64-bit code. x86_64 (also called x64) uses a different instruction set, adds and removes certain features, etc.

The thing to realize is that you _can_ use 64-bit math in 32-bit code, it just won't perform as well as it would in native 64-bit code.

_________________
- Tycho

Image


Top
Offline   
Display posts from previous:  Sort by  
Post new topic  Reply to topic

All times are UTC-05:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created by Miah with assistance from hyprnova