質問:
A を B に分割し、A < B と仮定します。答えは、A が B に q 回入り、余りが R になります。
例: 7 は 20 に入る 2 倍余り 6
ヒント: A > 差になるまで、B から A を引きます。引いた回数を数えて、その差が余りになります。
Ex 20-7 = 13 13 – 7 = 6 6 <7 so the count is 2 and the remainder is 6
これは私のコードです。完全ではありません。この問題のやり方がわかりません。どんな助けでも感謝します。
TITLE PROJECT
INCLUDE Irvine32.inc
.data
prompt1 byte 'Enter number A:',0
prompt2 byte 'Enter number B:',0
a dword ?
b dword ?
remainder dword ?
.code
main proc
call clrscr
mov eax,0
mov ebx,0
mov edx,offset prompt1
call writestring
call readint
mov a,eax
mov edx,offset prompt2
call writestring
call readint
mov b,ebx
mov eax,a
mov ebx,b
sub ebx,a ;set edx to 0
div ebx
mov remainder,ebx
;xor eax,eax
call writedec
call crlf
exit
main ENDP
END main