对于IDIV数类型不匹配 [英] Operand type mismatch for idiv

查看:346
本文介绍了对于IDIV数类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在写它产生的x86-32 code编译器。

I am currently writing a compiler which produces x86-32 code.

不过,我试图执行除法时有问题。

However, I have a problem when trying to implement division.

idivl %ecx, %ebx

这code给了我以下错误:

This code gives me the following error:

Error: operand type mismatch for `idiv'

有谁知道为什么吗?上述各行是唯一的时间 IDIV 出现在我的code。

推荐答案

据我的参考, IDIV 除以64位整数 EDX: EAX 由提供的寄存器的值。

According to my reference, IDIV divides the 64-bit integer EDX:EAX by the provided register's value.

IDIV - 整数除法

idiv — Integer Division

的IDIV指令除以64位整数的EDX的内容:EAX(通过查看EDX作为最显著四个字节构成
  和EAX作为至少显著四字节)由指定的操作数
  值。除法的商数结果存储到EAX,而
  其余的放在EDX。

The idiv instruction divides the contents of the 64 bit integer EDX:EAX (constructed by viewing EDX as the most significant four bytes and EAX as the least significant four bytes) by the specified operand value. The quotient result of the division is stored into EAX, while the remainder is placed in EDX.

语法

idiv <reg32>
idiv <mem>


  
  

例子

Examples

idiv ebx ; divide the contents of EDX:EAX by the contents of EBX. Place the quotient in EAX and the remainder in EDX.
idiv DWORD PTR [var] ; divide the contents of EDX:EAS by the 32-bit value stored at memory location var. Place the quotient in EAX

和中EDX其余部分。

idivl 指令的行为完全像 IDIV ,除了 idivl 是一个符号的除法。

The idivl instruction behaves exactly like idiv, except idivl is a signed division.

请参阅 http://www.cs.virginia.edu/ 〜埃文斯/ cs216 /引导/ x86.html

另一位伟大的裁判: http://ref.x86asm.net/

这篇关于对于IDIV数类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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