Thread about the languages ( another one ? )

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
Post Reply
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Thread about the languages ( another one ? )

Post by Dio »

Istar wrote:2. Do not confuse 'word' with 'byte' - a word is two bytes.
No, Giles is absolutely right on this one. A word is simply the native instruction size for the hardware. A word may certainly be a byte.

The word == 2 bytes convention is far less widespread than the byte == 8 bits one - this is not a legacy thing; MIPS and non-Thumb ARM code (or, indeed, 64-bit ARM) both have 32-bit words.
User avatar
venusian
Baaaaaaa!
Baaaaaaa!
Posts: 6653
Joined: Wed Nov 06, 2002 2:22 pm 0
Location: South Gloucestershire

Re: Thread about the languages ( another one ? )

Post by venusian »

The word=2bytes is a MSVC thing isn't it? All the WORD and DWORD stuff left over from Win16 and Win32. That's always been my impression anyway.

I'm a UNIX weenie, historically speaking, so as far as I'm concerned "word" means the machine's native datatype length which, also because I'm also a UNIX weenie means 32 bits and sizeof(word)==sizeof(ptr) and I can cast between the two at will. Go me.
User avatar
t0ne
Baaaaaa!
Baaaaaa!
Posts: 3134
Joined: Wed Sep 11, 2002 8:48 am 0
Location: Bristol

Re: Thread about the languages ( another one ? )

Post by t0ne »

I got into the word == 2 bytes, longword == 4 bytes stuff doing 68k asm on the Amiga, but yes, it was certainly WORD == 2 and DWORD == 4 bytes in Win16/32 MSVC land too.
User avatar
gravy
Sheepie Whore
Sheepie Whore
Posts: 19572
Joined: Wed May 01, 2002 1:28 pm 0
Location: The Other Place

Re: Thread about the languages ( another one ? )

Post by gravy »

venusian wrote:I can cast between the two at will. Go me.
Ooof! Evil!
User avatar
GoatFoam
Baaaaa!
Baaaaa!
Posts: 1255
Joined: Tue Dec 12, 2006 11:05 am 0
Location: Brizzle
Contact:

Re: Thread about the languages ( another one ? )

Post by GoatFoam »

I think we can wrap this one up with a collective "Thank fuck things have calmed down and become reasonably standardised!" :)

All this stuff will be forgotten when my new computer architecture built on base 17 numbers takes over anyway.
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Thread about the languages ( another one ? )

Post by Dio »

As far as I'm aware it was Motorola that did the most to promote word == 16 bits. I don't think intel asm needed the dword ptr and word ptr stuff explicitly labelled until the 386, but I'm not certain of that.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27259
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Thread about the languages ( another one ? )

Post by gilesgoat »

Ok, according to wikipedia Gaz is right about byte, however is let's say 'commonly accepted byte is 8 bits'.
The byte (play /ˈbaɪt/) is a unit of digital information in computing and telecommunications that most commonly consists of eight bits. Historically, a byte was the number of bits used to encode a single character of text in a computer[1][2] and for this reason it is the basic addressable element in many computer architectures. The size of the byte has historically been hardware dependent and no definitive standards existed that mandated the size. The de facto standard of eight bits is a convenient power of two permitting the values 0 through 255 for one byte. With ISO/IEC 80000-13, this common meaning was codified in a formal standard. Many types of applications use variables representable in eight or fewer bits, and processor designers optimize for this common usage. The popularity of major commercial computing architectures have aided in the ubiquitous acceptance of the 8-bit size.[3]

The term octet was defined to explicitly denote a sequence of 8 bits because of the ambiguity associated at the time with the term byte.[4]
And again, Wikipedia seems to be pretty good in this :
In computing, word is a term for the natural unit of data used by a particular processor design. A word is basically a fixed sized group of bits that are handled as a unit by the instruction set and/or hardware of the processor. The number of bits in a word (the word size, word width, or word length) is an important characteristic of a specific processor design or computer architecture.

Modern processors, including embedded systems, usually have a word size of 8, 16, 24, 32 or 64 bits, while modern general purpose computers usually use 32 or 64 bits. Special purpose digital processors, such as DSPs for instance, may use other sizes and many different sizes have been used historically, including 8, 9, 12, 18, 24, 36, 39, 40, 48 and 60 bits. The slab is an example of a system with an earlier word size. Several of the earliest computers (and a few modern as well) used BCD rather than plain binary, typically having a word size of 10 or 12 decimal digits, and some early decimal computers had no fixed word length at all.
Anyway, when in doubt, use sizeof() and/or typedefs :wink:

