收藏 分享(赏)

王爽汇编程序设计项目.doc

上传人:yjrm16270 文档编号:7137318 上传时间:2019-05-07 格式:DOC 页数:17 大小:105KB
下载 相关 举报
王爽汇编程序设计项目.doc_第1页
第1页 / 共17页
王爽汇编程序设计项目.doc_第2页
第2页 / 共17页
王爽汇编程序设计项目.doc_第3页
第3页 / 共17页
王爽汇编程序设计项目.doc_第4页
第4页 / 共17页
王爽汇编程序设计项目.doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

1、1王爽汇编程序设计项目(拿到题目,建议先自己动手去做,去思考) 程序设计项目一data segmentdw ?data endsend要求:只在定义的数据段?中加入相关的内容,使得上面的程序可以在屏幕中间显示一个绿色的字符A。汇编源程序设计如下:assume cs:datadata segmentdw 61hstart:mov ax,datamov ds,axmov bx,0mov ax,0b800hmov es,axmov cx,0mov cl,ds:bxmov ch,00000010b mov es:2000,cxmov ax,4c00hint 21hdata endsend start通

2、过此程序设计学习到了:一个有意义、完整的汇编源程序必须有至少有一个代码段。程序设计项目二对加密的字符串进行解密。要求:2(1)加密的字符串放在 Cryptography段。(2)解密方法:将 Cryptography段的每个字符的 ASCII值减去 1。 (3)用汇编语言实现程序,将 Cryptography段的数据按照解密方法进行解密,将解密后的数据放在 PlainText段,然后再把解密之后的字符串以白底蓝字方式显示到屏幕中间。(4)密文和明文的数据段定义如下:Cryptography segmentdb tqsfbe!zpvs!xjohtdb !cf!zpvs!nbtufs!Crypto

3、graphy endsPlainText segmentdb 2*17 dup ( )PlainText ends汇编源程序设计如下:assume ds:cryptography,cs:codecryptography segmentdb tqsfbe!zpvs!xjohtdb !cf!zpvs!nbtufs!cryptography endsplainText segmentdb 34 dup (0)plainText endscode segmentstart:mov ax,cryptographymov ds,axmov bx,0mov di,34mov ax,0b800hmov es,

4、axmov cx,0mov al,0mov cx,34s: mov al, ds:bxdec almov ds:di,alinc bxinc diloop smov di,343mov bx,46 /列mov si,1920 /行mov cx,34s1: mov ah,01110001bmov al,ds:diinc dimov es:si+bx,axinc siinc siloop s1mov ax,4c00hint 21hcode endsend start通过此程序设计学习到了:定位显示时,列不能取奇数程序设计项目三加、减、除三则运算。要求:(1)读取字符串的内容,判断第四个字符是+、-

5、或/,然后按照相应的符号进行运算,并把运算结果转换为字符串存放在等号后面,最后把算式显示到屏幕中间,白底蓝字。(2)注意数字字符的 ASCII与数字的对应关系,数字的数值加 30H为这个数字的字符所对应的 ASCII。(3)数据段定义如下:Calculate segmentdb 1. 3/1= db 2. 5+3= db 3. 9-3= db 4. 4+5= Calculate ends汇编源程序设计如下:assume ds:calculate,cs:codecalculate segmentdb 1. 3/1= db 2. 5+3= db 3. 9-3= db 4. 4+5= calcula

6、te endsstack segment4dw 64 dup (0)stack endscode segmentstart:mov ax,calculatemov ds,axmov di,3mov ax,stackmov ss,axmov sp,128mov ax,0b800hmov es,axmov si,0mov bx,1504mov cx,4s:push cxmov ah,0mov al,ds:di call jian0 inc di mov ch,0mov cl,ds:dipush cxmov dl,clcall chufapanduanmov cl,dljcxz chufak1:po

