4 ms·
Advantages of having a common set of conventions might not be apparent if you look at them through the lens of a single ISA (x86 in your example); however, if y
by inkyoto 6y ago
Advantages of having a common set of conventions might not be apparent if you look at them through the lens of a single ISA (x86 in your example); however, if you consider that porting UNIX and a C compiler to a new hardware architecture was everyone's favourite pastime back in the day, having the $ and % conventions greatly helped with reducing the cognitive load and shielding the engineer from quirks and idiosyncrasies of new assembly languages / ISA's.
Registers can have vastly different names across hardware architectures, e.g. they could be named r0, g0, gr1, f2, Motorola 68HC16 has registers named X and Y, or simply numbered register names have been used as well (if my memory serves me well, the IBM System 360 ISA was the most egregious example where LD 1,1 meant load a constant of «1» into the register number 1, albeit I can't remember in which the order). Then there are widly varying processor specific control register names, e.g. i860 had «psr», «epsr», «db», «dirbase», «fir», «fsr», «kr», ki», «t» and «merge» control registers in the ISA, whereas the PDP-11's own processor status word (PSW) was mapped to the 177776 address in the hardware and PSW was a widely used (but not mandated) MACRO-11 preprocessor alias that had to be manually defined in every assembly file.
Also, the register window SPARC architecture utilises names gN for global registers and lN for local registers, and with C compilers habitually emitting jump label names that start with a «L», without the help of extra semantic cues, it would not be immediately obvious whether ld l0, l0 meant «load the address designated the label named l0 into a register named l0», or «store the contents of the register named l0 into an address the label l0 refers to» (I am stretching the SPARC example a bit here to highlight my point as it has a load/store architecture). Therefore seeing a $ was an immediate «heads-up, a constant is about to follow» and, likewise, seeing a % indicated a upcoming register name. It certainly has helped me quite a bit with squickly settling into a new architecture by skimming over assembly outputs of C compilers and assembly parts of UNIX kernels.
AT&T conventions were rather widely applied across for some time, but it appears that they are less frequently followed nowadays.