Re: for your languages
- From: Seebs <usenet-nospam@xxxxxxxxx>
- Date: 03 Jun 2011 00:44:25 GMT
On 2011-06-02, Rui Maciel <rui.maciel@xxxxxxxxx> wrote:
Well, it will tie someone to a particular machine until someone invests
his time developing a compiler which is able to abstract that and, by
doing that, support other machines. After all, the language isn't the
compiler and the compiler isn't the language.
This really makes no sense. No abstraction of
Tell me this: is it impossible to perform that specific operation, either
through a single instruction or through a set of instructions, in two
Not in general, no.
Look at it this way: How would you do that on one of the Cell's SPE
units? Or, heck. PowerPC. What exactly is the equivalent of
Answer, there isn't one, *because there is no such thing as ax*. The PowerPC
chip does not have the same map of registers.
Similarly, let's say we start with some 68k assembly.
You can't translate this to x86, because x86 doesn't HAVE eight general
purpose data registers like that. (And if my memory's wrong, and it does,
no problem; just pop over to SPARC or something where there's even MORE
general purpose registers.)
If it is possible then it is also possible to
express that operation through an assembly language which supports both
But it's not possible, because the entire point is that the architectures
DON'T have corresponding elements.
Please explain how you'd abstract
from a PPC macro assembler to something else...
If the processor architecture doesn't support out of order execution then
it can be omitted. If the target architecture supports it but doesn't
provide a way to enforce in-order execution then there could be a problem,
but I'm not aware of such a case.
There's a lot more to it than that. The semantics are not as simple as
a quick summary might make it sound.
The point of using assembly is that it lets you do things which simply
*don't* map to other chips. Say you're on an x86, and you're in segmented
mode. There's *nothing* you can do on a 68k that is even analagous to the
trickery that goes on when you take advantage of overlapping segments on
So, really, that's where this all breaks down; in reality, assembly code
is full of things which simply do not translate. That's why people use
it; because there's no way to express these things except in terms of a
given CPU. What bits might be set outside of the directly affected registers
by an operation? Different bits on different CPUs for different operations,
and the registers they'd be set in aren't necessarily translateable.
And this is why you can't meaningfully talk about an assembler being
portable in the way that C is. Fundamentally, C is specifying *semantics*,
which are an abstraction that need not correspond to specific processor
events. There are operations in C that generate no code on one machine
and lots of code on another, because the "function" described is irrelevant
in one system and complicated in another. Assembly, by contrast, is
specifying *instructions*. They don't necessarily have semantic content
that is comprehensible in any way separate from the details of that specific
chip. If you execute an instruction to "clear condition code register", that
doesn't necessarily translate to a machine which has more than one such
register, using them for different things. You can't talk about the
semantics of the code and translate at that level, because the code hasn't
*got* abstract semantics.
The closest you could come would be to write an entire processor simulator
and then just assemble the code. This clearly leaves us with a gigantic
difference between C and a "macro assembler".
Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@xxxxxxxxx
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
- Prev by Date: Re: Puzzling #define
- Next by Date: Re: Puzzling #define
- Previous by thread: Re: for your languages
- Next by thread: Re: for your languages