4 ms·
I've seen assembly languages that do separate target and source operands with an = sign. So you would write that something like: mov eax = 5 and use a sim
by tom_mellior 9y ago
I've seen assembly languages that do separate target and source operands with an = sign. So you would write that something like:
mov eax = 5
and use a similar style for other things, like:
add eax = ebx, ecx
This is very nice and clear. But it only really works for three-address assembly languages, i.e., where the target register may be different from the sources. In classical x86, the target of an add is identical to one of the operands. So you would need something like
add eax += ebx
or
add eax = eax, ebx
where you must duplicate a register. Presumably when these assembly languages were developed 40 years ago, this was perceived as too much syntax.
- Koshkin 9y ago> nice and clear Looks absolutely horrible to me, why not simply eax = ebx + ecx ?
- throwaway-1209 9y ago+1. Make it look more like a severely restricted version of C.
- tom_mellior 9y agoI guess because there's no simple infix operator for every operation implemented by the machine. Also, the addition may be floating-point or 32, 16, or 8 bit, signed or unsigned, possibly vectorized. An opcode is a good place to express these things.
- throwaway-1209 9y agoOpcodes are fine, no one is saying everything has to be expressed as an operator. I'd like to see more of a C/C++ intrinsics syntax, but with total control over the order of instructions and register allocation. Basically same power as assembly, syntax close to intrinsics, but you tell it which registers to use, and there's one instruction per line, and they're executed exactly as you write them, with no creativity on the part of the compiler.