问题
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