dseg segment
msg db '1+2+3+...+10=$'
dseg ends
assume cs:cseg, ds:dseg
cseg segment
start:
mov ax, dseg
mov ds, ax
lea dx, msg
mov ah,9
int 21h
mov cx, 10 ;控制长度
mov ax, 0 ;保存计算结果
mov bx, 1 ;从1开始累加
loop0:
add ax, bx
inc bx
loop loop0
call print
mov ax,4c00h
int 21h
;print(ax)
print proc near
xor cx, cx
mov bx, 10
p0:
xor dx, dx
div bx
xor dx, 0e30h
push dx
inc cx
cmp ax, 0
jnz p0
p1:
pop ax
int 10h
loop p1
ret
print endp
cseg ends
end start
温馨提示:答案为网友推荐,仅供参考