编写程序,实现表的处理:内存单元中有一个ASCII码表,编写程序完成下面的功能:
① 首先输出表的内容;
② 插入一个数据,插入的数据和插入的位置从键盘输入;
③ 对表中的数据进行排序,按升顺或降顺排序可以进行选择;
④ 在表中查找某一个关键字,要查找的关键字从键盘输入;如果找到,输出查找的关键字并给出提示“find”,否则给出提示“no find”;
⑤ 程序执行以后,输出表中的插入以后的内容和排序以后的内容;
⑥ 程序有友好的运行界面;
⑦要求程序能够处理基本的错误信息;
...全文
1066打赏收藏
急求高手帮忙啊?
编写程序,实现表的处理:内存单元中有一个ASCII码表,编写程序完成下面的功能: ① 首先输出表的内容; ② 插入一个数据,插入的数据和插入的位置从键盘输入; ③ 对表中的数据进行排序,按升顺或降顺排序可以进行选择; ④ 在表中查找某一个关键字,要查找的关键字从键盘输入;如果找到,输出查找的关键字并给出提示“find”,否则给出提示“no find”; ⑤ 程序执行以后,输出表中的插入以后的内容和排序以后的内容; ⑥ 程序有友好的运行界面; ⑦要求程序能够处理基本的错误信息;
prints macro s ;定义宏输出字符串
mov ah,9
mov dx,offset s
int 21h
endm
input macro
mov ah,01h
int 21h
endm
output macro
mov ah,02h
int 21h
endm
data segment
line1 db ' -------------------------table---------------------------',0ah,0dh,0ah,0dh,'$' ;主页面
line2 db 0ah,0dh,'Please input where you want to insert the string!',0ah,0dh,'$'
line3 db 0ah,0dh,'Please input the string!',0ah,0dh,'$'
strs1 db 0ah,0dh,'Do you search want again?(Y or N)','$'
strs2 db 0ah,0dh,'Press Esc return to dos!','$'
strs3 db 0ah,0dh,'The key you press is wrong!Press again!',0ah,0dh,'$'
right db 'find',0ah,0dh,'$'
wrong db 'no find',0ah,0dh,'$'
table db ' !"#$%&',27h,'()*+,-./0123456789:;<=>?'
db '@ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db'[\]^_`abcdefghijklmnopqrstuvwxyz{|}~',00
x dw $-table
data ends
code segment
assume ds:data,cs:code
start:mov ax,data
mov ds,ax
mov es,ax
prints line1
mov cx,x
dec cx
lea di,table
lop: mov dl,[di]
inc di
output
loop lop
start1:prints line2
input
and ax,000fh
lea bx,table
mov si,x
lop1: dec si
mov dl,[bx+si-1]
mov [bx+si],dl
cmp si,ax
je inputs
jmp lop1
inputs: prints line3
input
mov [si-1],dl
call compositor
mov cx,x
lop2: lea di,table
mov dl,[di]
inc di
output
loop lop2
search:input
mov cx,x
lea di,table
repne scasb
cmp cx,00
jnz Find
cmp [di-1],al
jz find
prints wrong
jmp again
find: prints right
again: prints strs1
input
cmp al,59h
je search
cmp al,79h
je search
cmp al,4eh
je exit
cmp al,6eh
je exit
prints strs3
jmp again
exit: prints strs2
input
cmp al,1b
je exitdos
jmp start1
exitdos:mov ah,4ch
int 21h
compositor proc
mov cx,x
dec cx
outlop: mov dx,cx
mov bx,offset table
inlop: mov al,[bx]
cmp al,[bx+1]
jc next
xchg al,[bx+1]
mov [bx+1],al
next: inc bx
dec dx
jnz inlop
loop outlop
ret
compositor endp