6 ms·
No one should use the AT&T syntax (2021)
- EligibleDecoy 2y agoHow anyone could keep x86 assembly and AT&T’s assembly straight is beyond me. Learning the industry standard assembly was hard enough. Thank goodness there are people who like this stuff, phew!
- ndesaulniers 2y ago> Suffixesq arew annoyingw No, DWORD DWORD DWORD is obnoxious.
- pyrale 2y agoI didn't really read the article, because/but I spent a minute or two playing with the cat. Nice little animation.
- deergomoo 2y agoI love whimsical stuff like this. Software can be very clinical.
- jmclnx 2y agoCool, neko, originally created for X by Masayuki Koba. I have it installed on my Slackware System :) To me, as a non-WEB developer, I think that would be hard to do on a WEB Page. As for AT&T vs x86 assembly, it is a flame war I have not heard from in decades and a couple of arguments were hit upon in the article were part of that war. Nice hearing about an old classic war :) I have not even looked at assembly in many decades, and back then I did the bare minimum with help from someone, so most of the article was over my head.
- rikroots 2y agoAmeko lives! https://aminet.net/package/util/wb/Ameko https://aminet.net/package/util/wb/Ameko
- nonethewiser 2y agoanother implementation: https://dimden.dev/ https://dimden.dev/
- pyrale 2y agoIs this a multiplayer implementation?
- neilv 2y agoIt used to be known as Oneko or Xneko, and chase your Windows or X11 desktop cursor. I once used it on both. Forcing it as a high-contrast distraction upon people who just want to read an article seems like it will discourage some of them. Discouraged people who nevertheless want to read the article, while using their pointing device to scroll, could add this to their uBlock Origin "My filters" tab: ||outerproduct.net/oneko.js$important
- crtasm 2y agoAlternatively you can enable reduced motion in browser settings and its code won't run. https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pref...
- deleted 2y ago[deleted]
- vidarh 2y agoYeah, I have a habit of tracing roughly where I'm reading with the mouse pointer. Which works exceedingly poorly when that means a cat will be running straight across my field of vision continuously while reading.
- supportengineer 2y agoLooks like a port of xneko which has been around since at least the early 1990's, I had it on my old Digital workstation
- irusensei 2y agoMight suggest to change the title to specify this is about the Assembly language.
- VWWHFSfQ 2y agoI'm curious if there's another "AT&T syntax" that would be confused with this? I always assumed was a very well-known assembly style.
- DonHopkins 2y agoAT&T: Local Analog Loopback Test The modem will perform the local analog loopback test if &T1 is selected. The test can be run only when in an asynchronous operation in non-error-correction mode (normal). To terminate the test in progress, the escape sequence must be entered first (see Section 3.1.1). If S18 is non-zero, the test will terminate automatically after the time specified by S18 and the OK result code will be reported. https://web.archive.org/web/20151028101531/http://www.zoomtel.com/documentation/dial_up/100498D.pdf https://web.archive.org/web/20151028101531/http://www.zoomte...
- bawolff 2y agoIs that a syntax? Would anyone be reasonably be confused by it?
- deleted 2y ago[deleted]
- brianmurphy 2y agoI guessed it was about the (Hayes) AT Command Set for modems. AT vs AT&T phone company and childhood memories. (Clearly this was wrong after clicking into the article)
- vidarh 2y agoFun little thing: If you really want to confuse an LLM, try to make it reason about x86 assembler, and watch it trip all over operand order (along with many other things). I've had models assume different operand order in two different places in the same file. x86 assembler really is the gift that keeps on giving. Sadly it doesn't given you anything nice.
- nineteen999 2y agoHonestly they don't do much better for Z80 or 6502 assembly from what I've seen either.
- vidarh 2y agoAny unstructured language seems to be a problem, but x86 just maximises the pitfalls...
- pclmulqdq 2y agoAs someone who has both written and read a lot of assembly in a professional context, my colleagues who are assembly writers very frequently prefer Intel syntax. The ones who are mostly (exclusively) readers seem to generally prefer AT&T. It is pretty undisputed that AT&T is easier for computers to parse, but it's also generally easier for humans to parse when reading it. * The suffixes give you a lot of easy specificity about what the operands are, while they are unnecessary if you already know what the operands are. * DWORD PTR [x + A + B * C] is wordy, but at least the math is clear, and you can write the arithmetic in any order you want (as well as using 3, 5, and 9 as multipliers). X(A, B, C) is more concise and has no operand order to think about, and not terribly hard to read once you learn. * AT&T syntax from a compiler always uses the easy cases and never makes mistakes about placement of the "glyphs" ($, %, etc.). There is none of the example's "movq ($28), %rax" because having a symbol called "$28" is fundamentally dumb. * Operand order in AT&T is really dumb, especially for 3-operand instructions, but if you're just reading, you really don't need to know operand order to understand what's going on. For these reasons, I assume the OP was written by someone who I assume writes a lot of assembly by comparison.
- ketzu 2y ago> Operand order in AT&T is really dumb I always found AT&T order much more intuitive to read. The "what am I doing" and then "where will it go" felt natural to me. But I didn't do much assembler, so my opinion doesn't matter :)
- pclmulqdq 2y agoIf you write for any CPU other than an x86, the Intel assembler syntax matches the syntax order you would get. It also sort of lines up with C and C++ syntax of putting the result on the left. I might be biased as an Intel-syntax-loving assembly-writing heathen.
- ketzu 2y ago> It also sort of lines up with C and C++ syntax of putting the result on the left. The article also discussed this argument, and I find it weird, because higher level languages also put the operation on the right side. Maybe I just prefer having the operation and the target close together? Having `abs(x) = y` put the absolute value of y into x, would be extremly weird to me in C++. > I might be biased as an Intel-syntax-loving assembly-writing heathen. I guess the world is on your side, and I just avoid assembly where possible :D (although, not really because of the syntax part, I can live with either syntax decision in the end after getting used to it)
- Stratoscope 2y ago> ...you should still clean your CPU at least annually: use soap, warm water, and a soft rag to get the gunk out of the transistors. I know the author is just making a joke here, and it is funny. Somehow it reminded me of some actual advice I've seen more than once on /r/thinkpad. I am paraphrasing from memory, but I'm sure I have the gist of it: > When you get a brand new ThinkPad in a factory sealed box, the first thing you must do is completely disassemble it and inspect all the parts. When you reassemble it, repaste the CPU with a quality paste like Arctic MX-4. Now you will have a ThinkPad built to your standards, not Lenovo's.
- kstenerud 2y agoReminds me of a little quip in a 68000 programming language book I read a long time ago. Paraphrasing: "Upon executing HALT, the processor will stop, and nothing short of a reset will get it going again. Although threatening it with a hammer has been known to work on occasion, especially if it knows you've killed before."
- HobbitJack 2y agoReading the Wikipedia page on Halt and Catch Fire it seems this issue actually caused a certain set of illegal opcodes to become an "official' HCF instruction (opcode was DD so it was also known as "Drop Dead") as it was also later used by the engineers for product testing or something.
- ChuckMcM 2y agoAnd there will always be a customer that writes to support asking what size hammer should be used to test that parameter.
- Stratoscope 2y agoWhy, a rowhammer, of course!
- exe34 2y agotangentially reminds me of the advice for waterproofing an outdoors electronics enclosure. use a waterproof enclosure, make sure the seal is properly placed, and intact, seal everything up and drill a hole in the bottom to let the water out.
- DonHopkins 2y agoAT&T syntax: We don't care. We don't have to. We're the phone company. https://www.youtube.com/watch?v=CHgUN_95UAw https://www.youtube.com/watch?v=CHgUN_95UAw
- kstenerud 2y ago> Putting the destination operand first emphasizes the site of mutation. This doesn't make any more convincing an argument than the "linguistic" and "consistency" arguments he shot down earlier. Why should putting the mutated argument first emphasize it any more than putting it second? If you order things the same way every time, people will implicitly know which one is the mutated argument because that's how the language is structured. There really is no strong benefit to either ordering, other than that [src, dst] is closer to human language (which is a minor benefit at best and not worth fighting over).
- gergo_barany 2y agoI'd agree that there is no strong inherent benefit to either ordering, except that it would be good not to needlessly violate expectations about mathematical operations. AT&T also permutes the order of operands of comparisons, which is just bizarre: https://gcc.godbolt.org/z/h6EcP5Yv9 https://gcc.godbolt.org/z/h6EcP5Yv9 "Compare A and B and do X if result is 'less than'" should never mean "do X if B is less than A". Anyway, the most important consideration for me is that standard documentation uses Intel operand order. Intel's manuals are hard enough to read, I wouldn't want to additionally permute operands in my head.
- kstenerud 2y agoCertainly, I'm not defending AT&T in any way, shape, or form. I think it's ugly and confusing as hell. My only point is that argument ordering is not something to worry about, and every argument I've heard one way or the other has been weak at best.
- kragen 2y agothe comparison operand ordering problem is a legitimate problem that i keep having even after having written thousands of lines of assembly in at&t syntax. i hope it goes away after i get to tens of thousands...
- IshKebab 2y agoI think because it's always in the same place and always first. That definitely emphasises it. Personally I think assembly should just have a little more syntax. If we wrote dst = mv src or dst <- add src it would just be obvious.
- pjmlp 2y agoIndeed, I once ported a nasm source into AT&T syntax, never again.
- AshamedCaptain 2y agoFrankly this article's complains read childish to me. Also, the masm syntax is full of weird-o heuristics to account for the fact that you can omit the size of the operands, and I have been hit by that several times. Yes, I prefer writing in masm, but if I had seen at&t syntax first, I am sure I would be a fan of at&t syntax.
- kazinator 2y agoOK, so renaming a file should be: $ mv new-name.txt old-name.txt I defer to the blogger's superior UX expertise!
- bmacho 2y agoIMO there shouldn't be a way to run programs without named arguments.
- jimbobthrowawy 2y agoHave you ever programmed in objectivec or swift? I imagine what you're describing working something like that, but on the command line. A few years back, mpv changed to make named arguments require an equals rather than a whitespace. I've gotten used to it, but it seems like such a weird outlier.
- im3w1l 2y agoWell consider consistency. In assembly's case. Using to from order makes it consistent with C. Consistent with manuals. And in the case of arithmetic instructions, consistent with the order used in mathematical notation. On the other hand for shell scripts, using from to makes it more consistent. With what? Pipelines read a from-file process it and then write. from to.
- kazinator 2y agoIronically, to from order makes it consistent with memcpy/memmove. But that ISO C function came from AT&T Unix. BSD has bcopy which uses "AT&T syntax".
- suzzer99 2y agoHey it works for github pull requests: base <- compare Merge the right into the left. Sure, totally intuitive.
- tmtvl 2y agoEh, there's examples of every permutation: ;; Lisp (setf a (xor b c)) ;; Kanren ;; Unification instead of mutation. ;; Therefore these are equivalent: (== a (xor b c)) (== (xor b c) a) # Contrived untested Raku example $b ^^ $c ==> my $a; % Amberjack b xor c -> a // Java var a = b ^ c;
- im3w1l 2y agoIn almost every respect I have a slight preference for the intel way (nasm dialect), but could live with the at&t one. But it's just ridiculous how mov eax, [edi + 8*ebx + 3] is written as mov 3(%edi,%ebx,8), %eax
- deleted 2y ago[deleted]
- torstenvl 2y ago> mov eax, ebx ; (1) load one dword from the EBX register and store it in the EAX register This is a mov instruction, not a ld instruction. There is no loading going on. The value in EBX is already loaded. Otherwise it wouldn't be in a register. It's hard for me to take someone seriously who doesn't understand the difference between a load and a move but feels as if they have the right to an opinion about assembly.
- gergo_barany 2y agoNote that LEA (load effective address) doesn't load from memory either. Intel also uses "load" in the descriptions of register-to-register moves: https://www.felixcloutier.com/x86/mov-2 https://www.felixcloutier.com/x86/mov-2 . Although confusingly, here "load register X" seems to mean "store to register X" (and again, not a memory store). Anyway, the word "load" doesn't imply "from memory" the way you suggest.
- torstenvl 2y agoNo, Intel gets the distinction exactly right: "The MOV instruction performs basic load data and store data operations between memory and the processor’s registers and data movement operations between registers." https://cdrdv2-public.intel.com/819723/325462-sdm-vol-1-2abcd-3abcd-4.pdf https://cdrdv2-public.intel.com/819723/325462-sdm-vol-1-2abc... Volume 1, page 7-3 (page 181 of the PDF). In the context of assembly, load/store refers to memory ⇆ register.
- gergo_barany 2y agohttps://www.felixcloutier.com/x86/lea https://www.felixcloutier.com/x86/lea: "LEA — Load Effective Address" https://www.felixcloutier.com/x86/mov-2 https://www.felixcloutier.com/x86/mov-2: "MOV — Move to/from Debug Registers ... At the opcode level, the reg field within the ModR/M byte specifies which of the debug registers is loaded or read. The two bits in the mod field are ignored. The r/m field specifies the general-purpose register loaded or read."
- comex 2y agoThe best argument for Intel syntax is subtraction and division. Intel syntax's sub rax, rbx is equivalent to AT&T syntax's subq %rbx, %rax ...and it computes (rax - rbx), not (rbx - rax)! I suppose you could justify the AT&T syntax as meaning "subtract rbx from rax". But it seems incredibly counterintuitive to me. Edit: As another comment pointed out, this issue also applies to comparisons and is even worse there. Intel's cmp rax, rbx jg foo is equivalent to AT&T syntax's cmp %rbx, %rax jg foo and it means "compare rax to rbx; if it's 'g'reater, then 'j'ump to foo". There's no good way to write that in English where rbx comes first. At best you could say: "compare rbx to rax; if rax is greater"…
- amluto 2y agoI think there are two legitimate reasons to use Intel syntax: 1. It matches the manual. AMD and Intel’s manuals agree about operand order, and IMO there is no justification whatsoever for an assembly syntax to fail to match the documentation. This is especially true for 3-address instructions and for two-input instructions like CMP. All these arguments about mathematical notation or linguistics are nonsense in my book. The correct order for the operands of ADD is what the corresponding manual says. 2. Intel address syntax is so much better than AT&T’s that it’s not even funny.
- jcranmer 2y agoDon't forget the weirdness of AVX-512 masks in AT&T syntax!
- amluto 2y agoI sincerely hope I never have to touch code like that. I have messed with code to save and restore AVX-512 registers, and this is about the only thing I like about AT&T syntax: there’s a uniform way to specify the instruction size that works when the instruction has no operands. I’m looking at you, XSAVE, XRSTOR, SYSRET, etc. The manual has no useful syntax to offer here.
- ack_complete 2y agoAT&T syntax for x86-64 introduces tons of nonstandard instruction names that you will never find in the official manuals. WTF are: movabs, cqto, filds, and ljmp? I also don't understand why x86 syntax has to be mutilated when special syntax is supported for other architectures. It's somehow OK for ARM64 to have [x1, w9, sxtw #2] or [x3, #32]! and 68K to have (%a2,%d1.l8), but x86-64 can't have [%rcx + %rdx4]. Reading x86-64 disassembly in AT&T syntax is just painful.
- m463 2y agoI learned ibm 370 assembly first, PDP-11 assembly second, then I think Z80. I found them to be very regular and understandable. So when I encountered intel chips and their assembly syntax, I disliked them. So about that time I switched to higher level languages. Are there still chips left have a nice orthogonal assembly language? I vaguely recall 68k being orthogonal too.
- lupire 2y agoHowant people are writing nee assembly languages such that this matters? Why would anyone even write in an assembly language instead of a human friendly language that has a simple compiler to to goofy assembly?
- layer8 2y agoTASM Ideal mode was great.
- dang 2y agoRelated: AT&T syntax is broken (2021) - https://news.ycombinator.com/item?id=33652023 https://news.ycombinator.com/item?id=33652023 - Nov 2022 (44 comments) Why no one should use the AT&T syntax ever - https://news.ycombinator.com/item?id=27089329 https://news.ycombinator.com/item?id=27089329 - May 2021 (8 comments) Also: AT&T Syntax versus Intel Syntax (2001) - https://news.ycombinator.com/item?id=33585154 https://news.ycombinator.com/item?id=33585154 - Nov 2022 (105 comments) What was the original reason for the design of AT&T assembly syntax? (2017) - https://news.ycombinator.com/item?id=26127368 https://news.ycombinator.com/item?id=26127368 - Feb 2021 (58 comments) Others?
- aap_ 2y agoI much prefer AT&T to intel syntax. i concede that cmp has the operand order swapped but otherwise i have to think less about it. Of course it's a matter of taste, but to me at least AT&T just feels nicer.
- clausecker 2y agoI like it, too. If you understand how it came to be (https://stackoverflow.com/a/42250270/417501 https://stackoverflow.com/a/42250270/417501), it's quite sensible. Also saves me from writing DWORD PTR all over the place.
- OnionBlender 2y agoYears ago I emailed the creator of Exapunks (a puzzle game where you write assembly in a made up instruction set) and asked why he used AT&T syntax instead of Intel syntax. He said it seemed more intuitive for English speakers. > This is usually only brought up by people who have prior assembly programming experience, which makes me think we made the right choice.
- trealira 2y agoI haven't played Exapunks, so I can't say, but about AT&T vs Intel: maybe the order of "mov source, destination" and "sub subtrahend, minuend" is easier, since it lines up with English phrases like "move this into that" and "subtract this number from that number," but everything else about Intel syntax was easier for me when I first learned assembly.
- spcharc 2y agoI love AT&T syntax. I originally started with Intel syntax when learning assembly since it was just in my textbook. I sometimes ran into weird syntax issues I didn't yet understand. For example, why "mov eax, [ebx + 2 * ecx + 4]" is allowed, but not "mov eax, [ebx + ecx + edx]" (1)? Or maybe "mov eax, [ebx + 3 * ecx]" (2)? Or maybe "mov eax, [2 * ebx + 4 * ecx]" (3)? As long as it is a math expression it should work right? Why did the compiler keeps telling me the expression is invalid? Later when I learned about AT&T syntax, everything started to make sense. The syntax ensures you cannot construct (1) and (3), and when trying to use (2) it explicitly tells you it expects 1, 2, 4, or 8 but got 3. I started to use AT&T syntax since then. In my opinion, there is one most confusing part about AT&T syntax, which is the condition based instructions. I guess the original author of the article did not do much programming with AT&T syntax so they did not notice. cmpl %eax, %ebx jae label Now tell me if eax is bigger, should you jump to label? Instead, with Intel syntax it is pretty straight forward. The "jae ..." following "cmp ebx, eax" translates to "if (ebx >= eax) goto ..." (BTW, the cat or whatever following your mouse pointer is super annoying)
- rep_lodsb 2y ago>For example, why "mov eax, [ebx + 2 * ecx + 4]" is allowed, but not "mov eax, [ebx + ecx + edx]" Because it's translated into a single machine instruction!!! "mov eax,[[ebx]]" doesn't work either - not on x86 at least, historically there were architectures that had indirect memory references :) It's still MUCH easier to read and write. How do you even remember the order in AT&T syntax? Shouldn't the scale factor maybe be given as a shift count since that's how the hardware works? By using familiar arithmetic expressions, it becomes perfectly clear what is meant, and anyone who actually writes assembly will quickly learn what forms are allowed. And if you are only reading the code, it doesn't matter. Of course, AT&T syntax comes from UNIX, where the zeroth commandment is "Thou shalt have no other programming languages but C and shell scripts". People who have invested the effort to memorize something like 42 different levels of operator precedence, and fluently read and write symbol vomit like "(((void *)(int [])fn(foo,bar=baz==quux++))" are obviously desperate to make assembly look EVEN MORE complicated...
- 2y ago
- molticrystal 2y ago>For example, consider the following number >030514 >...that number is understand to mean ‘add the contents of registers A1 and A4, and store the result in register A5’. The association between this numeric form and its meaning under the ISA is completely arbitrary They are not as arbritary as first glance as they might appear, related functions often cluster together creating families of opcodes. How many instructions in the family, what circuits and hardware components they use, and other optimization factors influence the arrangement of instructions as well which can determine the binary number the opcode uses.
- hi-v-rocknroll 2y agoI grew up on Intel-style because that's what Borland and Microsoft assemblers used. This article seems like stylistic bikeshedding/religious war of left vs. right hand destination apart from a few ergonomic gotchas.
- prabhu-yu 2y ago1.Once we learn Intel syntax, same knowledge can re-used in other ISA (RISC-V, ARM) This is not true for AT&T syntax, hence one more no for the use of AT&T.
- flohofwoe 2y agoHere is where Intel syntax breaks down: > mov eax, ebx ; (1) load one dword from the EBX register and store it in the EAX register Note how the comment says something entirely different than the assembler mnemonics ("load" instead of "move", and the source and target register in the comment are in different order than in the mnemonics). My simple rule of thumb when I worked both on Z80 and 68k in the early 90s: - LOAD dst WITH src - MOVE src INTO dst Intel syntax would make a lot more sense if it would use the Z80-style LD instead of MOV. Not that I'm an AT&T syntax fan, but this one detail always bothered me. But I guess I should get used to it because ARM also got it "wrong" ;)