Hacker News new | ask | show | jobs
by epcoa 868 days ago
> and the x86 assembly syntax where the destination is the last register.

ITYM AT&T :). The idea is that the basic grammar is common across architectures to help compiler backend authors. The historical reason for the ordering is because that’s how it was on the PDP-11, the “mother” assembly. And all AT&T/GNU versions preserve this ordering regardless of the vendor format.

> The other is the syntax most commonly used in practice

It didn’t always used to be this way. In the dark ages before NASM, MASM was a top warez.

And depending on what you’re doing I don’t think Intel syntax is uncommon, gas will even accept it for the most part these days.

> "wait, which version is this? the one that does destination first or destination second?"

There must be some mnemonic to associate sigil vomit with destination last. Shitty sigils come out the ass?

1 comments

> The historical reason for the ordering is because that’s how it was on the PDP-11

True, I think. I mean, that certainly was the case for PDP-11 and VAX asm. 68000 too (pretty much a 32 bit, 16 register PDP-11). Whether that was the actual reason is more debatable.

> And all AT&T/GNU versions preserve this ordering regardless of the vendor format.

False. GNU `as` puts the destination register first for all of Arm32, Arm64, MIPS, PowerPC, RISC-V. Every RISC ISA, as far as I know. Except for store instructions, where the source register is first.

Yes absolutely right about the modern RISC archs. I should have just said AT&T not AT&T/GNU. The difference is that x86, VAX and SPARC were AT&T UNIX porting efforts prior to or alongside GNU, and GNU sort of chose to inherit that. The newer RISC architectures did not have the hand/influence of AT&T as far as I know.

As far as the operand ordering with the x86, the thing is they did flip it from the Intel syntax and the beginnings of this port date back to Version 7 (1978), a few years before GNU. So what was the reason other than it looked like the incumbent/precedent PDP-11? I haven't heard it being much more than circumstance.