push ax
call Calculation
Calculation:
test al, 1
jnz Odd ;нечетное, переход на метку Odd
jz Even ;четное, переход на метку Even
Odd:
push bp
mov bp,sp
mov al,[bp+4]
mul al
pop bp
jmp Show_AX
Even:
push bp
mov bp,sp
mov al,[bp+4]
mov bl, al
mul al
mul bl
sub al, 1
pop bp
int Calculation(short value) {
if (value % 2 == 1) {
char value_l = (char)value; // use only lower 8 bit
return value_l * value_l;
} else {
char value_l = (char)value; // use only lower 8 bit
short first_mul = value_l * value_l;
char mul_l = (char)first_mul; // use only lower 8 bit of result
short second_mul = mul_l * value_l;
second_mul = (second_mul & 0xFF00) + (char)second_mul - 1; // subtract 1 only from lower 8 bits
return second_mul;
}
}