7、p cxpush cxmov dl,clcall jianfapanduanmov cl,dljcxz jianfak3:pop cxpush cxmov dl,clcall jiafapanduanmov cl,dljcxz jiafa5k2:pop cxpop cxadd di,12loop smov cx,0mov cx,4g2:push cxmov cx,16g1:mov ah,01110001bmov al,ds:siinc simov es:bx,axinc bxinc bxloop g1add bx,128pop cxloop g2mov ax,4c00hint 21hchufa

8、:push axinc dimov ch,0mov cl,ds:dimov al,clcall jian0mov cl,alpop axdiv clinc diinc diadd al,30hmov ds:di,aljmp short k1jiafa:push axinc dimov ch,0mov cl,ds:dimov al,clcall jian0mov cl,al6pop axadd al,cladd al,30hinc diinc dimov ds:di,al jmp short k2jianfa:push axinc dimov ch,0mov cl,ds:dimov al,clc

9、all jian0mov cl,alpop axs5:dec alloop s5add al,30hinc diinc dimov ds:di,aljmp short k3jian0: mov cx,30hs1:dec alloop s1retchufapanduan:mov cx,2fhs2:dec dlloop s2retjianfapanduan:mov cx,2dhs3:dec dlloop s3retjiafapanduan:mov cx,2bhs4:dec dlloop s4retcode endsend start7学会了:分别设计了三个子程序分别用于除法、减法、加法的判断通过哪

10、种判断就执行哪种计算方法从 data段的段地址 di=3开始扫描下一行是 3+16 、3+16+16 以此下去结果保存等式=后面最后显示在屏幕中间程序设计项目四编程计算 x(x2)的 y(y2)次方。使用 add指令实现。另,若学到第 10章,使用两种方式实现:(1)只使用 add指令实现;(2)只使用 mul指令实现;并将计算式显示在屏幕中央。例如:计算 4的 3次方。在屏幕中央显示格式如下:43-64注意:结果不能超过 16位寄存器可存储的最大值。汇编源程序设计如下:1、只使用 add指令实现assume cs:codecode segmentstart:mov ax,0b800hmov

11、es,axmov si,1504mov ax,2mov dx,3push dxpush axmov di,axdec dxmov cx,dxmov dx,axs1:push cxmov bx,axdec ax8mov cx,axinc axmov ax,dxmov bx,dxs2:add ax,bxloop s2pop cxmov dx,axmov ax,diloop s1mov ax,dxmov cx,axpop axpop dxadd ax,30hmov ah,00000001badd dx,30hmov dh,00000001bmov es:si,axadd si,160mov bh,0

12、0000001bmov bl,5ehmov word ptr es:si,bxadd si,160mov es:si,dxadd si,158mov bh,00000001bmov bl,2dhmov word ptr es:si,bxadd si,2mov word ptr es:si,bxadd si,2mov word ptr es:si,bxadd si,2mov word ptr es:si,bxadd si,156mov di,0mov ax,cxmov bx,109h:mov dx,0div bxpush dxinc dimov cx,axjcxz ok1jmp short ho

13、k1:mov cx,dih1: pop dxadd dx,30hmov dh,00000001bmov es:si,dxadd si,2loop h1mov ax,4c00hint 21hcode endsend start会做项目三的基础上完成此程序并不难程序设计项目五定义一个数据段如下:data segmentdb h12E332lL#O*&!88nIcE$% %$T1O m33E44E55t y77O88u!()db ?data ends注意:第一行字符串为待处理的数据,?为字符串结束符号。设计程序完成如下操作:(1)去掉除字母、空格、!之外的字符;(2) 通过内存间的数据交换,将数据段

14、中的字符串修改为 Hello!Nice to meet you!;(3)在屏幕正中打印处理好后的数据。完成程序后思考:(1)如何设计程序,程序代码量最少;(2)如何设计程序,程序执行速度最快;(3)如何设计程序,使得程序具有通用性。注意:(1)?、!和空格分别假定为字符串的结束符、一句话的最后的标点和单词间的间隔符,都不属于干扰符号。10(2)这里的通用性是指:任意带有其他符号干扰的一组字符串都能够通过程序被处理为具有如下特点的英文段落:段落中只包含字母、空格、!三种符号。段落中的每句话都是以开头字母为大写,!为结束标点的句子。汇编源程序设计如下:assume cs:codedata segm

