Liste des Groupes | Revenir à cl c |
Bart <bc@freeuk.com> wrote:
If you've followed the subthread then you will know that nobody disputesI dispute this and I think that to same degree several other folks too.
that assignment reads from side of '=' and writes to the other.
Assgmenet _does not read_, it "only" writes. Assigment get two
parameters which are treated in different way. Imagine that you
are programming in a language like C, but are forbidden to use
assignment operator. But fortunately you have C "function"
'assign' with prototype:
void assign(int * p, int v);
Instead of writing
A = B
you need to write
assign(&A, B)
Of course, in real life nobody is going to force you to anything,If you have to use a function, yes. Because you've introduced an artificial split in Where and When those dereferences are done.
but except for fact that in C assignment has value the 'assign'
function is doing the same thing as '=' operator. And you can
see that it is asymetric: first agrument is an addres and right
is a value.
Here is A:=B from my HLLs in one of my ILs (intermediate language):If A is in memory then it could be the same on 2-address architectures:You somewhat miss fact that "A = B" has 3 parts, that is "A", "=", and "B".
>
mov [A], [A]
>
but more typically it needs two instructions (here using RTL):
>
mov R, [A]
mov [A], R
>
Here, [A] appears in both instructions, it means the same thing, and
refers to the same location. Only the position (left vs. right operand,
exactly the same as in A = A) tells you if it's reading or writing.
The second 'mov' instruction came from "=", the first 'mov' is extra.
So instructions look symmetric, but clearly assigment part is asumetric.
This has been covered. The syntactical symmetry is that whatever you have on the LHS, you can write the same thing on the RHS:There is a Load on one operand and a balancing Store on the other. TwoAgain: only store comes from assignment. This is clearly visible
loads or two stores would not make sense here.
if instead of misleading "A = A" you take "A = B" and replace
'B' by various things. Assigment part (store instruction) stays
the same, compution of value changes. In
A = c + d
you get two load (for c and d) and then addition. To put itWhy don't you need to compute the address of B? Why don't you need to load the value of B? It is more like this:
differently, you have
compute value of B
compute address of A
store
In my PUSH B example from interpreted code, it will read B from memory, and write it to a stack (also in memory). POP A will read from the stack, and write to memory.Note that Load and Store can also be considered symmetric: each LoadConcerning instruction, sure. But load is not an assignment.
reads data from somewhere and writes it somewhere else. Just like Store
does. So some instruction sets use the same mnemonic for both.
It may look so in simple misleading cases.
But even if 'A' isI've done this stuff at the chip level (writing into an 8-bit latch for example, then reading from it); it's going to take a lot to convince me that this is anything much different from a read/write or direction flag!
allocated to register and you translate whole "A = B" to single
load, the load computes value of 'B' and if the result is in
correct register the assigment proper can be optimised to no
operation.
Well, you need /something/ to denote whether you are reading or writing some location.And /my/ point was that in virtually every HLL, that dereference to turnI partially agree. Normal case is that write access is explicit
a variable's address, denoted by its name, into either a read or write
access of its value, is implicit.
(for example via '=' in C) and it simly takes variable address. Only
read access in implicit.
Les messages affichés proviennent d'usenet.