MASM使用寄存器作为mod运算符之间的表达式

问题描述 投票:1回答:2

我在masm32中完全是新手,我想实现在(错误的)代码的以下行中描述的这种想法:

mov ebx,(eax mod any_number)

编译器给我错误A2026:期望的常数

我读到寄存器之间不能使用mod操作,因此哪些方法可以帮助我执行相同的想法?

希望您的帮助。

masm masm32
2个回答
2
投票
9%5 = 4模量是什么意思?这是除以2后的余数

mov eax, 9 mod 5

xor edx, edx mov eax, 9 mov ecx, 5 div ecx

现在edx包含模量

0
投票
我想用我的答案来练习这本书的练习2.b

James T. Streib的汇编语言指南:简要介绍],]];result = number % amount mov eax,number cdq ;copy or propagate the sign bit into the edx register idiv amount mov result,edx ;the remainder in the edx register and the ;quotient in the eax register

© www.soinside.com 2019 - 2024. All rights reserved.