我试图在 x86 程序集中迭代地找到 GCD。不知何故,循环在第一次迭代后继续终止,因为余数 = 0。任何想法为什么?
;while r > 0 do
; Set b = a
; Set a = r
; Set r = b % a
;Output a
calculation_loop:
cmp remainder, 0 ;check if remainder is 0
je end_of_calc ;if it is, value in intA is GCD
mov ecx, intA ;set b = a
mov intB, ecx
mov ecx, remainder ;set a = r
mov intA, ecx
mov edx, 0 ;clearing remainder
mov ecx, intA ;process remainder and store in variable
div ecx
mov remainder, edx
mov eax, remainder
call WriteInt
call Crlf
jmp calculation_loop
end_of_calc:
call Crlf
mov eax, intA
mov edx, OFFSET outputPrompt
call WriteString
call WriteInt
call Crlf