Reputation:
if a Word is the natural unit of data used by a particular processor, so in a x86 processor it is 4 bytes, then why in NASM and other assemblers the DW (Define Word) allocates 2 bytes of memory and not 4 bytes?
Upvotes: 3
Views: 2070
Reputation: 1156
For historical reasons. The x86 family started as a 16-bit architecture (8086). That was the time when the instruction set was defined, and all further processors have to be backward-compatible.
The 80386 was the first 32-bit processor in the x86 series.
BTW I am writing an assembler tutorial and I think I'll put your question as an example there. Thanks!
Upvotes: 4
Reputation: 17945
That is due to historic reasons. The first member of the x86 processor family was the 8086, and in the 8086 was mostly a 16 bit processor.
As a historical side note, originally byte meant word, because at first, computers had only one width of data they could process, and byte was that width, and that width was also called character (that's why a byte is called char
in C). Then computers grew, and things have become defacto standards...
Upvotes: 1