what happens when we do mov eax , -4?

僤鯓⒐⒋嵵緔 提交于 2021-02-05 12:21:02

问题


I know that -4 is copied into the EAX register.

My doubts:

  • -4 will be converted into two's complement binary notation before copying to EAX or not?

  • If it is converted into two's complement binary notation , who does the job?

  • Is there any special opcode for denoting negative numbers?

  • What is the possible maximum negative number we can store in EAX register?

  • Is there any special opcode or instructions for signed arithmetic?

what happens when we multiply a negative and positive number in CPU?


回答1:


The conversion to two's complement binary is done by the assembler. The machine code emitted by the assembler contains the data in binary form.

Some opcodes interpret data as unsigned values, some work on signed values, and some opcodes are the same for both. There are no opcodes that are specifically for negative numbers.

The range of eax when interpreted as a signed number is is -2^31 .. 2^31-1.

Assuming the use of a signed multiply instruction, and no overflow, multiplying a negative number by a positive number gives the correct negative result as a two's complement value.



来源:https://stackoverflow.com/questions/47390399/what-happens-when-we-do-mov-eax-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!