In principle, squaring the value of a register isn't hard:
mov ax, [var]
mov cx, [var]
mul cx // square of answer is in DX:AX
But I got to thinking -- the course that I'm learning Assembly for prizes efficiency very highly; a difference of even a single line less could be worth up to 5 points.
I realize this is micro-optimization, but would the following code perform the the same way?:
mov ax, [var]
mul ax // is answer still in DX:AX ?
I suppose a much simpler way of expressing my question: is AX (or AL/AH) a valid parameter for the mul
and imul
commands in 8086 assembly?