1、内存单元中有一个ASCII码表编写程序,实现表的处理:内存单元中有一个ASCII码表,编写程序完成下面的功能: 首先输出表的内容; 插入一个数据,插入的数据和插入的位置从键盘输入; 对表中的数据进行排序,按升顺或降顺排序可以进行选择; 在表中查找某一个关键字,要查找的关键字从键盘输入;如果找到,输出查找的关键字并给出提示“find”,否则给出提示“no find”; 程序执行以后,输出表中的插入以后的内容和排序以后的内容; 程序有友好的运行界面;要求程序能够处理基本的错误信息;data segmenttable db20 4b 26 37 7c,0ah,0dh,$str db which da
2、ta you want to insert and where it is?,0ah,0dh,$meg db Sorting the table,you want it on the basis of db ascending order or descending order?,0ah,0dh db 1 represent ascending order.,0ah,0dh db 2 represent descending order.,0ah,0dh,$meg1 db error ,make another choice.,0ah,0dh,$meg2 db Input the data y
3、ou want to be found.,0ah,0dh,$meg3 dbfind,0ah,0dh,$meg4 db no find,0ah,0dh,$inf db *ASCII TABLE(before change)*,0ah,0dh,$inf1 db *ASCII TABLE(ascending order)*,0ah,0dh,$inf2 db *ASCII TABLE(descending order)*,0ah,0dh,$num db 3 db ? db 3 dup(?)data endscode segment assume cs:code,ds:data,es:datastart
4、:mov ax,data mov ds,ax lea dx,table mov ah,9 int 21h lea dx,str mov ah,9 int 21h mov ah,1 int 21h push ax call non pop ax sub al,30h xor ah,ah mov cl,3 mul cl mov bx,ax mov ah,1 int 21h mov tablebx,al mov ah,1 int 21h mov tablebx+1,al call non lea dx,meg mov ah,9 int 21hinput:mov ah,1 int 21h push a
5、x call non pop ax cmp al,31h je x1 cmp al,32h je x2 lea dx,meg1 mov ah,9 int 21h jmp inputx1:mov cl,5 dec cloutlp:mov ch,cl mov si,offset table inlp: mov al,si and al,0fh mov dl,al push cx mov cl,4 shl dl,cl pop cx mov al,si+1 cmp al,61h jae b2 and al,0fh or dl,al jmp a1b2:sub al,57h add dl,al a1: m
6、ov al,si+3 and al,0fh mov bl,al push cx mov cl,4 shl bl,cl pop cx mov al,si+4 cmp al,61h jae a3 and al,0fh or bl,al jmp a2a3:sub al,57h add bl,ala2: cmp dl,bl jna next mov al,si xchg al,si+3 mov si,al mov al,si+1 xchg al,si+4 mov si+1,alnext: add si,3 dec ch jnz inlp loop outlp lea dx,table mov ah,9
7、 int 21h jmp selectx2:mov cl,5 dec cloutl:mov ch,cl mov si,offset table inl: mov al,si and al,0fh mov dl,al push cx mov cl,4 shl dl,cl pop cx mov al,si+1 cmp al,61h jae c4 and al,0fh or dl,al jmp c1c4:sub al,57h add dl,al c1: mov al,si+3 and al,0fh mov bl,al push cx mov cl,4 shl bl,cl pop cx mov al,
8、si+4 cmp al,61h jae c3 and al,0fh or bl,al jmp c3c3:sub al,57h add bl,alc2: cmp dl,bl jae nex mov al,si xchg al,si+3 mov si,al mov al,si+1 xchg al,si+4 mov si+1,alnex: add si,3 dec ch jnz inl loop outl lea dx,table mov ah,9 int 21hselect:lea dx,meg2 mov ah,9 int 21h mov ah,1 int 21h mov bl,al and al
9、,00fh mov dl,al mov cl,4 shl dl,cl mov ah,1 int 21h mov bh,al and al,00fh or al,dl mov cx,15 mov di,offset table mov al,bl repne scasb jnz non_find mov al,bh repne scasb jz findnon_find:call non lea dx,meg4 mov ah,9 int 21h jmp printfind:call non lea dx,meg3 mov ah,9 int 21hprint:lea dx,table mov ah
10、,9 int 21h mov ah,4ch int 21hnon proc mov dl,0ah mov ah,2 int 21h mov dl,0dh mov ah,2 int 21h retnon endpcode endsend startdata segmenttable db20 4b 26 37 7c,0ah,0dh,$data endscode segment assume cs:code,ds:datastart: mov ax,data mov ds,ax x1:mov cl,5 dec cloutlp:mov ch,cl mov si,offset table inlp:
11、mov al,si and al,0fh mov dl,al push cx mov cl,4 shl dl,cl pop cx mov al,si+1 cmp al,61h jae b2 and al,0fh or dl,al jmp a1b2:sub al,57h add dl,al a1: mov al,si+3 and al,0fh mov bl,al push cx mov cl,4 shl bl,cl pop cx mov al,si+4 cmp al,61h jae x2 and al,0fh or bl,al jmp a2x2:sub al,57h add bl,ala2: c
12、mp dl,bl jna next mov al,si xchg al,si+3 mov si,al mov al,si+1 xchg al,si+4 mov si+1,alnext: add si,3 dec ch jnz inlp loop outlp lea dx,table mov ah,9 int 21hmov ah,4chint 21hcode endsend startmov bx,ax mov si,ax add si,2 mov di,si dec si mov cx,5 rep movsb mov ah,1 int 21h mov tablebx,al mov ah,1 i
13、nt 21h mov tablebx+1,al output macro local print1 lea dx,inf mov ah,9 int 21h mov si,0 mov cx,48 mov bl,4print1: mov dl,tablesi mov ah,2 int 21h inc si loop print1 dec bl mov cx,48 mov dl,0ah mov ah,2 int 21h mov dl,0dh mov ah,2 int 21h jnz print1 lea dx,inf1 mov ah,9 int 21hendmdata segmenttable db
14、20 35 33 1a 1d 4b 26 08 02 0d 03 34 2c 2a 27 0d db3d 01 48 3b 4c 22 4a 40 36 50 56 39 3e 52 3a 44 db76 69 6a 6b 7d 60 63 70 7c 6c 5c 5a 65 60 59 5f db count =$-table-1str db where insert: $str1 db insert: $meg db ascending order or descending order?,0ah,0dh db 1 represent ascending order.,0ah,0dh db
15、 2 represent descending order.,0ah,0dh,$meg1 db error ,make another choice.,0ah,0dh,$meg2 db Input the data you want to be found: $meg3 dbfind,0ah,0dh,$meg4 db no find,0ah,0dh,$inf db *ASCII TABLE*,0ah,0dh,$inf1 db *,0ah,0dh,$data endscode segment assume cs:code,ds:data,es:datastart:mov ax,data mov
16、ds,ax mov es,ax output insert: lea dx,str mov ah,9 int 21h mov ah,1 int 21h and al,00fh mov dl,10;wojiade mul dl;wojiade mov dx,ax mov cl,4 shl dl,cl mov ah,1 int 21h and ax,00fh;al改成ax add dx,ax;原来是or al,dl dec dx;wojiade mov ax,dx;wojiade push ax call non pop ax xor ah,ah mov cl,3 mul cl mov bx,ax
17、; bx 存放插入位置的三倍 mov al,48 push ax; 入栈 连同ah和48 mul cl; ax 48*3 mov cx,ax; cx 483存入 std inc cx;我加的 sub cx,bx;wojiade mov si,ax add ax,3 mov di,ax sub ax,3 rep movsb lea dx,str1 mov ah,9 int 21h mov ah,1 int 21h mov tablebx,al mov ah,1 int 21h mov tablebx+1,al call non output lea dx,meg mov ah,9 int 21h
18、choose_order: mov ah,1 int 21h push ax call non pop ax cmp al,31h je x1 cmp al,32h je x2 lea dx,meg1 mov ah,9 int 21h jmp choose_orderx1: mov cl,49 dec cla0: mov ch,cl mov si,offset table a1: mov al,si and al,0fh mov dl,al push cx mov cl,4 shl dl,cl pop cx mov al,si+1 cmp al,61h jae a3 and al,0fh or
19、 dl,al jmp a4a3: sub al,57h add dl,al a4: mov al,si+3 and al,0fh mov bl,al push cx mov cl,4 shl bl,cl pop cx mov al,si+4 cmp al,61h jae a5 and al,0fh or bl,al jmp a6a5: sub al,57h add bl,ala6: cmp dl,bl jna next mov al,si xchg al,si+3 mov si,al mov al,si+1 xchg al,si+4 mov si+1,alnext: add si,3 dec
20、ch jnz a1 loop a0 jmp selectx2: mov cl,49 dec clb0: mov ch,cl mov si,offset table b1: mov al,si and al,0fh mov dl,al push cx mov cl,4 shl dl,cl pop cx mov al,si+1 cmp al,61h jae b2 and al,0fh or dl,al jmp b3b2: sub al,57h add dl,al b3: mov al,si+3 and al,0fh mov bl,al push cx mov cl,4 shl bl,cl pop
21、cx mov al,si+4 cmp al,61h jae b4 and al,0fh or bl,al jmp b5b4: sub al,57h add bl,alb5: cmp dl,bl jae next1 mov al,si xchg al,si+3 mov si,al mov al,si+1 xchg al,si+4 mov si+1,alnext1: add si,3 dec ch jnz b1 loop b0 select:lea dx,meg2 mov ah,9 int 21h mov ah,1 int 21h mov bl,al and al,00fh mov dl,al m
22、ov cl,4 shl dl,cl mov ah,1 int 21h mov bh,al and al,00fh or al,dl mov bl,al mov cx,48c1: mov al,si and al,0fh mov dl,al push cx mov cl,4 shl dl,cl pop cx mov al,si+1 cmp al,61h jae c2 and al,0fh or dl,al jmp c3c2: sub al,57h add dl,alc3: cmp bl,dl jnz non_find find: call non lea dx,meg3 mov ah,9 int 21h jmp printnon_find:add si,3 loop c1 call non lea dx,meg4 mov ah,9 int 21hprint: output mov ah,4ch int 21h non proc mov dl,0ah mov ah,2 int 21h mov dl,0dh mov ah,2 int 21h retnon endpcode endsend start
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1