0
我想在x86程序集中迭代地找到GCD。不知何故,循環在第一次迭代之後保持終止,因爲餘數= 0。任何想法爲什麼?GCD迭代地在x86 intel程序集中
;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