📄 6.asm
字号:
data segment
buf1 db "Please input numbers n(n<362):$"
buf2 db 10,0,10 dup('$')
buf3 db 0ah,0dh,"1+2+...+n=",24h
buf4 dw ?
data ends
code segment
assume ds:data,cs:code
start: mov ax,data
mov ds,ax
lea dx,buf1
mov ah,9
int 21h
lea dx,buf2
mov ah,0ah
int 21h
and cx,00ffh
mov cl,buf2[1]
lea si,buf2+2
xor bx,bx
mov dl,10
lop: mov al,[si]
and ax,000fh
xchg bx,ax
mul dl
xchg bx,ax
add bx,ax
inc si
loop lop
mov dx,bx
mov ax,dx
call total
mov buf4,ax
lea dx,buf3
mov ah,9
int 21h
mov ax,buf4
call output
mov ax,4c00h
int 21h
total proc
push dx
dec dx
cmp dx,1
je A
call total
A: add ax,dx
pop dx
ret
total endp
output proc
mov cx,0
mov bx,10
B1: mov dx,0
div bx
add dl,30h
push dx
inc cx
or ax,ax
jz B2
jmp B1
B2: pop dx
mov ah,2
int 21h
loop B2
ret
output endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -