输入一组字符串在把它们的数字和字母分开放到别的数组
assume cs:code,ds:datadata segment
str0 db 20
db?
db 20 dup(?)
show db 0ah,0dh,"$";;回车换行
data ends
smg segment
letter DB20 DUP ('$');;用来放字母
numDB20 DUP ('$');;放数字
smg ends
code segment
start:mov ax,data
mov ds,ax
lea dx,str0
mov ah,0ah
int 21h
lea dx,show;;输入和输出第一次的字符串
mov ah,09h
int 21h
mov cl,str0+1
mov ch,0
lea si,str0+2
mov ax,smg
mov ds,ax
lea di,num
lea bp,letter
nex: mov dl,
n:CMP DL,'0';;识别数字和放入
jb le0
cmp dl,'9'
ja le0
mov dl,
mov ,dl
inc di
inc si
le0:
cmp dl,'z'
ja s
le1:cmp dl,'a';;识别字母和放入
jb s
mov al,
mov ,al
inc si
inc bp
s: dec cl
JNZ nex
sow:lea dx, letter ;;输出变成乱码 高手帮帮我!!!
mov ah,09h
int 21
so: lea dx, num
mov ah,09h
int 21h
mov ax,4c00h
int 21h
code ends
end start 本帖最后由 superbe 于 2018-11-24 22:02 编辑
改完后的代码:
;输入一组字符串在把它们的数字和字母分开放到别的数组
assume cs:code,ds:data
data segment
str0 db 20
db?
db 20 dup(?)
show db 0ah,0dh,"$" ;回车换行
data ends
smg segment
letter DB20 DUP (') ;用来放字母
numDB20 DUP (') ;放数字
smg ends
code segment
start:mov ax,data
mov ds,ax
lea dx,str0
mov ah,0ah
int 21h
lea dx,show ;输入和输出第一次的字符串
mov ah,09h
int 21h
mov cl,str0+1
mov ch,0
lea si,str0+2
mov ax,smg
mov es,ax ;把smg段地址给es
lea di,num
lea bp,letter
nex: mov dl,
n:CMP DL,'0' ;识别数字和放入
jb le0
cmp dl,'9'
ja le0
mov es:,dl
inc di
jmp short s
le0:
cmp dl,'z'
ja s
le1:cmp dl,'a' ;识别字母和放入
jb s
mov es:,dl
inc bp
s: inc si
dec cl
JNZ nex
sow: mov ax,smg
mov ds,ax ;把smg段地址给ds
lea dx, letter ;输出字母
mov ah,09h
int 21h
so: lea dx, num ;输出数字
mov ah,09h
int 21h
mov ax,4c00h
int 21h
code ends
end start
页:
[1]