大家好,又见面了,我是你们的朋友全栈君。
include irvine32.inc;
.data
i dword 0;
sum qword 0;
str1 byte “请输入16进制的(32位整数)乘数和被乘数”,0
str2 byte “乘积为:”,0;
j dword 0;
.code
main proc
L1:
mov edx,offset str1;
call writestring;
mov j,0;
mov eax,0;eax为(低32位)乘积值;
mov ebx,0;edx为(低32位)乘积值的中间值
mov edx,0;
mov esi,0;dsi为(高32位)乘积值的中间值
mov edi,0;edi为(高32位)乘积值;
mov cl,0;cl为移位的位数
call readhex;
cmp eax,80000000h;
jna L4;
neg eax;
inc j;
L4:
mov ebx,eax; ebx存储乘数(来移位的)
;call writeint;
call readhex;
cmp eax,80000000h;
jna L5;
neg eax;
inc j;
L5:
mov i,eax;
;call writeint;
mov eax,0;
cmp ebx, 0;
jne L2;
cmp i,0;
je finally;
L2: cmp ebx,0;
jz quit;
shr ebx,1;
jnc next;if(ZF==0)
mov esi,0;每次都要清零;
mov edx,i;
shld esi,edx,cl;
shl edx,cl;
add eax,edx;
jnc L3;if(ZF==0)
add edi,1;
L3:
add edi,esi;
next:
inc cl;
jmp L2;
quit:
call crlf;
mov edx,offset str2;
call writestring;
mov ebx,eax;
cmp j,1;
jne L6;
add edi,80000000h
;call writestring
L6:
mov eax,edi;
call writehex;
mov eax,ebx;
call writehex;
call crlf;
jmp L1;
finally:
exit
main endp;
end main
转载于:https://www.cnblogs.com/hqu-ye/archive/2013/02/25/2932588.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/136773.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...