《王爽汇编程序设计项目.doc》由会员分享,可在线阅读,更多相关《王爽汇编程序设计项目.doc(15页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流王爽汇编程序设计项目.精品文档. 王爽汇编程序设计项目(拿到题目,建议先自己动手去做,去思考) 程序设计项目一data segment dw ?data endsend要求:只在定义的数据段?中加入相关的内容,使得上面的程序可以在屏幕中间显示一个绿色的字符A。汇编源程序设计如下:assume cs:datadata segment dw 61h start:mov ax,data mov ds,ax mov bx,0 mov ax,0b800h mov es,ax mov cx,0 mov cl,ds:bx mov ch,00000010b
2、mov es:2000,cx mov ax,4c00h int 21hdata endsend start通过此程序设计学习到了:一个有意义、完整的汇编源程序必须有至少有一个代码段。程序设计项目二对加密的字符串进行解密。要求:(1)加密的字符串放在Cryptography段。(2)解密方法:将Cryptography段的每个字符的ASCII值减去1。 (3)用汇编语言实现程序,将Cryptography段的数据按照解密方法进行解密,将解密后的数据放在PlainText段,然后再把解密之后的字符串以白底蓝字方式显示到屏幕中间。(4)密文和明文的数据段定义如下:Cryptography segme
3、nt db tqsfbe!zpvs!xjoht db !cf!zpvs!nbtufs!Cryptography endsPlainText segment db 2*17 dup ( )PlainText ends汇编源程序设计如下:assume ds:cryptography,cs:codecryptography segment db tqsfbe!zpvs!xjoht db !cf!zpvs!nbtufs!cryptography endsplainText segment db 34 dup (0)plainText endscode segment start:mov ax,cryp
4、tography mov ds,ax mov bx,0 mov di,34 mov ax,0b800h mov es,ax mov cx,0 mov al,0 mov cx,34 s: mov al, ds:bx dec al mov ds:di,al inc bx inc di loop s mov di,34 mov bx,46 /列 mov si,1920 /行 mov cx,34 s1: mov ah,01110001b mov al,ds:di inc di mov es:si+bx,ax inc si inc si loop s1 mov ax,4c00h int 21hcode
5、endsend start 通过此程序设计学习到了:定位显示时,列不能取奇数程序设计项目三加、减、除三则运算。要求:(1)读取字符串的内容,判断第四个字符是+、-或/,然后按照相应的符号进行运算,并把运算结果转换为字符串存放在等号后面,最后把算式显示到屏幕中间,白底蓝字。(2)注意数字字符的ASCII与数字的对应关系,数字的数值加30H为这个数字的字符所对应的ASCII。(3)数据段定义如下:Calculate segment db 1. 3/1= db 2. 5+3= db 3. 9-3= db 4. 4+5= Calculate ends汇编源程序设计如下:assume ds:calcul
6、ate,cs:codecalculate segment db 1. 3/1= db 2. 5+3= db 3. 9-3= db 4. 4+5= calculate endsstack segment dw 64 dup (0)stack endscode segment start:mov ax,calculate mov ds,ax mov di,3 mov ax,stack mov ss,ax mov sp,128 mov ax,0b800h mov es,ax mov si,0 mov bx,1504 mov cx,4 s:push cx mov ah,0 mov al,ds:di c
7、all jian0 inc di mov ch,0 mov cl,ds:di push cx mov dl,cl call chufapanduan mov cl,dl jcxz chufa k1:pop cx push cx mov dl,cl call jianfapanduan mov cl,dl jcxz jianfa k3:pop cx push cx mov dl,cl call jiafapanduan mov cl,dl jcxz jiafa k2:pop cx pop cx add di,12 loop s mov cx,0 mov cx,4 g2:push cx mov c
8、x,16 g1:mov ah,01110001b mov al,ds:si inc si mov es:bx,ax inc bx inc bx loop g1 add bx,128 pop cx loop g2 mov ax,4c00h int 21h chufa:push ax inc di mov ch,0 mov cl,ds:di mov al,cl call jian0 mov cl,al pop ax div cl inc di inc di add al,30h mov ds:di,al jmp short k1 jiafa:push ax inc di mov ch,0 mov
9、cl,ds:di mov al,cl call jian0 mov cl,al pop ax add al,cl add al,30h inc di inc di mov ds:di,al jmp short k2 jianfa:push ax inc di mov ch,0 mov cl,ds:di mov al,cl call jian0 mov cl,al pop ax s5:dec al loop s5 add al,30h inc di inc di mov ds:di,al jmp short k3 jian0: mov cx,30h s1:dec al loop s1 retch
10、ufapanduan:mov cx,2fh s2:dec dl loop s2 retjianfapanduan:mov cx,2dh s3:dec dl loop s3 retjiafapanduan:mov cx,2bh s4:dec dl loop s4 retcode endsend start学会了:分别设计了三个子程序分别用于除法、减法、加法的判断通过哪种判断就执行哪种计算方法从data段的段地址di=3开始扫描下一行是3+16 、3+16+16以此下去结果保存等式=后面最后显示在屏幕中间 程序设计项目四编程计算x(x2)的y(y2)次方。使用add指令实现。另,若学到第10章,使
11、用两种方式实现:(1)只使用add指令实现;(2)只使用mul指令实现;并将计算式显示在屏幕中央。例如:计算4的3次方。在屏幕中央显示格式如下:4364注意:结果不能超过16位寄存器可存储的最大值。汇编源程序设计如下:1、只使用add指令实现assume cs:codecode segment start:mov ax,0b800h mov es,ax mov si,1504 mov ax,2 mov dx,3 push dx push ax mov di,ax dec dx mov cx,dx mov dx,ax s1:push cx mov bx,ax dec ax mov cx,ax i
12、nc ax mov ax,dx mov bx,dx s2:add ax,bx loop s2 pop cx mov dx,ax mov ax,di loop s1 mov ax,dx mov cx,ax pop ax pop dx add ax,30h mov ah,00000001b add dx,30h mov dh,00000001b mov es:si,ax add si,160 mov bh,00000001b mov bl,5eh mov word ptr es:si,bx add si,160 mov es:si,dx add si,158 mov bh,00000001b mo
13、v bl,2dh mov word ptr es:si,bx add si,2 mov word ptr es:si,bx add si,2 mov word ptr es:si,bx add si,2 mov word ptr es:si,bx add si,156 mov di,0 mov ax,cx mov bx,10 h:mov dx,0 div bx push dx inc di mov cx,ax jcxz ok1 jmp short h ok1:mov cx,di h1: pop dx add dx,30h mov dh,00000001b mov es:si,dx add si
14、,2 loop h1 mov ax,4c00h int 21hcode endsend start会做项目三的基础上完成此程序并不难程序设计项目五定义一个数据段如下:data segmentdb h12E332lL#O*&!88nIcE$% %$T1O m33E44E55t y77O88u!()db ?data ends注意:第一行字符串为待处理的数据,?为字符串结束符号。设计程序完成如下操作:(1)去掉除字母、空格、!之外的字符;(2) 通过内存间的数据交换,将数据段中的字符串修改为Hello!Nice to meet you!;(3)在屏幕正中打印处理好后的数据。完成程序后思考:(1)如何
15、设计程序,程序代码量最少;(2)如何设计程序,程序执行速度最快;(3)如何设计程序,使得程序具有通用性。注意:(1)?、!和空格分别假定为字符串的结束符、一句话的最后的标点和单词间的间隔符,都不属于干扰符号。(2)这里的通用性是指:任意带有其他符号干扰的一组字符串都能够通过程序被处理为具有如下特点的英文段落:段落中只包含字母、空格、!三种符号。段落中的每句话都是以开头字母为大写,!为结束标点的句子。汇编源程序设计如下: assume cs:codedata segment db h12E3321L#o*&!88nIcE$T1o m33E44E55t y77o88u!() db ?data en
16、dsstack segment dw 64 dup (0)stack endscode segment start:mov ax,data mov ds,ax mov si,0 mov ax,0b800h mov es,ax mov di,1440 mov ah,0 mov bh,0 s:mov al,ds:si inc si mov ah,0 mov dl,al call zifu jcxz xianshizifu zf:mov ah,0 mov al,dl call gan jcxz xianshigan gg:mov ah,0 mov al,dl call kongge jcxz xia
17、nshikong kk:mov ah,0 mov al,dl call wenhao jcxz j jmp short sxianshizifu: mov al,dl mov ch,0 add bh,1 dec bh dec bh mov cl,bh jcxz daxie or al,00100000b hh1:mov ah,00000001b mov es:di,ax add di,2 jmp short zf daxie:mov ch,0 mov cl,20h da:dec al loop da mov bh,1 jmp short hh1xianshigan:mov al,dl mov
18、ah,00000001b mov es:di,ax add di,2 mov bh,0 jmp short ggxianshikong:mov al,dl mov ah,00000001b mov es:di,ax add di,2 jmp short kk j:mov ax,4c00h int 21h zifu: or al,00100000b mov ch,0 mov cl,60h z1:dec al loop z1 mov cl,26 z2:mov bl,cl dec al mov cl,al jcxz z3 mov cl,bl loop z2 jmp short z4 z3:add b
19、h,1 z4:mov cl,al ret gan:mov ch,0 mov cl,21h g1:dec al loop g1 mov cl,al ret kongge:mov ch,0 mov cl,20h kong1:dec al loop kong1 mov cl,al ret wenhao:mov ch,0 mov cl,3fh w1:dec al loop w1 mov cl,al retcode ends end start 此程序也是建立在项目三的基础上的,分别建四个子程序判断字符、空格、感叹号、问号。难点是:如何使每一句子开头的字母大写,句子与感叹号!为结尾 问号?结束程序设计项
20、目六在屏幕中间显示:“中华”两个字。参看demo0.png示例。提示:通过字模提取工具,可以提取字的显示信息。 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1,1,1,1,0,0,0,0,0 db 0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0 db 0,0,0,
24、0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,1,1,0,0,1,1,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0 db 0,0,1,1,0,0,0,1,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0 db 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0 db 0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,
25、0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0
26、,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0data endsstack segment dw 64 dup (0)stack endscode segment start:mov ax,0b800h mov es,ax mov dl,160 mov al,16 mul dl mov di,ax add di,20 mov ax,stack mov
27、ss,ax mov sp,64 mov ax,data mov ds,ax mov si,0 call qingp mov bh,16 mov bl,25 call zhong mov di,0 mov dl,160 mov al,16 mul dl mov di,ax add di,80 mov bh,16 mov bl,30 call hua jmp short ok zhong: mov ch,0 mov cl,bh s2:push cx mov ch,0 mov cl,bl s1:push cx mov ch,0 mov cl,ds:si inc si jcxz buxianshi m
28、ov ax, 0403h mov es:di,ax add di,2 fh:pop cx loop s1 add di,110 pop cx loop s2 ret buxianshi:mov ax,0000h mov es:di,ax add di,2 jmp short fh hua: mov ch,0 mov cl,bh s3:push cx mov ch,0 mov cl,bl s4:push cx mov ch,0 mov cl,ds:si inc si jcxz buxianshi1 mov ax, 0403h mov es:di,ax add di,2 fh1:pop cx loop s4 add di,100 pop cx loop s3 ret buxianshi1:mov ax,0000h mov es:di,ax add di,2 jmp short fh1 qingp:push cx push di mov di,0 mov cx,9000 mov ax,0000h k1: mov es:di,ax add di,2 loop k1 pop di pop cx ret ok:mov ax,4c00h int 21hcode endsend start(完)