I'm not very happy with the do {} while() statement in C

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: I'm not very happy with the do {} while() statement in C

Post by mhull »

Ras wrote:
bob wrote:It is simply what you get when you keep hacking on an instruction set to add new features.
The customers have decided that they don't want to throw away all the software they already paid for. That's why backwards compatibility won, because it addressed the needs of the paying customers.
But none of that backward-compatibility for a puny chip would have been necessary if IBM hadn't compromised their brand by choosing the Intel 8088 for reasons of expediency. IBM originally wanted the more natural choice of Motorola 68000 since its architecture/assembly was somewhat similar to their mainframe s360 architecture. (The Motorola even has some built-in BCD instructions.) But Motorola manufacturing was not quite ready for the volume IBM needed, so they went with the drastically not-forward-looking but highly available 8088/16 chips, saddling the development community with a scrawny architecture basically forever.

:?
Matthew Hull
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: I'm not very happy with the do {} while() statement in C

Post by bob »

Only question is, who wants to do that? No speed savings to fetch less than an 8 byte value, a penalty in fact... Causes lots of overhead on the network which is big-endian in data transmission (hence the hton functions in the network library...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: I'm not very happy with the do {} while() statement in C

Post by bob »

mhull wrote:
Ras wrote:
bob wrote:It is simply what you get when you keep hacking on an instruction set to add new features.
The customers have decided that they don't want to throw away all the software they already paid for. That's why backwards compatibility won, because it addressed the needs of the paying customers.
But none of that backward-compatibility for a puny chip would have been necessary if IBM hadn't compromised their brand by choosing the Intel 8088 for reasons of expediency. IBM originally wanted the more natural choice of Motorola 68000 since its architecture/assembly was somewhat similar to their mainframe s360 architecture. (The Motorola even has some built-in BCD instructions.) But Motorola manufacturing was not quite ready for the volume IBM needed, so they went with the drastically not-forward-looking but highly available 8088/16 chips, saddling the development community with a scrawny architecture basically forever.

:?
I completely agree, and remember when this issue was being discussed. I was teaching M6800 and then M68000 back in the day. Motorola had this "book" they sold which was a fat ring binder with a 68000 single-board machine in the binder. Was really a nice architecture, matched machines like the xerox, /360 or /370, Dec, etc. IE 16 general purpose registers, single memory operand instructions (which the /360 subverted with the mvc type instructions that were slow as christmas).

And here we are. Good processors, horrible instruction set architecture.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: I'm not very happy with the do {} while() statement in C

Post by Ras »

bob wrote:Was really a nice architecture
However, ALL of the 68k machines were closed ecosystems, unlike the IBM PC. Consequence: upgrade to a new processor, which in itself was difficult or expensive enough, and then the software would stop working because it all relied on the standardised hardware. Not only games, but also many applications. That set a negative incentive for innovation. Don't buy newer stuff or it will stop working. That's why 030 machines were not widespread, and nobody had a 040 one.

Meanwhile in the Intel ecosystem, the main issue was thoughtless game programmers who used fixed delay loops, making games unplayable with faster CPUs. But auto-calibrating delay loops against the RTC was no rocket science, and once that spread, you could safely buy something faster, and things still worked, only better. And everytime you bought new stuff, Intel made money that they put into cranking out ever faster CPUs. It became a self-accelerating cycle.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: I'm not very happy with the do {} while() statement in C

Post by mar »

bob wrote:Only question is, who wants to do that? No speed savings to fetch less than an 8 byte value, a penalty in fact... Causes lots of overhead on the network which is big-endian in data transmission (hence the hton functions in the network library...
I found a use case for this in my current project. Certainly it's not about speed.

Lots of overhead? You can't be possibly serious... bswap is fast as mov and this only covers packet header, not the data you send.
Considering what you have to do on the CPU part to just send a packet, it boils down to nothing, certainly not anything you could even measure.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: I'm not very happy with the do {} while() statement in C

Post by Ras »

mhull wrote:saddling the development community with a scrawny architecture basically forever.
Well, no. The last true x86 architecture was the 486. After that, we still have the external x86 instruction set, but not the architecture; internally, modern x86 CPUs are something entirely different. And nobody cares for the external instruction set. Already 10 years ago, the actual x86 related part of the CPU's die was neglectable.

What this variable length CISC ISA does is actually a sort of compression, and since CPU speed has increased way more than memory speed, this is even a good thing, because it's a better use of the CPU caches.
lauriet
Posts: 199
Joined: Sun Nov 03, 2013 9:32 am

Re: I'm not very happy with the do {} while() statement in C

Post by lauriet »

Hmmmmmmm !!!

What has this got to do with "not happy with do while" ???
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: I'm not very happy with the do {} while() statement in C

Post by lucasart »

lauriet wrote:Hmmmmmmm !!!

What has this got to do with "not happy with do while" ???
This is Talkchess for you...

Thread hijacking at its finest :wink:
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: I'm not very happy with the do {} while() statement in C

Post by mhull »

Ras wrote:
mhull wrote:saddling the development community with a scrawny architecture basically forever.
Well, no. The last true x86 architecture was the 486. After that, we still have the external x86 instruction set, but not the architecture; internally, modern x86 CPUs are something entirely different. And nobody cares for the external instruction set. Already 10 years ago, the actual x86 related part of the CPU's die was neglectable.

What this variable length CISC ISA does is actually a sort of compression, and since CPU speed has increased way more than memory speed, this is even a good thing, because it's a better use of the CPU caches.
Then why does the open source RISC V not resemble the Intel model? The registers look more like, well, IBM s/360, not the Intel/AMD kluge. I think this illustrates the point being made, that the peculiar Intel μC wasn't the best way forward to begin with.
Matthew Hull
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: I'm not very happy with the do {} while() statement in C

Post by syzygy »

Ras wrote:What this variable length CISC ISA does is actually a sort of compression, and since CPU speed has increased way more than memory speed, this is even a good thing, because it's a better use of the CPU caches.
The uniform instruction length of RISC turned out to be not an advantage and perhaps a disadvantage, but I don't think the x86-64 instruction set is a good example of how to encode instructions efficiently.