当我们执行 mov eax , -4 时会发生什么? [英] what happens when we do mov eax , -4?

查看:59
本文介绍了当我们执行 mov eax , -4 时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 -4 被复制到 EAX 寄存器中.

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

我的疑惑:

  • -4 在复制到 EAX 之前会被转换成二进制补码吗?

  • -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?

我们可以在 EAX 寄存器中存储的最大负数是多少?

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

有符号算术有什么特殊的操作码或指令吗?

Is there any special opcode or instructions for signed arithmetic?

当我们在 CPU 中将负数和正数相乘时会发生什么?

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

推荐答案

二进制补码的转换是由汇编程序完成的.汇编器发出的机器码包含二进制形式的数据.

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.

当解释为有符号数时,eax 的范围是 -2^31 .. 2^31-1.

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.

这篇关于当我们执行 mov eax , -4 时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