두 숫자의 gcd를 찾는 데는 다른 방법이 있지만 어셈블리의 명령에 가장 적합한 것이 무엇인지 알고 싶습니다. 어떻게 프로그램에이 메서드를 구현합니까?80x86 어셈블리가 가장 큰 제수 프로그램을 어떻게 프로그램합니까?
는 여기에 지금까지이 작업은 다음과 같습니다
.586
.MODEL FLAT
INCLUDE io.h ; header file for input/output
.STACK 4096
.DATA
number1 DWORD ?
number2 DWORD ?
prompt1 BYTE "Please enter an integer for X", 0
prompt2 BYTE "Please enter an integer for Y", 0
string BYTE 40 DUP (?)
resultLbl BYTE "The greatest common divisor of X and Y is", 0
gcd BYTE 11 DUP (?), 0
.CODE
_MainProc PROC
input prompt1, string, 40
atod string
mov number1, eax
input prompt2, string, 40
atod string
mov number2, edx
mov eax, number1
mov edx, number2
Get_GCD:
xchg eax,edx
cmp eax,edx
jb Get_GCD
sub eax,edx
test edx,edx
jnz Get_GCD
ret
dtoa gcd, edx
output resultLbl, gcd
mov eax, 0
mov edx, 0
ret
_MainProc ENDP
END ; end of source code
나는 그것을 실행하고 아무 일도 발생하지 않습니다.
당신이 어떻게에 조금 정교한 수는 질문에 게시 코드에서 발견 된 문제 (들)을 해결하도록되어? 코드 덤프는 특히 좋은 답변을 만들지 않습니다. – Michael
나는 이것에 관해 Michael과있다. 여기에 숙제로 답을 덤프 (코드 만)하면 도움이되지 않습니다 (원래 답을 읽을 수도 없었습니다). 원래 질문에서 사용하지 않은 라이브러리를 사용했습니다. 나는이 대답에 투표를 거절했다. –