


下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、南昌大学实验报告学生姓名:学号:专业班级:实验类型: 验证 综合 设计 口创新实验日期:实验成绩:实验3分支程序实验.实验目的1. 掌握单分支、双分支、多分支程序的设计方法;2. 掌握利用DEBUGS CODEVIEW修改参数、检查结果的方法;1. 熟悉汇编语言源程序的编辑、汇编、连接及调试过程。.实验内容1.猜数程序,预设一数字字符 M,从键盘输入一个数字字符N,判断:若N <M,显示“TOOBIG” ;若 N >M 则显示“ TOO SMALL ;否则显示“ YOUR ARE RIGHT data segme ntM db '6'N db ?mesgl db O
2、dh,Oah, ' too small$ 'mesg2 db 0dh,0ah, ' too big$ 'mesg3 db 0dh,0ah, ' you are right$ 'data endscode segme ntassume ds:data,cs:codesta比mov ax,datamov ds,axmov ah,01hint 21hmov N,alcmp al,1bh;如果输入是 esc键就退出jmp exitcmp al,Mjb small; 比M小就跳去smallja big; 比M大就跳去bigmov dx,offset mes
3、g3;显示正确mov ah,09hint 21hjmp startsmall:mov dx,offset mesgl;显示太小字符串mov ah,09hint 21hjmp startbig:mov dx,offset mesg2;显示太大字符串mov ah,09hint 21hjmp startexit:mov ah,4chint 21hcode endsend start输入3显示too small ,输入9显示too big2. 编写一个程序,判别键盘上输入的字符;若是1-9字符,则显示“IT IS A DIGITAL” ;若为A-Z或a-z字符,均显示“ IT IS A LOWCASE
4、ETTER ;若是回车字符 <CR>其 ASCII码为ODH),则结束程序,若为其它字符则不显示,继续等待新的字符输入。data segme ntNdb ?mesgl db 0dh,0ah,'it is a digital$'mesg2 db 0dh,0ah,'it is a lowcase letter$'data endscode segme ntassume ds:data,cs:codesta比mov ax,datamov ds,axmov ah,01hi nt 21hmov N,alcmp al,0dh;如果输入为回车则退出j e exit
5、cmp al,31hj b start; 比1小就重新再来cmp al,39hj a let;比9大就跟字母比较mov dx,offset mesgl; 输出是数字mov ah,09hi nt 21hj mp startlet:cmp al,'A'j b start; 比A小就重新再来cmp al,'Z'j b display; 比Z大就输出cmp al,'a'j b start; 比a小就重新再来cmp al,'z'j a start; 比z大就重新再来 display:mov dx,offset mesg2; 输出是字母mov
6、 ah,09hi nt 21hj mp startexit:mov ah,4chi nt 21hcode endsend startc:>debug QZ ,exe Pgp|lt is 趙 di乌itnl.-gdit is a loMcase let3. 预留字符串口令,输入口令串与预留密码串比较。若匹配则显示“MATCH,否则显示“ NOMATCH!,PROGRAM TERMINATED!data segme ntmesg1 db 0dh,0ah,'match$'mesg2 db 0dh,0ah,'nomatch!,program terminated!$
7、9;mesg3 db 'hello$'data endscode segme ntassume ds:data,cs:codesta比mov ax,datamov ds,axmov bx,0mov cl,0mov ch,0;cl 和ch都清零in put:mov ah,01hint 21h; 输入字符inc cl;计算输入字符数cmp al,Odhje guide;输入是回车就跳进判断语句cmp cl,1;cl 是1的时候,bx是0je compareinc bxcompare:cmp al,mesg3bxje in put;如果输入相等则继续比较inc ch;存放输入不同的字
8、符个数jmp in putguide:cmp cl,01h;什么也没输入就退出je exitcmp cl,6;输入字符数与预设不同则不符合jne nocmp ch,0;输入字符数不同的个数为0则符合jne nomov dx,offset mesg1mov ah,09hint 21hjmp startno:lea dx,mesg2mov ah,09hint 21hjmp startexit:mov ah,4chint 21hcode endsend starttie) Lorwit匚 harixri输入hello 显示 match,输入a Ma M显示no match4.上述程序1、2、3分别完
9、成后请编写一个程序来实现简单的程序菜单显示。(采用 地址跳跃表法实现)显示一个菜单要求用户从下表中选择:(1)GUESS NUMBER GAME(对应程序1)(2)CHAR SELECTION PROGRAM(对应程序2)(3)PASSWORD PROGRAM(对应程序3)(4)PRESS “ ESC TO QUIT用户作出选择13时,显示输出要执行操作的名字,如“"Your selection is 1,the program will execute GUESS NUMBER GAME! ”然后转向相应的程序去执行,执行 结束前进行退出的判断,显示一个提示信息"will
10、 you con ti nue program really ?(Y:N) ”要求用户从键盘键入字符,若是“Y”键,则继续程序的执行,若是“ N”键,则返回到菜单。若用户选择4,要求程序显示提示信息“Please press ESC key toexit! ” ,并能按要求正确退出。data segme ntadr dw adr1; 定义地址表dw adr2dw adr3dw adr4menu db 0dh,0ah,'me nu:'定义目录db 0dh,0ah,'(1)guess nu mber game'db 0dh,0ah,'(2)char sele
11、ct ion program'db 0dh,0ah,'(3)password program'db 0dh,0ah,'(4)press "esc" to quit$'ase1 db 0dh,0ah,'your select ion is 1,the program will execute guess nu mber game!$',0dh,0ahase2 db 0dh,0ah,'your select ion is 2,the program will execute char selecti ong pro
12、gram!$',0dh,0ahase3 db 0dh,0ah,'your select ion is 3,the program will execute passwordprogram!$',0dh,0ahstr1 db 0dh,0ah,'will you continue program really?(Y:N)$'str2 db 0dh,0ah,'please press esc key to exit!$'str3 db 0dh,0ah,'please in put number between 1 to 9$'g
13、uess1 db 0dh,0ah,'too big$'guess2 db 0dh,0ah,'too small$'guess3 db 0dh,0ah,'you are right$'M db '6'N db ?charl db 0dh,0ah,'it is a digital$'char2 db 0dh,0ah,'it is a lowcase letter$'codel db 0dh,0ah,'match$'code2 db 0dh,0ah,' no match!progr
14、am term in ated!$'code3 db 'hello$'data endscode segme ntassume ds:data,cs:codestart:mov ax,datamov ds,axmov si,0mov bx,0lea si,adr; 把地址表首地址给 si mov dx,offset menu; 显示主菜单 mov ah,09hint 21hmov dl,0dh;换行mov ah,2int 21hmov dl,0ah;回车mov ah,2int 21hmov ah,1;输入选项int 21hcmp al,0dh;输入是回车就退出je L1
15、mov ah,0;ah 置零sub al,31hshl ax,1add si,axjmp adrsi;地址跳跃表法adrl:lea dx,ase1mov ah,9int 21h ; 提示选中1语句lea dx,str3mov ah,9int 21hmov dl,0dhmov ah,2int 21hmov dl,0ahmov ah,2int 21h ; 回车换行mov ah,01hint 21hmov N,alcmp al,Mjb small ; 比M小就跳去smallja big; 比M大就跳去bigmov dx,offset guess3 ;显示正确mov ah,09hint 21he1:
16、lea dx,str1 ;判断是否回主菜单mov ah,9int 21hmov ah,1int 21hcmp al,'Y'je adrljmp startsmall:显示太小字符串显示太大字符串mov dx,offset guess2 ;mov ah,09hint 21hjmp e1big:mov dx,offset guess1 ;mov ah,09hint 21hjmp e1L1:jmp adr4 ; 跳跃jump接力adr2:lea dx,ase2;提示选中2语句mov ah,9int 21hmov dl,0dhmov ah,2int 21hmov dl,0ahmov a
17、h,2int 21h ;回车换行mov ah,01hint 21hmov N,alcmp al,31hjb adr2;比1小就重新再来cmp al,39hja let; 比9大就跟字母比较mov dx,offset charl;输出是数字mov ah,09hint 21he2: lea dx,str1 ;判断是否回主菜单mov ah,9int 21hmov ah,1int 21hcmp al,'Y'je adr2jmp startlet:cmp al,'A'jb adr2;比A小就重新再来cmp al,'Z'jb display; 比Z大就输出c
18、mp al,'a'jb adr2;比a小就重新再来cmp al,'z'ja adr2;比z大就重新再来display:mov dx,offset char2mov ah,09hint 21hjmp e2adr3:lea dx,ase3;提示选中3语句mov ah,9int 21hmov dl,0dhmov ah,2int 21hmov dl,0ahmov ah,2int 21h;回车换行mov bx,0mov cl,0mov ch,0;cl 和ch都清零in put:mov ah,01hint 21h;输入字符inc cl;计算输入字符数cmp al,0dhje
19、 guide;输入是回车就跳进判断语句cmp cl,1;cl 是1的时候,bx是0 je compareinc bxcompare:cmp al,code3bxje in put;如果输入相等则继续比较inc ch;存放输入不同的字符个数jmp in putguide:cmp cl,6;输入字符数与预设不同则不符合jne nocmp ch,0;输入字符数不同的个数为0则符合jne nomov dx,offset codelmov ah,09hint 21hlea dx,str1;判断是否回主菜单mov ah,9int 21hmov ah,1int 21hcmp al,'Y'je
20、 adr3jmp startno:lea dx,code2mov ah,09hint 21hlea dx,str1;判断是否回主菜单mov ah,9int 21hmov ah,1int 21hcmp al,'Y'je adr3jmp startadr4:lea dx,str2; 提示选中4语句mov ah,9int 21hmov ah,1int 21hcmp al,1bhjne adr4;判断输入是否是 ESC键mov ah,4chint 21h ;退出code endsend startC:>debug 04.exe_SImenu:CDguess number game
21、CZ)char selection programCSJpassword prog rami(4冲r巳轻占 'esc'1 to quit1your selectiem is Ijthe pragrais will exEcutE guess number game!please input number betueeni 1 to 9E>too bigmH I you continue program real ly?(¥:M)Nmenu:t1Jguess number gameC2)char selection prornt(3) pass:UDrd proQ
22、frami(4) press ''esc'1 to quitwill you comtiime prurram refilly?CY-M)IMnenu"(Dguess number gimc(2) ch$rIcct inin progmisi(3) pdshjurd prugrum (Jpress 'esc to quitZy(MW selection is the program wi 11 exec nite char select iong progran!0i t i. £ a lObicdse let tBi*ulll you co
23、ntiwe protfram really?CY-M)iiinenu"(1) guess murnber get me(2) ch$rIcct inin progmisi(3) p(iswurd prtKfrdin(4) pjfEss esc1" to quit3yotir selection is 3the program uil 1L execute password program!nomatchtprogi'ami termhiatedfwill you ccmtiTMJie: progLiuw r&aUyTnYiNJmi 11 you LdTit i nue progroim red JI ly f l¥ : IM Jrl rvenu:Cl)$fuies£ nuLMber gameCZ)char selection program(3) password program(4) press &quo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 财务制度合同管理范例
- 公司汽车租赁协议合同
- 有关个人和企业借款合同
- 小区门口门面租赁合同
- 进口销售合同
- 金融行业投资产品风险提示合同
- 湖南环境生物职业技术学院《ntroductontoMarketng》2023-2024学年第二学期期末试卷
- 运城师范高等专科学校《社会化阅读》2023-2024学年第二学期期末试卷
- 上海师范大学天华学院《展具设计》2023-2024学年第二学期期末试卷
- 中山职业技术学院《工程流体学》2023-2024学年第二学期期末试卷
- 《大学生创新创业基础教程》教学教案
- 2024专利代理人考试真题及答案
- JJF 2163-2024漆膜划格器校准规范
- 电子技术基础课件第6章数字电路基础
- 国有企业职业经理人绩效考核制度
- 新版FMEA控制程序-第五版FMEA
- 剪叉式升降平台结构设计
- 中智集团招聘笔试题库2024
- 三晋卓越联盟·山西省2024-2025学年度高三9月质量检测+语文试卷
- 《那一刻我长大了》习作课件
- 教科版小学科学六年级上册期末考试试卷(含答案)
评论
0/150
提交评论