-5

質問:

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
4

1 に答える 1

1

ループは次のように実装されます。

ループダウン:

    mov   ecx, 10   ; count from 10 to 0

 label:
    dec   ecx
    loop label

ループアップ:

   xor  ecx,ecx   ; count from 0 to 10
 label:
   inc ecx
   cmp ecx, 10
   jne label

次に、アルゴリズムがどのように機能し、この情報をどのように適用するかを考えてください。

于 2013-12-05T19:04:14.107 に答える