Jump to content
  • Advertisement
Sign in to follow this  
nuclear123

word size?

This topic is 2561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

when i write a program in assembly and i define a variable of "word" size.....is it truly the natural word size of my processor? for example on an i7 64bit processor will it be the size of 64bits.....or will it be defined as how microsoft defines the size of a words "A WORD is a 16-bit unsigned integer" ?

Share this post


Link to post
Share on other sites
Advertisement
Depends on your CPU ( in your example a word is 64bit ), as word is determined by the default data size of the processor in question. List of sizes by CPU type

That said, there are The Windows Datatypes as defined by Microsoft. In this case, WORD is #defined as you've described ([font="Courier New"]typedef unsigned short WORD;)[/font], 16bits, while a DWORD or DWORD32 = 32 and a DWORD64 is 64bit. Frankly, leaving this world behind was a pleasure! All of these sizes of course are only relevant to the Windows API's.



Then again, all this awkwardness can be blamed on C making data sizes dependant on the platform. Most other languages, especially more modern languages, are much more explicit about the data size of all in-built types.



EDIT: Why exactly, did someone vote this comment down? If you perceive something as factually incorrect, post it accordingly.

EDIT2: As to intel assembly instructions ( that above post was posted while I wrote this one ), in Intel assembly a word is defined as 2 bytes.

Share this post


Link to post
Share on other sites

intel syntax


That's an assembly language syntax, not an assembler. Many assemblers use Intel syntax; many others do not.


What actual tool that converts assembly language to machine code are you using?

Share this post


Link to post
Share on other sites
*sigh*


Are you using inline assembly in C/C++, or are you talking about actual MASM files?

Share this post


Link to post
Share on other sites
Then there are no "variables" from the point of view of your assembly code. Inline assembly relies on the symbols defined in the containing scope to infer operand sizes, so what you define in your C/C++ code is what you get in your assembly language.

Share this post


Link to post
Share on other sites
when i write a program in assembly and i define a variable of "word" size.....is it truly the natural word size of my processor? for example on an i7 64bit processor will it be the size of 64bits.....or will it be defined as how microsoft defines the size of a words "A WORD is a 16-bit unsigned integer" ?

I think you may be confused by how the size of primitive data-types according to their standards are defined in C/C++. In these languages an int, for example, is the size that is natural to the processor (it will be 32 bits on a 32-bit system, 64 bits on a 64-bit system etc.) However, since somewhere in 1960s (and thanks to the developers of the System/360 at IBM, as far as I know) a byte is defined as 8 bits, a word as two bytes (16 bits), a double word (dword) as 32 bits and so on. These terms also apply when you code in assembly:

[font="Courier New"]mov eax, dword ptr [ebx][/font]

For the same reason assemblers will raise an error if the size of the destination register doesn't match the size of the value you are trying to load into it (unlike C/C++ compilers that automatically perform the necessary type-casting):

[font="Courier New"]mov [color="#FF0000"]ax, [color="#FF0000"]dword ptr [ebx] // error C2443: operand size conflict[/font]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!