Intel 8086 Assembly - Squaring a Register

In principle, squaring a register value is not difficult:

mov ax, [var]
mov cx, [var]
mul cx         // square of answer is in DX:AX

But I thought of it - a course that I study very well Assembly for prizes; the difference even on one line less can cost up to 5 points.

I understand that this is micro-optimization, but will the following code work the same way ?:

mov ax, [var]
mul ax          // is answer still in DX:AX ?

I suggest a much simpler way of expressing my question: is AX (or AL / AH) a valid parameter for commands muland imulin assembly 8086?

+3
source share
2 answers

Yes, mul axputs ax*axin dx:ax.

+3
source

mul ax, DX: AX = AX * AX , , AX, , , mul bx, BX .

, mul al (mul ah), AX = AXAX, AX = ALAL ( AX = AL * AH), , AX 255, AX, ( AH).

+1

Source: https://habr.com/ru/post/1755218/


All Articles