15、entdb h12E3321L#o*&!88nIcE$T1o m33E44E55t y77o88u!()db ?data endsstack segmentdw 64 dup (0)stack endscode segmentstart:mov ax,datamov ds,axmov si,0mov ax,0b800hmov es,axmov di,1440mov ah,0mov bh,0 s:mov al,ds:siinc simov ah,0mov dl,alcall zifu jcxz xianshizifuzf:mov ah,0mov al,dlcall ganjcxz xianshi

16、gangg:mov ah,0mov al,dlcall konggejcxz xianshikongkk:mov ah,0mov al,dlcall wenhao11jcxz jjmp short sxianshizifu:mov al,dlmov ch,0add bh,1dec bhdec bhmov cl,bhjcxz daxieor al,00100000bhh1:mov ah,00000001b mov es:di,axadd di,2jmp short zfdaxie:mov ch,0mov cl,20hda:dec alloop damov bh,1jmp short hh1xia

17、nshigan:mov al,dlmov ah,00000001bmov es:di,axadd di,2mov bh,0jmp short ggxianshikong:mov al,dlmov ah,00000001bmov es:di,axadd di,2jmp short kkj:mov ax,4c00hint 21hzifu:or al,00100000bmov ch,012mov cl,60hz1:dec alloop z1mov cl,26 z2:mov bl,cldec almov cl,aljcxz z3mov cl,blloop z2jmp short z4z3:add bh

18、,1z4:mov cl,alretgan:mov ch,0mov cl,21hg1:dec alloop g1mov cl,alretkongge:mov ch,0mov cl,20hkong1:dec alloop kong1mov cl,alretwenhao:mov ch,0mov cl,3fhw1:dec alloop w1mov cl,alretcode ends end start 此程序也是建立在项目三的基础上的,分别建四个子程序判断字符、空格、感叹号、问号。难点是:如何使每一句子开头的字母大写,句子与感叹号!为结尾问号?结束13程序设计项目六在屏幕中间显示:“中华”两个字。参看

19、 demo0.png示例。提示:通过字模提取工具,可以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,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,0db 0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0

23、,0,0,0,0,0,0,0,0db 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,0db 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,0db 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,0db 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,0,0,0db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0

24、,0,0,0,0,0,0,0,0,0,0,0,0,0db 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,1db 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,0db 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,0db 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,0db 0,0,0,0,0,0,0,0,0,0,0,0

25、,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0db 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 segmentdw 64 dup (0)stack endscode segmentstart:mov ax,0b800hmov es,axmov dl,160mov al,16mul dlmov di,axadd di,20mov ax,stackmov ss,axmov sp,64mov ax,datamov ds,axmov si,0call qingp15mov

26、bh,16mov bl,25call zhongmov di,0mov dl,160mov al,16mul dlmov di,axadd di,80mov bh,16mov bl,30call huajmp short okzhong:mov ch,0mov cl,bhs2:push cxmov ch,0mov cl,bls1:push cxmov ch,0mov cl,ds:siinc sijcxz buxianshimov ax, 0403hmov es:di,axadd di,2fh:pop cxloop s116add di,110pop cxloop s2retbuxianshi:

27、mov ax,0000hmov es:di,axadd di,2jmp short fhhua:mov ch,0mov cl,bhs3:push cxmov ch,0mov cl,bls4:push cxmov ch,0mov cl,ds:siinc sijcxz buxianshi1mov ax, 0403hmov es:di,axadd di,2fh1:pop cxloop s4add di,100pop cxloop s3retbuxianshi1:mov ax,0000hmov es:di,axadd di,2jmp short fh1qingp:push cxpush dimov di,0mov cx,9000mov ax,0000h17k1: mov es:di,axadd di,2 loop k1pop dipop cxretok:mov ax,4c00hint 21hcode endsend start(完)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报