答:注释:用IA-32汇编指令进行编写
include io32.inc
.data
msg1 byte '请输入第一个数字',13,10,0
msg2 byte '请输入第二个数字',13,10,0
readbuf1 byte 256 dup(0)
readbuf2 byte 256 dup(0)
num byte 00h ;记录负号个数
.code
start:
xor ecx,ecx
xor ebx,ebx
mov eax,offset msg1
call dispmsg
mov eax,offset readbuf1 ;设置入口参数eax
call readmsg ;调用输入字符串子程序
mov edx,eax ;edx记录字符位数
push edx ;字符位数压入堆栈保护--------压入堆栈
mov esi,offset readbuf1 ;esi指向readbuf1
cmp byte ptr [esi],'-'
jz again3
again1:
cmp byte ptr [esi],'.'
jnz again2
push ecx ;堆栈 ecx
inc esi
dec edx
again2:
inc ecx ;read2循环 , 字符为数字时
mov al,[esi]
sub al,30h
imul ebx,10
movzx eax,al
add ebx,eax
dec edx
inc esi
cmp edx,00H
jnz again1
jmp done1
again3: ;read1 记录负号数num
inc esi
inc num
dec edx
jmp again1
done1: ;done 保护ebx,小数化成的整数,ecx小数位数-----------压入堆栈
push ebx
pop ebx
pop ecx
pop edx
sub edx,ecx
dec edx
push ebx
push edx
;------------------------------------------------------------------
xor ecx,ecx
xor ebx,ebx
mov eax,offset msg2
call dispmsg
mov eax,offset readbuf2 ;设置入口参数eax
call readmsg ;调用输入字符串子程序
mov edx,eax ;edx记录字符位数
push edx ;字符位数压入堆栈保护--------压入堆栈
mov esi,offset readbuf2 ;esi指向readbuf1
cmp byte ptr [esi],'-'
jz again6
again4:
cmp byte ptr [esi],'.'
jnz again5
push ecx ;堆栈 ecx
inc esi
dec edx
again5:
inc ecx ;read2循环 字符为数字时
mov al,[esi]
sub al,30h
imul ebx,10
movzx eax,al
add ebx,eax
dec edx
inc esi
cmp edx,00H
jnz again4
jmp done2
again6: ;read1 记录负号数num
inc esi
inc num
dec edx
jmp again4
done2: ;done 保护ebx,小数化成的整数,ecx小数位数压入堆栈
push ebx
pop ebx ;ebx存入换算后的数据二整数
pop ecx
pop edx
sub edx,ecx
dec edx ;edx存入数据二小数位数
pop ecx ;数据一的小数位数
pop eax ;数据一的整数
add ecx,edx
imul eax,ebx
mov ebx,1
done3:
imul ebx,10
dec ecx
cmp ecx,0
jnz done3
mov edx,0
div ebx
call dispuid
mov eax,'.'
call dispc
mov eax,edx
call dispuid
exit 0
end start