CS:APP example uses idivq with two operands?

前端 未结 3 843
栀梦
栀梦 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 01:57

    I think your book has made a mistake.

    idivq only has one operand. If I try to assemble this snippet:

    idivq $9, %rcx
    

    I get this error:

    test.s: Assembler messages:
    test.s:1: Error: operand type mismatch for `idiv'
    

    This works:

    idivq %rcx
    

    but you probably already know that.

    It may also be a macro (unlikely, but possible. credit to @HansPassant for this).

    Perhaps you should contact the book's author so that they can add an entry to the errata.

提交回复
热议问题