4 ms·
I subjectively like AT&T syntax more (as a more familiar to me and having more "machine" vibe). However, I recognize that it's objectively worse for a human co
by dmytrish 6y ago
I subjectively like AT&T syntax more (as a more familiar to me and having more "machine" vibe).
However, I recognize that it's objectively worse for a human coder and contains some syntactic footguns which shoot even a experienced coder regularly:
- `number` (memory displacement/pointer) used instead of literal `$number`. It's an easy automatic mistake even for a person who knows this very well.
- the SIB clauses for x86 (memory addressing with constant Displacement and Scale and Index, Base in registers) look like `D(B, I, S)`: it's possible to remember this, but reading/writing it is not as obvious as `[D + B + I * S]`.
- Intel syntax in general is more similar to high-level languages, even though it's more verbose.
- AT&T syntax has syntactic redundancies like '%' before each register which make code much noisier than needed.
- pwdisswordfish2 6y ago% before register names isn't redundant: it allows you to refer to symbols that would otherwise have the same spelling as register names.
- dmytrish 6y agoYes, that's where AT&T is more logical. In practice, though, naming a symbol with a register name is error-prone and confusing. I'd rather have a way to escape a symbol when it's really needed than to pay the price of noise for an admittedly bad idea.
- cesarb 6y agoNew registers are added all the time (for instance, the %zmm registers), so even if a symbol name doesn't conflict now, it might conflict in the future. Having separate namespaces for symbols and registers is a good idea.
- renox 6y agoGood point, but I wonder if it shouldn't be the labels which should be prefixed instead of the registers?
- burfog 6y agoYes, ideally the labels would be strings in the style of C source code. That includes using \0 to put NUL bytes in the middle. It also includes wide character strings. This allows for unusual languages like LISP and FORTH, without mangling the symbols. Symbols could have commas and spaces.
- hyperman1 6y agoThe intel syntax has some nice gotchas though as the scale can be 1. I believe there is [eax+ebp] which uses the ds segment, but [ebp+eax] uses ss.
- exmadscientist 6y agoThe really fun bit is when you explicitly want to force one form or other, for some reason. Usually this is related to instruction length, but occasionally you used to run into times when one form could help avoid a stall. Keeping tricks like that stable and clearly documented is, uh, not for the faint of heart.
- deleted 6y ago[deleted]