输入一串数字,求和
运行结果:
程序代码:
datas segmentx db ?
y db ?
z db ?xInputPrompt db 'Enter a number x=$'
yInputPrompt db 0dh,0ah,'Enter a number y=$'
zOutputPrompt db 0dh,0ah,'sum x+y=$'datas endsstacks segmentdb 100h dup(0)
stacks endscodes segmentmain proc farassume cs:codes,ds:datas,ss:stacksstart:push dssub ax,axpush axmov ax,datasmov ds,axmov dx,offset xInputPrompt ;输出请求x输入提示mov ah,9int 21hmov ah,1 ;输入数据保存在X中int 21hsub al,30hmov x,almov dx,offset yInputPrompt ;输出请求y输入提示mov ah,9int 21hmov ah,1 ;输入数据保存在y中int 21hsub al,30hmov y,aladd al,xmov z,almov dx,offset zOutputPrompt ;输出z提示mov ah,9int 21h;输出zmov bx,10mov cx,0mov al,z mov ah,0s: mov dx,0 div bxadd dx,30hpush dxinc cxcmp ax,0jnz ss1: pop dxmov ah,2int 21hloop s1retmain endpcodes endsend main