我是 masm32 的新手,我想实现以下(不正确的)代码行中描述的这种想法:
mov ebx,(eax mod any_number)
编译器给了我错误 A2026:预期常量
我读到不能在寄存器之间使用 mod 操作,那么哪些方法可以帮助我执行相同的想法?
希望得到您的帮助。
9 % 5 = 4 模数是什么意思?是两个数相除后的余数
mov eax, 9 mod 5
或者
xor edx, edx
mov eax, 9
mov ecx, 5
div ecx
现在 edx 包含模数
我想用我对汇编语言指南的练习 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