私はmasm32の完全な初心者であり、次の(間違った)コード行で説明されているようなアイデアを実現したいと考えています:
mov ebx,(eax mod any_number)
コンパイラでエラー A2026 が表示されます: 定数が必要です
mod操作はレジスタ間で使用できないと読んだので、同じアイデアを実行するのにどの方法が役立ちますか?
あなたの助けを願っています。
9 % 5 = 4 モジュラスとは何ですか? 2つの数を割った余りです
mov eax, 9 mod 5
また
xor edx, edx
mov eax, 9
mov ecx, 5
div ecx
edx には係数が含まれるようになりました
私の答えを、本のGuide to Assembly Language: A Concise Introduction by James T. Streibの演習 2.b に使用したいと思います。
;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