[edit] - in those days I try to write stuff that is possibly 'independent' of those kind of size problems and when I need for some particular reason 'specific numbers of bits' I tend to use stuff like uint32 uint8 uint16 "properly defined somewhere once for all" exactly to avoid ambiguity of "how long is this long or short is this short" or such.
Last edited by gilesgoat on Wed Aug 29, 2012 3:31 pm 0, edited 1 time in total.
Giles the billy goat
"Baa"
User avatar
gravy
Sheepie Whore
Sheepie Whore
Posts: 19572
Joined: Wed May 01, 2002 1:28 pm 0
Location: The Other Place

Re: Thread about the languages ( another one ? )

Post by gravy »

gilesgoat wrote:Ok, according to wikipedia Gaz is right about byte, however is let's say 'commonly accepted byte is 8 bits'.
Well yeah, everyone knows that :D
User avatar
zip accident
Sheepie Whore
Sheepie Whore
Posts: 13928
Joined: Sun Feb 20, 2005 1:58 pm 0
Location: Bristol, UK

Re: Thread about the languages ( another one ? )

Post by zip accident »

I seem to remember hearing about bytes on tape including parity bits, and thus being potentially up to nine or ten bits.
"My way is the way of not fighting":- the book of Enter the Dragon.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27259
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Thread about the languages ( another one ? )

Post by gilesgoat »

zip accident wrote:I seem to remember hearing about bytes on tape including parity bits, and thus being potentially up to nine or ten bits.
Here we are going a bit into 'absurdity' I think :)

I mean if you want to consider 'byte' as 'unit that expresses the info' and/or include in it 'extra protocol bits as well'.

Then yes 8 bits + 1 bit parity = 9 bits

But then if you start to use FEC it could well be 8 bits data + 4 bits error code so 12

But if you consider a telnet TCP packet it could be 56 bytes to send one char so 8 + 55*8 = 448 bits ...
Giles the billy goat
"Baa"
User avatar
GoatFoam
Baaaaa!
Baaaaa!
Posts: 1255
Joined: Tue Dec 12, 2006 11:05 am 0
Location: Brizzle
Contact:

Re: Thread about the languages ( another one ? )

Post by GoatFoam »

You can reduce the error rate to zero with an infinite number of parity bits.

Also:

Q: What goes "Pieces of nine! Pieces of nine!"?
A: A parroty error.
User avatar
noodles
Baaaaaa!
Baaaaaa!
Posts: 2053
Joined: Wed May 15, 2002 1:04 pm 0
Location: France

Re: Thread about the languages ( another one ? )

Post by noodles »

  • CBM Basic V2
  • AMOS
  • 68k (on the Amiga of course)
  • Object Turbo Pascal
  • Delphi
  • VB6
  • C#
  • C
Still carefully avoiding C++. Just looking at the object syntax makes me angry.

I wish there was a language that synthesises C# syntax with the low-levelness of C (ie no VM and direct memory control).
There is the temptation on occasion to go back to Delphi but it's a bit marginal
to get anything going API-wise for games.
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Thread about the languages ( another one ? )

Post by tufty »

venusian wrote:I'm a UNIX weenie, historically speaking, so as far as I'm concerned "word" means the machine's native datatype length which, also because I'm also a UNIX weenie means 32 bits and sizeof(word)==sizeof(ptr) and I can cast between the two at will. Go me.
A: Tru64, OSX on x86/64 or ppc/64, other unixes. There have also been 16 bit, 36 bit, and (I believe) 128bit unixes, at least. Probbly others, too.
B: only because address size happens to coincide with word size.

i.e. you've been lucky so far
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
venusian
Baaaaaaa!
Baaaaaaa!
Posts: 6653
Joined: Wed Nov 06, 2002 2:22 pm 0
Location: South Gloucestershire

Re: Thread about the languages ( another one ? )

Post by venusian »

A. There's also been an 8 bit data, 16 bit pointer UNIX. I know because I ported it to the Amiga.
B. Irony failure much?
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27259
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Thread about the languages ( another one ? )

Post by gilesgoat »

@Venusian : are you talking about UZI maybe ?
Giles the billy goat
"Baa"
Post Reply