News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

dwords words differences on different architecture

Started by Kyoy, June 13, 2005, 07:01:25 AM

Previous topic - Next topic

Kyoy

I read that Machine bytes/words/double words are processor specific, for instance on IA-32 architecture's the 32 bit is a word not a double word. On IA-64, word size is 64 bit.

I am confused because i have always taken for granted that 8 bit is a byte, 16 bit is a word 32 bit is a dword when i do any assembly programming or especially C programming.

So my question is, when will this processor specific word/byte differences be relevant during programming? When should i actually take note?

Also this will make it very confusing. When people refer to dword, will they usually mean 32 bit or 64 bit or whatever their processer is?

hutch--

#1
This is why assembler tends to specify the size in the data type.

OWORD = 16 bytes.
QWORD = 8 bytes
DWORD = 4 bytes
WORD = 2 bytes
BYTE = 1 byte

These all correspond to the various sizes of registers.

With the maths co-processor you have,

REAL4 = 32 bit
REAL8 = 64 bit
REAL10 = 80 bit
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

AeroASM

On x86-32 a word is always 2 bytes. However, it mgith differ in x86-64. On PPC a word is 4 bytes.

Tedd

The confusion comes from the orginal meaning of 'word.' It just meant the full size of a register - the "word size"
Bytes have always been 8-bits. As PCs became mainstream, the word-size was 16-bits - so a word was 16 bits.
With the move to 32-bit, the new word-size was twice as big as the old one, so it had double word-size. Hence they were named "double words" => dword.
It's just a terminology problem. However, convention has taken over and the size of a word is 16-bits, but the "word-size" of IA32 is 32-bits :wink
No snowflake in an avalanche feels responsible.

Kyoy

Thanks for clarifying. So a dword is still 32 bit in an IA-32 ? That is weird ..

I read this though :
Quote
A DWORD is not a double word on modern hardware.  It is a single word and WORD is actually a half word  on IA-32.  On an IA-64, DWORD is actually a half word and WORD is a quarter word.

and

Quote
Based on the processor, on IA-64 architecture's the word size is 64 bit not 32 bit. Half of a machine word is 32. Quarter is 16

May i know then if the writer is just plain wrong or is the writer referring to something else that i am unaware of?

AeroASM

A word is the size of a register. A WORD is 16 bits.
A dword is twice the size of a register. A DWORD is 32 bits.

Therefore the IA-32 word = DWORD
And the IA-64 word = QWORD.

Kyoy

Quote from: AeroASM on June 13, 2005, 11:35:38 AM
A word is the size of a register. A WORD is 16 bits.
A dword is twice the size of a register. A DWORD is 32 bits.

Therefore the IA-32 word = DWORD
And the IA-64 word = QWORD.

Yup i just read Tedd's reply (which was posted seconds after mine), thanks.

So its only a matter of Terminology, that simple?

Hutch said Masm will specify the size of data types. But when you are doing something like C programming or using an older and unsupported assembler like Tasm and when it comes to declaring dwords/words/bytes this word dword terminology difference is irrelevant and won't affect anything i suppose?

AeroASM

I tis irrelevant to programming because MASM will always use the WORD and DWORD definitions, as is the convention. You just need to be careful when reading documentation becuase they might mean either "word" or "WORD".

dsouza123

The size of data types are fixed in 32-bit MASM, as noted before.

When declaring variables in the .data and .data? (uninitialized data) sections
there are full and abrieviated ways of specifing (many of) the data types.


.data
  item1  db 0   ;  item1   byte 0       both declare a  byte  8-bit initialized with 0   db means data byte   0..255
  item2  dw 0   ;  item2   word 0                       word 16-bit                      dw means data word   0..65535
  item4  dd 0   ;  item4  dword 0                      dword 32-bit                      dd means data dword  0..4294967295
  item8  dq 0   ;  item8  qword 0                      qword 64-bit                      dq means data qword  0..18446744073709551615
  item10 dt 0   ;  item10 tbyte 0                      tbyte 80-bit                      dt means data tbyte

; also the following less frequently used types (the signed types and a special pointer type)
  sitem1 sbyte  -1    ;  8-bit -128 to 0 to 127
  sitem2 sword  -1    ; 16-bit -32768 to 0 to 32767
  sitem4 sdword -1    ; 32-bit -2147483648 to 0 to 2147483647

  item6  df 0   ;  item6  fword 0                      fword 48-bit                      df means data farword

; for floating point
  ritem4   real4 0.0  ;     a single precision 32-bit floating point number
  ritem8   real8 0.0  ;     a double precision 64-bit
  ritem10 real10 0.0  ;  an extended precision 80-bit used internally in x87 FPU



tenkey

Quote from: Kyoy on June 13, 2005, 11:53:24 AM
So its only a matter of Terminology, that simple?

Hutch said Masm will specify the size of data types. But when you are doing something like C programming or using an older and unsupported assembler like Tasm and when it comes to declaring dwords/words/bytes this word dword terminology difference is irrelevant and won't affect anything i suppose?

Yup, it's just terminology.

If you stick with just the (Intel-AMD) x86 line of processors (and Motorola 68k series), the terminology hasn't changed as they moved from 16-bit to 32-bit.

However, jump to another architecture, like the IBM 370 mainframes (and according to Aero, the Power PC), and you will find that "fullwords" (32-bits) and double words (64-bits) are different. I'd have to unbury some stuff to see if the IBM 360/20 was 16-bit, but I know it used the 32-bit terminology for data sizes. All of the other 360/370 models implemented the full 32-bit core instruction set (FP and decimal instructions were options in the early models).
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8