中南民族大学80x86汇编实验报告_第1页
中南民族大学80x86汇编实验报告_第2页
中南民族大学80x86汇编实验报告_第3页
中南民族大学80x86汇编实验报告_第4页
中南民族大学80x86汇编实验报告_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、院 系:计算机科学学院 专 业:计算机科学与技术年 级: 2010 级 课程名称: 汇编语言 学 号: 10061103 姓 名: 张名扬 指导教师: 雷建云 2012年 6 月 17 日年级 2010级班号 计科四班学号 10061103专业计科姓名 张名扬实验名称 计算总评成绩实验类型设计型综合型创新型实验目的或要求实验一:实验要求:从键盘中输入一同学的期中成绩,实验成绩,期末成绩和他们在总评成绩中分别占的百分比,计算得到改同学的总评成绩,并显示出来. 实验原理(算法流程) ; example assembly language program - adds two numbers; au

2、thor: zhang; date: revised 7/97.386.model flatexitprocess proto near32 stdcall, dwexitcode:dwordinclude io.h ; header file for input/outputcr equ 0dh ; carriage return characterlf equ 0ah ; line feed.stack 4096 ; reserve 4096-byte stack.data ; reserve storage for datagrade1 dword ?grade2 dword ?grad

3、e3 dword ?sum1 dword ?prompt1 byte enter first grade: , 0prompt2 byte enter the percent of first grade: , 0prompt3 byte enter second grade: , 0prompt4 byte enter the percent of second grade: , 0prompt5 byte enter third grade: , 0prompt6 byte enter the percent of third grade: , 0string byte 40 dup (?

4、)label1 byte cr, lf, the sum is sum byte 11 dup (?) byte cr, lf, 0实验原理(算法流程).code ; start of main program code_start: output prompt1 ; prompt for first score input string, 40 ; read ascii characters atod string ; convert to integer mov grade1, eax ; store in memory output prompt2 ; prompt for first

5、percent input string, 40; read ascii characters atod string; mul grade1 ; grade1*eax mov sum1,eax ; move eax to sum1output prompt3 ; input string, 40 ; atod string ; mov grade2, eax ; output prompt4 ; input string, 40; atod string; mul grade2 ; grade2*eax add sum1,eax ; add eax to sum1output prompt5

6、 ; input string, 40 ; atod string ; mov grade3, eax ; output prompt6 ; input string, 40; atod string; mul grade3 ; grade3*eax add sum1,eax ; add eax to sum1mov eax,sum1; move sum1 to eaxmov sum1,100; move 100 to sum1divsum1 ; eax/100dtoasum,eax; outputlabel1; output sum invoke exitprocess, 0 ; exit

7、with return code 0public _start ; make entry point publicend ; end of source code实验结果分析及心得体会实验结果:成绩评定年级2010级班号 计科4班学号10061103专业计科姓名张名扬实验名称大小写字母字符互换实验类型设计型综合型创新型实验目的或要求实验二:实验要求:从键盘输入一个字符,如果该字符是回车符,直接退出程序,如果是小写字母,则转换为大写字母并显示;如果是大写字母,则转换为小写字母并显示;如果是非字母字符,则显示提示信息,并等待用户重新输入字符。实验原理(算法流程);-字母字符转换-datas seg

8、ment ;此处输入数据段代码 prompt1 db 0dh,0ah, please input a character : ,$prompt2 db 0dh,0ah,you input not a character ,please input a character , $prompt3 db 0dh,0ah, uppercase letter convert to lowercase letter: ,$prompt4 db 0dh,0ah,lowercase letter convert to uppercase letter: ,$datas endsstacks segment ;

9、此处输入堆栈段代码 stacks endscodes segment ;此处输入代码段代码 assume cs:codes,ds:datas,ss:stacksstart: mov ax,datas mov ds,ax_input: lea dx,prompt1mov ah,09hint 21hmov ah,01h int 21hmov bl,alcmp bl,0dhje _end_lowcase:cmp bl,a实验原理(算法流程) jl _uppercasecmp bl,zjg _uppercasesub bl,20hlea dx,prompt4mov ah,09hint 21hmov d

10、l,blmov ah,02hint 21hjmp _input_uppercase:cmp bl, ajl _warncmp bl,zjg _warnadd bl, 20hlea dx,prompt3mov ah,09hint 21hmov dl,blmov ah,02hint 21hjmp _input_warn: lea dx,prompt2mov ah,09hint 21h jmp _input _end: mov ah,4ch int 21hcodes ends end start实验结果分析及心得体会 成绩评定年级2010级班号 计科4班学号10061103专业计科姓名张名扬实验名称

11、显示九九乘法表实验类型设计型综合型创新型实验目的或要求实验三:实验要求:以九行九列的形式显示九九成法表 显示下三角格式也可以显示上三角格式实验原理(算法流程); example assembly language program - adds two numbers; author: zhang; date: revised 7/97.386.model flatexitprocess proto near32 stdcall, dwexitcode:dwordinclude io.h ; header file for input/outputcr equ 0dh ; carriage re

12、turn characterlf equ 0ah ; line feed.stack 4096 ; reserve 4096-byte stack.data ; (17)reserve storage for dataprompt byte -九九乘法表- , cr,lf,0row word 1 dup (?)col word 1 dup (?)jizhi word 1 dup (?)num byte 6 dup(?),0 ;num作为输出的nextrow byte cr,lf,0mullabel byte *, 0equlabel byte =, 0.code ; (26)start of

