汇编语言(二十四)之输出n行星号
输入一个数n,输出n行星号
程序运行:
代码:
datas segment
line_number_max_len db 0ffh
line_number db 0, 100h dup(?)
input_line_number_prompt db 'input line number:$'
output db 0dh,0ah,'**********$'
output_err db 0dh,0ah,'input errorr$'
datas ends
stacks segment stack
db 100h dup(?)
stacks ends
codes segment
assume cs:codes,ds:datas,ss:stacks
SKIPLINES proc far
start:
push ds
mov ax,0h
push ax
mov ax,datas ;初始化ds
mov ds,ax
lea dx,input_line_number_prompt ;输入提示
mov ah,9
int 21h
lea dx, line_number_max_len ;输入要打印长度
mov ah,10
int 21h
cmp line_number[0],0 ;将字符串转成数字
jz err
mov ax,0
mov dx,0
mov di,10
mov si,1
mov cl,line_number[0]
mov ch,0
s:
mov bl,line_number[si]
cmp bl,'0'
jb err
cmp bl,'9'
ja err
sub bl,30h
mov bh,0
mul di
add ax,bx
inc si
loop s
mov cx,ax ;输出多行字符串
s1:
lea dx,output
mov ah,9
int 21h
loop s1
jmp exit
err:
lea dx,output_err
mov ah,9
int 21h
exit:
ret
SKIPLINES endp
codes ends
end SKIPLINES