汇编语言 - 如何做模? [英] Assembly Language - How to Do Modulo?

查看:171
本文介绍了汇编语言 - 如何做模?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么样的模运算符x86汇编?

Is there something like a modulo-operator in x86 Assembler?

推荐答案

DIV 指令(和它的对手 IDIV 有符号数),同时给出商和余数(模)。 DIV R16 把一个32位的数字在 DX:AX 由16位操作数和存储在商 AX 和其余中 DX

The DIV instruction (and it's counterpart IDIV for signed numbers) gives both the quotient and remainder (modulo). DIV r16 divides a 32-bit number in DX:AX by a 16-bit operand and stores the quotient in AX and the remainder in DX.

例如:

mov dx, 0     
mov ax, 1234
mov bx, 10
div bx       ; Divides 1234 by 10. DX = 4 and AX = 123

在32位汇编​​你可以做 DIV EBX 来划分的 64位操作数EDX:EAX 通过 EBX 。见英特尔<一个href=\"http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html\">Architectures软件开发人员手册了解详情。

In 32-bit assembly you can do div ebx to divide a 64-bit operand in EDX:EAX by EBX. See Intels Architectures Software Developer’s Manuals for more information.

这篇关于汇编语言 - 如何做模?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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