CS:APP example uses idivq with two operands?

前端 未结 3 828
栀梦
栀梦 2020-12-07 01:24

I am reading about x86-64 (and assembly in general) through the book \"computer systems a programmer\'s perspective\"(3rd edition). The author, in compliance with other sour

3条回答
  •  隐瞒了意图╮
    2020-12-07 02:02

    Interestingly, gas seems to allow the following:

    mov $20, %rax
    mov $0, %rdx
    mov $5, %rcx
    idivq %rcx, %rax
    ret
    

    This is still performing the one operand division under the hood, but it LOOKS like two-operand form. As long as the first operand is a register and the second operand is specifically %rax, this works. However, in general idivq seems to require the one operand form.

提交回复
热议问题