微机原理,用汇编语言,编写求两个数的最大公约数!!跪求!!!

2025-03-23 16:59:29
推荐回答(1个)
回答1:

用汇编语言编写程序,提示从键盘输入两个数,求这两个数的最大公约数。基于WIN32、MASM实现include io32.inc .datain_msg1 byte 'Enter a number: ',0 in_msg2 byte 'Enter another number: ',0 out_msg byte 'The common denominator is: ',0.codestart:mov eax,offset in_msg1 ; 提示输入第一个数据 call dispmsg call readsid ; 输入第一个数据 mov ebx,eax ; 保存到EBX mov eax,offset in_msg2 ; 提示输入第二个数据 call dispmsg call readsid ; 输入第二个数据 mov ecx,eax ; 保存到ECXcall againmov eax,offset out_msg call dispmsg mov eax,ecx call dispsid jmp done ; 转移到结束again proccmp ebx,ecxjnl frontxchg ebx,ecx front: xor edx,edx mov eax,ebxdiv ecxcmp edx,0