News for hackers. Stuff that matters.
Re:AT&T Syntax versus Intel Syntax by mixmastamyk on Sunday November 13, 2022 @01:52PM (#33586108)

  op src dest 
is the logical order, the rest of the syntax I don’t care about much.
Re:AT&T Syntax versus Intel Syntax by pjmlp on Sunday November 13, 2022 @02:06PM (#33586260)
In mathematics variable = value, variable receives value, ergo op dest src.

That is logic.

Re:AT&T Syntax versus Intel Syntax by mrkeen on Sunday November 13, 2022 @02:41PM (#33586567)
In mathematics variable = value ≡ value = variable
Re:AT&T Syntax versus Intel Syntax by LudwigNagasena on Sunday November 13, 2022 @02:18PM (#33586382)
That doesn’t follow. variable = value, ergo dest op src.
Re:AT&T Syntax versus Intel Syntax by pavlov on Sunday November 13, 2022 @02:16PM (#33586363)
Indeed. Besides, “let there be light” is clearly destination-first, so this matter was already resolved by Genesis 1:3.
Re:AT&T Syntax versus Intel Syntax by Eleison23 on Sunday November 13, 2022 @03:33PM (#33587038)
Which direction was the Hebrew text written in?
Re:AT&T Syntax versus Intel Syntax by googlryas on Sunday November 13, 2022 @02:45PM (#33586601)
That is just an arbitrary notation, nothing to do with logic. In English at least, "add 4 to x" is more natural than "add to x 4".

Ergo op src dest

Re:AT&T Syntax versus Intel Syntax by bialpio on Sunday November 13, 2022 @03:08PM (#33586794)
But English "add 4 to x" tells you nothing about where to store the result. : - )

"Add 4 to x and store result in x" vs "Let x be x + 4"?

Re:AT&T Syntax versus Intel Syntax by monocasa on Sunday November 13, 2022 @03:17PM (#33586892)
Without any other context, you generally assume that the target is an accumulator.

So "add 4 coins to that bucket", generally means at the end of that operation the bucket contains at least four coins plus any coins that were already in the bucket.

Re:AT&T Syntax versus Intel Syntax by bialpio on Sunday November 13, 2022 @05:26PM (#33588039)
Huh, I think my brain is not wired to think about `x` as a storage, it is closer to "add 3 to x for x = 2", which then gets reduced to "add 3 to 2" and then the destination is missing...
Re:AT&T Syntax versus Intel Syntax by monocasa on Sunday November 13, 2022 @03:19PM (#33586907)
...math has no such order. Half the point of algebra is that the two sides of the equation are semantically equivalent and can be swapped at will.
Re:AT&T Syntax versus Intel Syntax by pjmlp on Sunday November 13, 2022 @03:58PM (#33587264)
Good luck convincing anyone that value = variable makes sense.
Re:AT&T Syntax versus Intel Syntax by monocasa on Sunday November 13, 2022 @04:34PM (#33587580)
My math teachers had no problem with '42 = x' vs 'x = 42' as long as the steps made sense to get there. In fact they'd probably comment that there was no need to go with 'x = 42' if I obviously took a circuitous route simply to end up with x on the left side of the equation, as that would have demonstrated a lack of internalizing some of the base ideas of algebra and it's approach of equation symmetry.
Re:AT&T Syntax versus Intel Syntax by LudwigNagasena on Sunday November 13, 2022 @10:03PM (#33589802)
You should distinguish the meaning of = in mathematical and meta-mathematical statements. “42y = yx, therefore 42 = x” is fine; but “let 42 = x” is not.
Re:AT&T Syntax versus Intel Syntax by fweimer on Sunday November 13, 2022 @05:07PM (#33587882)
Some older C coding styles recommend that order because before compilers added warnings, “if (17 = variable)” resulted in a diagnostic, while “if (variable = 17)” would not. Nowadays, I think most programmers prefer putting the fastest-changing expression first.
Re:AT&T Syntax versus Intel Syntax by pjmlp on Monday November 14, 2022 @01:43AM (#33590871)
Yeah that is due to clever C semantics that that should never had allowed for anything other than boolean expressions in conditionals like proper grown languages.
Re:AT&T Syntax versus Intel Syntax by akira2501 on Sunday November 13, 2022 @04:20PM (#33587452)
And it has no state. Half the point of computation is maintaining state for the purpose of efficiency. So, computation gets an "assignment" operator where pure math lacks one, pure math being relegated to subscripts of time and indicator functions instead.
Re:AT&T Syntax versus Intel Syntax by molticrystal on Sunday November 13, 2022 @03:19PM (#33586914)
Postfix , infix, prefix, crucifix.
Re:AT&T Syntax versus Intel Syntax by AnimalMuppet on Sunday November 13, 2022 @06:35PM (#33588530)
That's just a convention. The way we would order the sentence in English is also just a convention.

You know what the logical convention to use would have been? The order that every assembler on the planet already used.

Re:AT&T Syntax versus Intel Syntax by colejohnson66 on Sunday November 13, 2022 @02:14PM (#33586339)
That “logical” order is only because you’re trying to read it like a sentence (“mov/add ebx into eax”) when you should be reading it like a formula or what it actually is - code. Also, considering Intel created the chip, it makes sense that they should decide how the assembly syntax should be, not AT&T.

The only reason “AT&T syntax” exists for x86 is because people working at AT&T refused to accept Intel’s manual as the authoritative reference on the syntax, and, instead, decided to follow the convention of the PDP, Motorola, etc. family and friends. Hence why `as` (and subsequently `gas`) have that as the default.

Re:AT&T Syntax versus Intel Syntax by SoftTalker on Sunday November 13, 2022 @02:03PM (#33586219)
TFA says "The `source, dest' convention is maintained for compatibility with previous Unix assemblers."
Re:AT&T Syntax versus Intel Syntax by sph on Sunday November 13, 2022 @03:39PM (#33587100)
Be that as it may, the AT&T indirect memory reference `section:disp(base, index,scale)` is an abomination unto God.

At least the Intel one makes actual mathematical sense: `section:[base + index*scale + disp]`

Re:AT&T Syntax versus Intel Syntax by userbinator on Sunday November 13, 2022 @03:44PM (#33587145)
That is extremely confusing for comparisons, which are effectively a subtraction.
Re:AT&T Syntax versus Intel Syntax by mixmastamyk on Sunday November 13, 2022 @08:31PM (#33589261)
I’m talking about moves and copies.
Re:AT&T Syntax versus Intel Syntax by int_19h on Sunday November 13, 2022 @08:43PM (#33589340)
It's even more confusing if moves have a different operation order from arithmetic ops and comparisons, no?
Re:AT&T Syntax versus Intel Syntax by mixmastamyk on Monday November 14, 2022 @01:50AM (#33590905)
No, each should have what makes sense, whether analogous to math or a shell command.
Re:AT&T Syntax versus Intel Syntax by int_19h on Monday November 14, 2022 @03:25AM (#33591458)
This implies that dst<-src "doesn't make sense"; but then why does practically every programming language use this ordering?
Re:AT&T Syntax versus Intel Syntax by mixmastamyk on Monday November 14, 2022 @12:13PM (#33597320)
A minor historical mistake/misdesign around the equals sign. Looks like algebra but fundamentally different.
Re:AT&T Syntax versus Intel Syntax by JonChesterfield on Sunday November 13, 2022 @04:09PM (#33587369)
Sketchy part is when operations read and write with the same argument. Op first is nice for that as it becomes op arg0 arg1.

I quite like the SSA style which tends to be dst0 dst1 opcode src0 src1 but that doesn't model assembly brilliantly. Perhaps that order with read-write arguments required to appear on both sides of opcode with the same symbol has some merit.

Re:AT&T Syntax versus Intel Syntax by NobodyNada on Sunday November 13, 2022 @04:36PM (#33587601)
I used to think this was more intuitive, but after using both for a while I came to the conclusion that putting the destination first is much more practical, because my eyes can scan the left column to quickly find where a register was last written to. If the destination is last, it doesn’t appear in a consistent location horizontally.
Re:AT&T Syntax versus Intel Syntax by Joker_vD on Sunday November 13, 2022 @05:22PM (#33588012)
Which is my all memcpy-like functions in C/C++ standard library take arguments in dst, src order.