Error moving a constant byte value into

前端 未结 2 1536
南笙
南笙 2021-01-03 01:46

I\'m working through Computer Systems, A Programmer\'s Perspective (3rd edition), and Practice Problem 3.3 contains the following line:

movb $0xF, (         


        
2条回答
  •  情书的邮戳
    2021-01-03 02:37

    For 64-bit x86; there is nothing wrong with the instruction movb $0x0F, (%ebx). It assembles to 0x67, 0xC6, 0x03, 0x0F.

    The book is wrong.

    Note that all instructions can be bugs (simple example: using add when you wanted to use sub), and movb $0x0F, (%ebx) may be a bug (e.g. maybe the value was supposed to be 0xFF, maybe it was supposed to use a different register, maybe it was supposed to use rbx, maybe it was supposed to be a lea, ..). This doesn't mean that it's always a bug (e.g. 32-bit addresses are perfectly legal and sometimes desirable in 64 bit code).

提交回复
热议问题