13、main program code_start: output prompt; mov row,1;outloop: mov ax,row ;(30)此处要用ax寄存器 mov col,1; 实验原理(算法流程)inloop: mul col;col*al mov jizhi,ax;(33)此处要用ax寄存器 mov ax,row; itoa num,ax; output num; output mullabel; mov ax,col ; 先把col的值放到ax寄存器中去 itoa num,ax; 再把ax中的值转换为ascii值并放到num中 output num; 这里输出col的字符形

14、式 output equlabel; mov ax,jizhi itoa num,jizhi; output num; inc col; mov ax,row;不能直接cmp col,row;因为二者都在存储器中 cmp col,ax; jle inloop; output nextrow ; inc row; cmp row,9; jle outloop; 原代码中这里和上在的跳转有错 input num,12; jmp endpro;endpro: invoke exitprocess, 0 ; exit with return code 0public _start ; make ent

15、ry point publicend ; end of source code实验原理(算法流程)实验结果:成绩评定年级2010级班号 计科4班学号10061103专业计科姓名张名扬实验名称求给定整数的所有素因子实验类型设计型综合型创新型实验目的或要求实验四:实验要求:输入一个整数,求出所有的素因子,并表现为乘积方式,求因子的算法用子程序来实现。 实验目的:掌握子程序的原理和方法,重点掌握子程序的编写和调用的过程以及堆栈操作和参数以及全局变量的概念。实验原理(算法流程); program to get all the prime numbers of a integer; author:zha

16、ng.model flatexitprocess proto near32 stdcall, dwexitcode:dwordinclude io.h ; header file for input/outputcr equ 0dh ; carriage return characterlf equ 0ah ; line feedmax equ 100 ; the max number.stack 4096 ; reserve 4096-byte stack.data ; reserve storage for datanumberdword?indexdword?jdword?flag1by

17、te?flag2byte?prompt0byteplease input an integer:,0prompt1bytecr,lf,cr,lf,the result is: ,0countword?valuebyte11 dup(?)byte0signbyte?byte0.code ; start of main program codeprocaprocnear32; 判断素数movflag1,0 ; 把0保存到flag1movindex,1 ;把1保存到index实验原理(算法流程)fora:incindex ;dec自加mov eax,index ;将index保存到eax中去cmpe

18、ax,ecx ;让eax与ecx比较jnlenda ;如果大于,跳转到enda moveax,ecxmovebx,indexcdq ;扩展被除数 divebxcmpedx,0jnefora ;如果不相等,跳转到forajmpendaa ;跳转到endaa enda:movflag1,1 endaa: retprocaendp ;子程序结束 procbprocnear32movflag2,0more:cmpnumber,1jeendbamoveax,numbercdqdivindexcmpedx,0jneendbbmovnumber,eaxinccountcmpcount,1jeprintnmo

19、vsign,*outputsignprintn:dtoavalue,indexcallproccjmpmoreendba:movflag2,1endbb:retprocbendp实验原理(算法流程)proccprocnear32leaebx,valuewhilea:moval,byte ptr ebxincebxcmpal,0jeendccmpal,20hjewhileamovsign,aloutputsignjmpwhileaendc:retproccendp_start:outputprompt0;主函数开始inputvalue,11outputprompt1movsign,=output

20、valueoutputsignatodvaluemovnumber,eaxmovcount,0movj,1nf1:incjmovecx,jcallprocacmpflag1,1jnenf1callprocbcmpflag2,1jnenf1 endfile: invoke exitprocess, 0 ; exit with return code 0public _start ; make entry point publicend (写不完时,可另加附页。)实验结果分析及心得体会成绩评定教师签名: 年 月 日年级 2010级班号 计科4班学号 10061103专业计科姓名 张名扬实验名称字符

21、串中指定字符的替换实验类型设计型综合型创新型实验目的或要求实验五:实验要求:输入一个字符实现替换功能将字符串中所有的a替换成a并输出新产生的字符串实验原理(算法流程)算法如下:; this program is to get the letter before and after the one you put in; author: xiang shiyuan.386.model flatexitprocess proto near32 stdcall, dwexitcode:dwordinclude io.h ; header file for input/outputcr equ 0dh

22、 ; carriage return characterlf equ 0ah ; line feed.stack 4096 ; reserve 4096-byte stack.data ; reserve storage for dataprompt1 byte this programe will exchange a to a byte please input string: ,0prompt2 byte the result is: string byte 50 dup(?).code ; start of main program code_start: output prompt1

23、 ;prompt1是a替换a并输出所在的串 input string,50 ; read ascii characters lea ebx,string ;find length of string)实验原理(算法流程)a: cmp byte ptr ebx,0dh ;串中每个字符与回车字符比较 je end1 ;等于则输出结果 cmp byte ptr ebx,41h ;串中每个字符与a字符的比较 je change ;相等则转换b: inc ebx ;继续比较下一个字符 jmp a change: mov byte ptr ebx,61h ;转换为a jmp b end1: output

24、prompt2 ;输出结果 invoke exitprocess, 0 ; exit with return code 0public _start ; make entry point public end ;end of source code 实验结果分析及心得体会实验结果:成绩评定年级2010级班号计科4班学号10061103专业计科姓名张名扬实验名称使用位操作指令实现双字类型数的高低字转换实验类型设计型综合型创新型实验目的或要求实验六:实验目的:掌握位指令的使用。实验要求:eax寄存器中的数,设法将其高字和低字实现互换实验原理(算法流程) ; author: zhang ; date: revised 10/2008.386.model flatexitprocess proto near32 stdcall, dwexitcode:dwordinclude io.hcr equ 0dh lf equ 0ah.stack 4096.dataprompt byte input

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论