跪求:用汇编语言写 输入一个字符串,以回车符结束,并去掉其内的空格,然后输出。 万分感谢!!! 5
展开全部
data segment
inf1 db 0dh,0ah,'input string: $'
inf2 db 0dh,0ah,'the string without space: $'
buf1 db 81
db ?
db 100 dup(0)
buf2 db 100 dup(0)
data ends
stack segment stack
db 100 dup(0)
stack ends
code segment
assume ds:data,ss:stack,cs:code
start:mov ax,data
mov ds,ax
lea dx,inf1
mov ah,9
int 21h
lea dx,buf1
mov ah,10
int 21h
lea si,buf1+1
mov ch,0
mov cl,[si]
lea di,buf2
lp1:
inc si
mov al,[si]
dec cx
cmp cx,0
jl show
cmp al,32
jz lp1
mov al,[si]
mov [di],al
inc di
jmp lp1
show:
mov byte ptr [di],'$'
lea dx,inf2
mov ah,9
int 21h
lea dx,buf2
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
inf1 db 0dh,0ah,'input string: $'
inf2 db 0dh,0ah,'the string without space: $'
buf1 db 81
db ?
db 100 dup(0)
buf2 db 100 dup(0)
data ends
stack segment stack
db 100 dup(0)
stack ends
code segment
assume ds:data,ss:stack,cs:code
start:mov ax,data
mov ds,ax
lea dx,inf1
mov ah,9
int 21h
lea dx,buf1
mov ah,10
int 21h
lea si,buf1+1
mov ch,0
mov cl,[si]
lea di,buf2
lp1:
inc si
mov al,[si]
dec cx
cmp cx,0
jl show
cmp al,32
jz lp1
mov al,[si]
mov [di],al
inc di
jmp lp1
show:
mov byte ptr [di],'$'
lea dx,inf2
mov ah,9
int 21h
lea dx,buf2
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询