Multiply numbers without using instructions MUL, IMUL, SHL, SHR, LOOP

后端 未结 4 453
误落风尘
误落风尘 2021-01-22 04:33

Is it possible to calculate result of multiplication without using instructions MUL, IMUL, SHL, SHR, LOOP, JMP in x86 assembly language?

4条回答
  •  再見小時候
    2021-01-22 05:04

    CPUs without a multiply instruction can generally do it with repeated addition but that becomes extremely difficult without loops.

    However, since you haven't specified which specific CPU you're interested in, I would posit one that either has an instruction like:

    add rt, rs, count
    

    instruction which adds rs to rt exactly count times. That would enable you to do it without a loop or jump instruction :-)

    Of course, then you could just have an paxmul instruction that does multiplication for you - not technically a mul but no doubt against the spirit of the question.

    But, to be honest, this question may be seen as moot since you'd be hard pressed actually trying to find a CPU without the instructions you list.

提交回复
热议问题