云南大学 软件学院 汇编实验8

合集下载

云南大学软件学院计算机网络原理实验八

云南大学软件学院计算机网络原理实验八

实验八、链路层实验——基于CRC编码的检错程序的实现一、实验目的1、通过实验,掌握CRC编码和解码的原理。

2、掌握基于CRC编码的差错检测技术。

二、实验指导现在计算机网络广泛采用的差错检测技术是基于CRC(cyclic redundancy check)循环冗余检测编码,CRC也称为多项式编码(polynomial code),CRC算法非常容易用硬件实现。

CRC编码操作如下:对给定的数据D,发送者选择r个附加位,追加到D的末尾,形成d+r位的新位型,该位型正好能被G模2除尽。

其中,G称为生成器。

CRC编码算法实现:1、选择生成多项式G,其最高次方为r,即r+1位的二进制位串2、计算D·2r, 即在数据D后面补r个0,构成d+r位的位串3、按模2除法求(D·2r/G)的余数R4、从D·2r中模2加上R,得到新的数据T,即加了CRC的帧三、实验要求1、设置一个d位的数据D,r+1位的多项式G,生成CRC码,并把此CRC码作为数据帧进行传送。

2、编写两个子程序,分别实现CRC编码和CRC解码,在主函数中对子程序进行调用。

解码子程序应能根据解码情况判断出接收到的数据帧是否出错,并给出提示。

3、要求分别以正确和错误的数据来检验此检错程序。

4、将编写程序的源代码加必要注释和程序运行结果一起填入实验报告中。

提示:1、编写程序时数据直接用二进制数,可能用到位操作符^(异或)和<<(左移)。

2、在设置错误的编码时,错误位数最好不要超过r+1位。

四、程序代码#include <stdlib.h>void crc_code(int A[],int G[],int x,int n)//编码子程序,异或函数,求余数{int i,j,k;printf("\n\t\t");for(k=0;k<x;k++)printf("%d",A[k]);//输出补零以后的数for(i=0;i<=x-n+1;i++){if(A[i]==1)//当首位为1时进行异或{for(j=0;j<=n-1;j++){if(A[i+j]==G[j])A[i+j]=0;//异或运算,相同为0,不同为1elseA[i+j]=1;}printf("\n\t\t");//输出每次异或运算后的结果for(k=0;k<=x-1;k++)printf("%d",A[k]);//输出余数}}}void crc_decode(int M[],int A[],int m,int n)//检验解码子程序{int i,sign=0;//初始化,定义一个标志位signfor(i=0;i<=m-1;i++){if(M[i]!=A[i])//若输入的M[i]中的任意一位不等于对应的A[i] {printf("第%d位出现错误\n",i+1);//输出错误信息sign=1;//若不等,则置标志位为1}}if(sign!=1)printf("数据正确\n");//输出正确信息}int main(){int m,n;int A[20],M[20],G[20],i,j;printf("请输入M[x]的长度m= ");scanf("%d",&m);printf("请输入G[x]的长度n= ");scanf("%d",&n);printf("\n请输入M[x]= \n");for(i=0;i<=m-1;i++)scanf("%d",&M[i]);printf("\n请输入G[x]= \n");for(j=0;j<=n-1;j++)scanf("%d",&G[j]);for(i=0;i<=m-1;i++)A[i]=M[i];for(i=m;i<=m+n-2;i++)A[i]=0;//被除数左移r位,r=m+n-2,即补r个0 crc_code(A,G,m+n-1,n);//调用异或运算函数for(i=0;i<=m-1;i++)A[i]=A[i]+M[i];//在被除数后面加上余数printf("\n\n结果为: ");for(i=0;i<=m+n-2;i++)printf("%d",A[i]);printf("\n");printf("\n请输入要进行CRC解码的数据:\n");for(i=0;i<=m-1;i++)scanf("%d",&M[i]);crc_decode(M,A,m,n);//调用校验解码函数return 0;}五、运行结果六、实验小结①通过这个实验,对CRC编码解码的算法有了初步了解.并且学会了CRC编码解码的算法。

云南大学--软件学院--数据库实验4

云南大学--软件学院--数据库实验4

云南大学软件学院实验报告课程:数据库原理与实用技术实验学期: 2012-2013学年第二学期任课教师:专业:学号:姓名:成绩:实验4 数据查询一、实验目的理解T-SQL语言的使用;熟练掌握数据查询语句;掌握合计函数的使用。

二、实验内容1、CAP数据库的查询(记录每个查询的SQL语句和查询结果)(1)建立CAP数据库,输入C、A、P、O四张表;图表 1 创建cap数据库图表 2创建四个表图表 3向表中插入数据图表 4表的内容(2)完成课后习题[3.2]b、[3.5]、[3.8]a,b、[3.11]b,f,j,l[3.2] (b)Retrieve aid values of agents who receive the maximum percent commission.图表 5最高佣金百分率[3.5] Consider the problem to find all (cid, aid) pairs where the customer does not place an order through the agent. This can be accomplished with the Select statementselect cid, aidfrom customers c. agents awhere not exists(select * from orders x where x.cid = c.cid and x.aid =a.aid) ;Is it possible to achieve this result using the NOT IN predicate in place of the NOT EXISTS predicate with a single Subquery? With more than one Subquery? Explain your answer and demonstrate any equivalent form by execution.图表 6 3.5 not in[3.8](a) Write a Select statement with no WHERE clause to retrieve all customer cids and the maximum money each spends on any product. Label the columns of the resulting table: eid, MAXSPENT.图表 7 3.8(b) Write a query to retrieve the AVERAGE value (over all customers) of the MAXSPENT of query (a)图表 8 3.8(b)[3.11] (b) We say that a customer x orders a product y in an average quantity A if A is avg(qty) for all orders rows with cid = x and pid = y. Is it possible in a single SQL statement to retrieve cid values of customers who order all the products that they receive in average quantities (by product) of at least 300?图表 9 3.11 (b)(f) Get pid values of products that are ordered by all customers in Dallas.图表 10 3.11 (f)(j) Use a single Update statement to raise the prices of all products warehoused in Duluth or Dallas by 10%. Then restore the original values byrerunning the procedure that you originally used to create and load the products table.图表 11 3.11 (j)(l) Write an SQL query to get aid and percent values of agents who take orders from all customers who live in Duluth. The aid values should be reported in order by decreasing percent. (Note that if percent is not retrieved in the select list, we cannot order by these values.)图表 12 3.11 (i)2、Employee数据库的查询(记录每个查询的SQL语句和查询结果)(1)向表中插入数据。

汇编实验8——精选推荐

汇编实验8——精选推荐

汇编实验8暨南⼤学本科实验报告专⽤纸课程名称汇编语⾔程序设计成绩评定实验项⽬名称分⽀程序设计指导教师实验项⽬编号实验项⽬类型实验地点学⽣姓学号2014053433学院信息科学技术学院系计算机系专业计算机科学技术专业实验时间2016年 4 ⽉30 ⽇下午15:00~16:50⼀、实验⽬的和要求1) 从键盘上接收两个⼀位⼗六进制数X和Y,然后再输⼊⼀个A-D之间的⼀个字符,按下列要求计算。

a)当输⼊字符为A,则计算X+Y,并以⼗六进制形式显⽰出来b)当输⼊字符为B,则计算|X-Y|,并以⼗六进制形式显⽰出来c)当输⼊字符为C,则计算X*Y,并以⼗六进制形式显⽰出来d)当输⼊字符为D,则计算X/Y,并以⼗六进制形式显⽰出来2)编程实现:设从STRING开始存放有⼀个以#为结束标志的字符串,把字符串中的字符进⾏分类,数字字符送⼊NUM开始的内存区中,⼤写字母送⼊从BCHAR开始的内存区中,⼩写字母存⼊从LCHAR开始的内存区中,其他字符存⼊从OTHER开始的内存区中。

3)编制⼀程序,从键盘输⼊两个长度不同的字符串,设字符串长度⼩于25个字符。

要求在屏幕上以右边对齐的形式显⽰出来。

编程要点:(i)在数据段中设置两个存放提⽰信息的字符串,⼀个是提⽰⽤户输⼊,另⼀个是指⽰显⽰信息位置;(ii)在数据段中设置两个存放输⼊字符串的缓冲区;(iii)输⼊字符串采⽤0AH号DOS功能调⽤,字符串存⼊缓冲区时,第2个字节为实际输⼊字符串的长度,从第3个字节开始为字符串的ASCII码。

(iv)为了实现显⽰的右对齐,由于两个字符串缓冲区的长度相同,只需要将两个字符串向缓冲区后⾯靠齐,再调⽤09H号DOS功能调⽤即可达到显⽰的右对齐。

⼆、程序流程图(每题分开写)1.、三、源程序(每题分开写)1. DSEG SEGMENT 'DATA'; add your data here!DSEG ENDSSSEG SEGMENT STACK 'STACK' db 256 DUP(0) SSEG ENDSCSEG SEGMENT 'CODE'START PROC FAR; set segment registers:MOV AX, DSEGMOV DS, AXMOV ES, AX; add your code heremov ah,01hint 21hmov cl,alint 21hmov dl,alint 21hmov bx,0cmp cl,65jb one1sub cl,55jmp outCone1:sub cl,48outC:cmp dl,65jb one2sub dl,55jmp outDone2:sub dl,48outD:cmp al,65je start1cmp al,67je start3mov al,clcbwdiv dlcmp al,10jnb add1add al,48jmp outd1add1:add al,55 outd1: cmp ah,10jnb add2add ah,48jmp outd2add2:add ah,55 outd2: mov bx,axmov ah,02h mov dl,10int 21hmov dl,blint 21hmov dl,46int 21hint 21hint 21hint 21hint 21hint 21hmov dl,bhint 21hjmp END start1:cbwmov bl,16div blmov bl,ahmov bh,alcmp bl,10jnb add3add bl,48jmp outd3add3:add bl,55outd3:cmp bh,10jnb add4add bh,48jmp outd4add4:add bh,55 outd4: mov ah,02h mov dl,10int 21hmov dl,bhint 21hmov dl,blint 21hjmp END start2: mov bl,dlcmp bl,cljnb sub1mov al,blmov bl,clmov cl,alsub1:add bl,48jmp outd5add5:add bl,55 outd5: mov ah,02h mov dl,10int 21hmov dl,blint 21hjmp ENDstart3:mov al,dlmul clmov bl,16div blmov bl,ahmov bh,alcmp bl,10jnb add6add bl,48jmp outd6add6:add bl,55outd6:cmp bh,10jnb add7add bh,48jmp outd7add7:add bh,55 outd7:mov ah,02hint 21hmov dl,blint 21hEND:MOV AX, 4C00h ; exit to operating system.INT 21hSTART ENDPCSEG ENDSEND START ; set entry point.2. DSEG SEGMENT 'DATA'; add your data here!; string1 db 'in put two string:'inputbuf1 db 25db 0stringbuf1 db 25 dup(' ')inputbuf2 db 25db 0stringbuf2 db 25 dup(' ')stringA db 25 dup(0),'$'stringB db 25 dup(0),'$'DSEG ENDSSSEG SEGMENT STACK 'STACK' db 256 DUP(0) SSEG ENDSCSEG SEGMENT 'CODE'START PROC FAR; set segment registers:MOV AX, DSEGMOV DS, AXMOV ES, AX; add your code heremov ah,0ahlea dx,inputbuf1int 21hmov dl,10int 21hmov ah,0ahlea dx,inputbuf2int 21hmov ah,02hmov dl,13int 21hmov dl,10int 21hmov bx,25mov cl,inputbuf1+1 mov ch,0sub bx,cxmov si,bxmov bx,0smov:cmp cx,bxjna printf1mov al,stringbuf1+bx mov stringA+bx+si,al add bx,1jmp smovprintf1:mov bx,25mov cl,inputbuf2+1 mov ch,0sub bx,cxmov si,bxmov bx,0smov1:mov al,stringbuf2+bxmov stringB+bx+si,aladd bx,1jmp smov1:printf2:lea dx,stringAmov ah,09hint 21hmov ah,02hmov dl,13int 21hmov dl,10int 21hlea dx,stringBmov ah,09hint 21hMOV AX, 4C00h ; exit to operating system.INT 21hSTART ENDPCSEG ENDSEND START ; set entry point.3.DSEG SEGMENT 'DATA'; add your data here!STRING db 'ABCDabcd12?#' NUM db 10 dup(0) nums dw 0BCHAR db 10 dup(0)bcs dw 0LCHAR db 10 dup(0)lcs dw 0OTHER db 10 dup(0)ots dw 0DSEG ENDSSSEG SEGMENT STACK 'STACK' db 256 DUP(0)CSEG SEGMENT 'CODE'START PROC FAR; set segment registers: MOV AX, DSEG MOV DS, AXMOV ES, AX; add your code heremov cx,0one:mov bx,cxmov al,STRING+bxcmp al,35je ENDcmp al,48jb twocmp al,58jb threecmp al,65jb twocmp al,91jb bccmp al,97jb twocmp al,123jb lctwo:mov bx,otsmov OTHER+bx,alinc bxinc cxmov ots,bxjmp onethree:mov bx,numsmov NUM+bx,alinc bxinc cxmov nums,bxjmp onebc:mov bx,bcsmov BCHAR+bx,alinc bxinc cxmov bcs,bxjmp onelc:mov bx,lcsmov LCHAR+bx,alinc bxinc cxmov lcs,bxjmp oneEND:MOV AX, 4C00h ; exit to operating system. INT 21h START ENDPCSEG ENDSEND START ; set entry point.四、结果分析(对输⼊\输出部分截屏)五、实验总结。

云南大学软件学院报告

云南大学软件学院报告

课程:数据结构实验学期:2014-2015学年第一学期任课教师:专业:信息安全学号:姓名:成绩:实验5 图基础实验一、实验目的1.掌握图的存储结构及其遍历。

二、实验软硬件环境(CPU、OS、IDE):三、实验任务(要求写出核心代码,并对运行结果截图)1)使用邻接矩阵和邻接表储表示分别实现如下给定的图1、图2、图3所示图的物理存储结构。

2)在1)所建立的图形存储结构上分别实现深度优先搜索遍历和广度优先搜索遍历,并给出遍历结果(序列)。

图3 有向图实验代码:#include<stdio.h>#include<stdlib.h>#define MAXVEX 20#define OK 1#define ERROR 0#define OVERFLOW -1#define INFINITY 65535#define QueueSize 20 //队列中最大元素个数typedef int QElemType; //队列的元素的类型typedef int VertexType;typedef int EdgeType;typedef enum{False,True}Boolean; //Boolean是布尔类型,其值是ture或false Boolean visited[MAXVEX]; //访问标志的数组。

typedef struct{VertexType vexs[MAXVEX];EdgeType arc[MAXVEX][MAXVEX];int numVertexes,numEdges;} MGraph; //邻接矩阵。

typedef struct EdgeNode //边表结点。

{int adjvex;struct EdgeNode *next;}EdgeNode;typedef struct VertexNode //顶点表结点。

{int data;EdgeNode *firstedge;}VertexNode,AdjList[MAXVEX];typedef struct{AdjList adjlist;int numVertexes,numEdges; //图中当前顶点数边数。

王爽《汇编语言》实验8

王爽《汇编语言》实验8

王爽《汇编语⾔》实验8
实验8是要求阅读⼀个很奇葩的代码:
assume cs:code
code segment
mov ax, 4c00h
int 21h
start: mov ax, 0
s: nop
nop
;下⾯这段代码主要是把s2的内容复制到s处
mov di, offset s
mov si, offset s2
mov ax, cs:[si]
mov cs:[di], ax
s0: jmp short s
s1: mov ax, 0
int 21h
mov ax, 0
s2: jmp short s1
nop
code ends
end start
先看看开始时代码在内存的存在:
对⽐前⾯的代码,可以看出,程序从start处开始运⾏,然后⼀直运⾏到mov cs:[di], ax处,
此时再查看内存:
发现标签s处的代码已经被更改成为jmp 0000,但是s2处的明明是jmp short s1啊,为什么把代码复制到s处就不同了?
再仔细观察,发现这个指令的机器码EBF6并没有改变,⽽因为jmp short是段内转移,机器码记录的是位移,F6对应的是-8的位移,⽽由于s 刚好处于cs:0008处,运⾏jmp后刚好后移8位,到达最开始的mov ax, 4c00h处,到此运⾏结束。

这⾥对于这个-8的位移控制得⾮常精妙,从s2转移到s1需要-8的位移,⽽从s转移到段头处也刚好是-8的位移,所以程序运⾏成功。

从这⾥可以看出,⼀个精妙的汇编代码⽐⾼级语⾔更有意思^_^。

实验报告模板—汇编语言

实验报告模板—汇编语言

指导教师 (签名):一.实验原理(基本知识简单介绍、算法、流程)二.实验结果(截图,提供实验测试/调试的结果等,在空白地方手写注释)Student strucm_sName db 6 dup(' ')m_sNum db 8 dup(' ')m_sScore db 3 dup(' ')Student endsstsg segment stack 's'dw 32 dup(?)stsg endsanykey macromov ah,7int 21hendmanykeyback macroanykeyshowmsg backendmcrlfm macropush axpush dxmov ah,9lea dx,crlfint 21hpop dxpop axendmexchange macro i,jpush cxpush sipush dimov cx,17;t=[i],即t=前项mov si,ilea di,stutemprep movsbmov cx,17;i=j,si->后项,即前项=后项mov di,i ;rep movsbmov cx,17;j=t,di->后项,即后项=tlea si,stutemprep movsbmov swapped,1pop dipop sipop cxendmspace macropush dxpush axlea dx,gapmov ah,9int 21hpop axpop dxendmshowmsg macro npush axpush dxmov ah,9lea dx,msg&nint 21hpop dxpop axendmmovitem macro dst,srcpush cxpush dipush sicldmov cx,17lea di,[dst]lea si,[src]rep movsbpop sipop dipop cxendmdata segmentstudentx student 30 dup(<>)stutemp db 17 dup (0),'$'studisp db 19 dup(0),'$'namepar LABEL BYTEmaxnlen db 7namelen db ?namefld db 7 dup(?)numpar label bytemaxmlen db 9numlen db ?numfld db 9 dup(?)scopar label bytemaxsco db 4scolen db ?scofld db 4 dup(?);输入文件路径缓冲区pathpar label bytepathmax db 40pathlen db ?pathnam db 40 dup(?)ae90 db 0ae80 db 0ae70 db 0ae60 db 0b60 db 0msg_b60 db 9,9,'Scores<60:$'msg_ae60 db 9,9,'Scores>=60:$'msg_ae70 db 9,9,'Scores>=70:$'msg_ae80 db 9,9,'Scores>=80:$'msg_ae90 db 9,9,'Scores>=90:$'cur_i dw ?crlf db 13,10,'$'titl db ' Students Management System',0DH,0AH,' ',0DH,0AH,0DH,0AHmenu1 db ' I(Insert the data of the students)',0dh,0ah ;menumenu2 db ' L(Browse the data of the students)',0dh, 0ahmenu3 db ' Q(Query the data of the students)',0dh, 0ahmenu4 db ' D(Delete the data of the students)',0dh, 0ahmenu5 db ' M(Modify the data of the students)',0dh,0ahmenu7 db ' P(Print the data of the students)',0dh, 0ahmenu8 db ' C(Statistics the data of the students)',0dh, 0ahmenu9 db ' E(Exit the System)',0dh, 0ah,'$'msgmenu5_1 db 0DH,0AH,'1-----Modify name',0DH,0AHmsgmenu5_2 db '2-----Modify number',0DH,0AHmsgmenu5_3 db '3-----Modify score',0DH,0AH,'$'msgmenu3_1 db 0DH,0AH,'1-----Search name',0DH,0AHmsgmenu3_2 db '2-----Search number',0DH,0AHmsgmenu3_3 db '3-----Search score',0DH,0AH,'$'mmenutip db ' choose a number from the menu above',0DH,0AH,'$'msgprinttitle db 0DH,0AH,0DH,0AH,' sno sname score ',0DH,0AH,'$'gap db ' $'stu dw ?stustored dw 0swapped db 0sav_cnt dw ?stusaved dw 0saveflag db 1errcde db 0endcde db 0endaddr dw ?filehandle dw ?msg_titleln db ' ------------------------------------',13,10,'$'msgsepln db '--------------------------------',0DH,0AH,'$'msg02 db 'Please input the new student info.',13,10,'$'msg03 db 'Name:','$'msg04 db 'ID:','$'msg05 db 'Score:','$'msg07 db 'Successly Saved!',13,10,'$'msgdeled db 'Successly Deleted a item!',13,10,'$'msgmoded db 'Successly Modified a item content!',13,10,'$'msginsed db 'Successly Inserted item(s)!',13,10,'$'msgqforins db 'Insert this item?(y/n):',13,10,'$'msgback db 'Press any key to back.$'msgexit db 'Press any key to exit.$'msg09 db 'students out of 30.',13,10,'$'msg20 db 'There are more than 30 students.',13,10,'$'msg21 db 'Save as:',13,10,'$'msg22 db 'Please input the file you want to operate:',13,10,'$'msg23 db 'Read successly!',13,10,'$'msg27 db 'There isn',27h,'t any student.',13,10,'$'msgnoext db 'There is no such item!',13,10,'$'msgnaminfid db 'Please input a name to find:',13,10,'$'msgnuminfid db 'Please input a number to find:',13,10,'$'msgscoinfid db 'Please input a score to find:',13,10,'$'msgstattit db 9,9,'The result of statistics is listed as follow:',13,10,'$'msg_nname db 'Please input a new one:',13,10,'$'msg_nnum db 'Please input a new num.:','$'msg_nsco db 'Please input a new score.:','$'msgqsave db 'The ducoment have not saved.Do you want to save it now(y/n)?','$'msg_delnamin db 'Please input the name you want to delete:',13,10,'$'msg_modname db 'Please input the name field you want to modify:',13,10,'$' msg_modnum db 'Please input the number field you want to modify:',13,10,'$'msg_modsco db 'Please input the score field you want to modify:',13,10,'$' opnmsg db '***Error occured while opening file***',13,10,'$' wrtmsg db '***Error occured while writing file***',13,10,'$' readmsg db '***Error occured while reading file***',13,10,'$' routemsg db '***Path name is invalid***',13,10,'$'data endscode segmentassume cs:code,ds:data,ss:stsg,es:datamain proc farstart:mov ax,datamov ds,axmov es,axmainmenu:mov AX,0600Hmov CX,0000Hmov DX,174FHmov BH,07int 10Hmov AH,02 ;set cursormov BH,0mov DX,0100Hint 10Hlea DX,titl ;display menumov AH,9int 21Hshowmsg _titlelnlea DX,mmenutipmov AH,9int 21Hcase:mov ah,0int 16hcmp ah,17h;'i'je addonecmp ah,26h;'l'je browsecmp ah,19h;'p'je displaycmp ah,10h;'q'je querycmp ah,20h;'d'je del_intermcmp ah,2eh;'c'je statiscmp ah,32h;'m'je changecmp ah,12h;'e'je exitdisplay:call display_inanykeybackjmp mainmenuquery:call query_inanykeybackjmp mainmenubrowse:call browse_inanykeybackjmp mainmenuaddone:call insert_inanykeybackjmp mainmenuexit:call quitstatis:call stat_inanykeybackjmp mainmenudel_interm:jmp deletechange:call mod_inanykeybackjmp mainmenudelete:call del_inanykeybackjmp mainmenubeep:mov AH,14mov AL,7mov BH,0int 10Hjmp mainmenumain endp;------------------------------------------------------------------------ browse_in proc nearcall near ptr clearcall near ptr cursorcall near ptr readallcall name_sortcall near ptr printretbrowse_in endp;------------------------------------------------------------------------ del_in proc nearcall clearcall cursorcall delete_inretdel_in endp;------------------------------------------------------------------------ query_in proc nearcall clearcall cursorcall bg_searchretquery_in endp;------------------------------------------------------------------------ stat_in proc nearcall clearcall cursorcall near ptr statretstat_in endp;------------------------------------------------------------------------ insert_in proc nearcall clearcall cursorcall near ptr inputcall name_sortretinsert_in endp;------------------------------------------------------------------------ display_in proc nearcall clearcall cursorcall near ptr printretdisplay_in endp;------------------------------------------------------------------------ mod_in proc nearcall clearcall cursorcall printcall bg_modifycall name_sortretmod_in endp;------------------------------------------------------------------------ delete_in proc nearpush axpush dxcall printcrlfmmov ah,9lea dx,msg_delnaminint 21hcall near ptr inputnamecall near ptr delshowmsg deledqdel:pop dxpop axretdelete_in endp;------------------------------------------------------------------------ bg_search proc nearshowmsg menu3_1mov ah,1int 21h;getch()crlfmcmp al,'1'je q1cmp al,'2'je q2showmsg scoinfidlea bx,studentx+14mov dx,3jmp bgsearq1:showmsg naminfidcall near ptr inputnamelea bx,studentxmov dx,1jmp bgsearq2:showmsg numinfidcall near ptr inputnumlea bx,studentx+6mov dx,2bgsear:push bxpush dxcall near ptr search;search(studentx,1)cmp ax,-1je qinsshowmsg printtitleshowmsg seplnpush simov si,axcall near ptr printlinepop sijmp qqueqins:showmsg qforinsmov ah,01int 21hcrlfmcall inputnumcall inputscocall storshowmsg insedmov saveflag,0qque:retbg_search endp;------------------------------------------------------------------------ bg_modify proc nearpush axpush bxpush dxshowmsg menu5_1;display modify submenumov ah,1int 21h;getch()crlfmcmp al,'1'je t1cmp al,'2'je t2mov bx,3call inputscojmp cint1:call inputnamemov bx,1jmp cint2:mov bx,2call inputnumcin:push bxcall near ptr modifycmp ax,-1je qmodicrlfmshowmsg modedqmodi:pop dxpop bxpop axretbg_modify endp;------------------------------------------------------------------------ quit proc nearcmp saveflag,0je qforsavjmp qsysqforsav:call clearcall cursorshowmsg qsavemov ah,1int 21hcmp al,'y'je savitjmp qsyssavit:call savemov ah,3eh;close filemov bx,filehandleint 21hqsys:mov ax,4c00hint 21hretquit endp;------------------------------------------------------------------------ search proc nearpush bpmov bp,sppush dipush bxpush sipush cxpush dxmov di,[bp+6]mov dx,stustoredmov bx,[bp+4];bx:typemov bp,dicmp bx,1je snamcmp bx,2je snummov cx,3mov bx,cxlea ax,scofldjmp loop1snam:mov cx,6mov bx,cxlea ax,namefldjmp loop1snum:mov cx,8mov bx,cxlea ax,numfldloop1:mov si,axrepe cmpsbje foundadd bp,17mov di,bpdec dhjnz loop1mov ax,-1showmsg noextjmp qsearchfound:mov ax,bpmov dx,stustoredsub dx,bxmov cur_i,dxqsearch:pop dxpop cxpop sipop bxpop dipop bpret 4search endp;------------------------------------------------------------------------ name_sort proc nearpush sipush dipush axpush bxpush dxpush cxcmp stustored,1je qsortlea bx,studentxpush bxmov ax,stustoredsub ax,1mov bl,17mul blpop bxadd bx,axmov dx,stustoredsub dx,1 ;dx:il1:mov swapped,0sub bx,17mov endaddr,bxpush bxlea si,studentx;si:j,j=0l2:mov di,siadd di,17mov bx,dimov ax,sirepe cmpsbjbe s3exchange ax,bxs3:mov si,axadd si,17;j++cmp si,endaddrjbe l2pop bxcmp swapped,0je qsortdec dxjnz l1qsort:pop cxpop dxpop bxpop axpop dipop siretname_sort endp;------------------------------------------------------------------------ del proc nearpush bxpush dipush sipush cxlea bx,studentxpush bxmov bx,1;search(studentx,name)push bxcall near ptr searchcmp ax,-1je nomatchmov di,axmov si,diadd si,17;si:j,di:imov cx,stustoredsub cx,cur_imovit:movitem di,simov di,si;si:j+1 ,di:jmov dx,diadd dx,17mov si,dxloop movitmov ax,1mov saveflag,0sub stustored,1nomatch:pop cxpop sipop dipop bxretdel endp;------------------------------------------------------------------------ insert proc nearpush sipush dipush axpush bxpush cxcmp stustored,0je exilea si,stutemplea di,studentxmov ax,stustoredmov bl,17mul bladd di,axmov cx,17;rep movsbinc stustoredexi:pop cxpop bxpop axpop dipop siretinsert endp;------------------------------------------------------------------------ stor proc nearpush axpush bxpush dxpush dipush sipush cxcmp namelen,0je qstocldmov ax,stustoredmov bl,17mul bllea dx,studentxmov stu,dxadd stu,axmov di,stulea si,namefldmov cx,6rep movsblea si,numfldmov cx,8rep movsbmov cx,3lea si,scofldrep movsbinc stustoredqsto:pop cxpop sipop dipop dxpop bxpop axretstor endp;------------------------------------------------------------------------ modify proc nearpush bpmov bp,sppush bxpush dxpush dipush cxmov bx,[bp+4]cmp bx,1je mdnamcmp bx,2je mdnumlea dx,studentx+14jmp findmdnam:lea dx,studentxjmp findmdnum:lea dx,studentx+6find:push dxpush bxcall near ptr searchcmp ax,-1je qu_modmov di,ax;cmp bx,1je mnamcmp bx,2je mnumlea dx,msg_nscomov ah,9int 21hlea dx,scoparmov ah,0ahint 21hmov cx,3lea si,scofldjmp mfymnam:lea dx,msg_nnamemov ah,9int 21hcall inputnamemov cx,6lea si,namefldjmp mfymnum:lea dx,msg_nnummov ah,9int 21hlea dx,numparmov ah,0ahint 21hmov cx,8lea si,numfldmfy:rep movsbmov saveflag,0mov ax,1qu_mod:pop cxpop dipop dxpop bxpop bpret 2modify endp;------------------------------------------------------------------------ stat proc nearpush cxpush bxpush dxpush axmov cx,stustoredlea bx,[studentx+14]sta:mov dx,[bx]mov ah,[bx+2]cmp dl,'1'je a90cmp dh,'9'jae a90cmp dh,'8'jae a80cmp dh,'7'jae a70cmp dh,'6'jae a60add b60,1jmp repeata90:add ae90,1jmp repeata80:add ae80,1jmp repeata70:add ae70,1jmp repeata60:add ae60,1repeat:add bx,17loop stashowmsg stattitshowmsg _titlelnshowmsg _b60mov bl,byte ptr b60call deciasccrlfmshowmsg _titlelnshowmsg _ae60mov bl,byte ptr ae60call deciasccrlfmshowmsg _titlelnshowmsg _ae70mov bl,byte ptr ae70call deciasccrlfmshowmsg _titlelnshowmsg _ae80mov bl,byte ptr ae80call deciasccrlfmshowmsg _titlelnshowmsg _ae90mov bl,byte ptr ae90call deciasccrlfmshowmsg _titlelnmov ae90,0mov ae80,0mov ae70,0mov ae60,0mov b60,0pop axpop dxpop bxpop cxretstat endp;------------------------------------------------------------------- errm proc nearpush axmov ah,9int 21hmov errcde,01pop axreterrm endp;------------------------------------------------------------------- input proc nearpush axpush dxcall near ptr clearcall near ptr cursorcmp stustored,29ja i1mov ah,09lea dx,msg02;display promptint 21hiloop:cmp stustored,29ja i1call near ptr inputnamecmp namelen,0je i2call near ptr inputnumcall near ptr inputscocall near ptr storjmp iloopmov saveflag,0jmp i2i1:mov ah,9lea dx,msg20;'There are more than 30 students.' int 21hi2:showmsg back;'Press any key to back.'i3:mov saveflag,0pop dxpop axretinput endp;---------------------------------------------------------------------- inputname proc nearpush axpush dxpush bxpush cxshowmsg 03mov ah,0ahlea dx,nameparint 21hcrlfmmov bh,0mov bl,namelenmov cx,7sub cx,bxn10:mov namefld[bx],20hinc bxloop n10pop cxpop bxpop dxpop axretinputname endp;----------------------------------------------------------------------- inputnum proc nearpush axpush dxpush bxpush cxshowmsg 04mov ah,0ahlea dx,numparint 21hcrlfmmov bh,0mov bl,numlenmov cx,9sub cx,bxn20:mov numfld[bx]inc bxloop n20pop cxpop bxpop dxpop axretinputnum endp;---------------------------------------------------------------------- inputsco proc nearpush axpush dxpush bxpush cxshowmsg 05mov ah,0ahlea dx,scoparint 21hcrlfmmov bh,0mov bl,scolenmov cx,4sub cx,bxn21:mov scofld[bx],20hinc bxloop n21pop cxpop bxpop dxpop axretinputsco endp;------------------------------------------------------------------------ print proc nearpush sipush cxpush dxpush axcmp stustored,0je qprintcrlfmcrlfmshowmsg printtitleshowmsg seplnlea si,studentxmov cx,stustoredpline: call near ptr printlineloop plinepop axpop dxpop cxpop siqprint:retprint endp;------------------------------------------------------------------------ printline proc nearpush dipush cxpush dxpush axlea di,studisp;stutemp=studentx[i]mov cx,6rep movsbmov [studisp+6],9add di,1mov cx,8rep movsbmov [studisp+15],9add di,1mov cx,3rep movsbmov ah,9lea dx,studispint 21hcrlfmshowmsg seplnpop axpop dxpop cxpop diretprintline endp;------------------------------------------------------------------------ deciasc proc nearmov ch,100dmov cl,10dre:cmp ch,0je qdecimov al,bl;cbwdiv ch;mov bl,ahcall near ptr printitmov al,chcbwdiv clmov ch,aljmp reqdeci:retdeciasc endp;--------------------------------------------------------------------printit proc nearadd al,30hmov dl,almov ah,2int 21hretprintit endp;-------------------------------------------------------------------- stor2 proc nearpush sipush dipush axpush bxpush cxcmp stutemp,0je exittlea si,stutemplea di,studentxmov ax,stustoredmov bl,17mul bladd di,axmov cx,17;rep movsbinc stustoredpop cxpop bxpop axpop dipop siexitt: retstor2 endp;------------------------------------------------------------------------ get_path proc nearpush axpush bxpush dxshowmsg 22;'Please input the file you want to operate:' mov ah,0ahlea dx,pathparint 21h;crlfmmov bl,pathlenmov bh,0mov pathnam[bx],0pop dxpop bxpop axretget_path endp;--------------------------------------------------------------------openh proc nearpush axpush cxpush dxcall near ptr get_pathmov ah,3dhmov cx,0lea dx,pathnamint 21hjc o1mov filehandle,axpop dxpop cxpop axreto1:mov endcde,01lea dx,opnmsgcall near ptr errmpop dxpop cxpop axretopenh endp;-------------------------------------------------------------------- readall proc nearpush axmov endcde,0call near ptr openhcmp endcde,0jne rexit;endcde=1mov stustored,0contin:call near ptr readhcmp endcde,0jne r20;endcde=1call near ptr stor2cmp stustored,30ja oexitjmp continr20:call near ptr clsehcall clearcall cursorshowmsg 23jmp rexitoexit:call near ptr clsehmov saveflag,0showmsg 09;rexit:showmsg back;pop axretreadall endp;----------------------------------------------------------------------- readh proc nearpush axpush bxpush cxpush dxmov ah,3fh;read filemov bx,filehandlemov cx,17lea dx,stutempint 21hjc c1cmp ax,0je c2;ax=0,end of file,quitcmp stutemp,1ah;EOF Marker?je c2pop dxpop cxpop bxpop axretc1:lea dx,readmsgcall near ptr errmc2:mov endcde,1pop dxpop cxpop bxpop axretreadh endp;----------------------------------------------------------------------- save proc nearpush cxpush axmov errcde,0call near ptr clearcall near ptr cursorcall near ptr creathcmp errcde,0jne s2sloop:mov cx,stustoredcmp stusaved,cxje sexitcall near ptr writhcmp errcde,0jne sexitjmp sloopsexit:call near ptr clsehmov saveflag,1showmsg 07s2:showmsg exitanykeymov stusaved,0pop axpop cxretsave endp;------------------------------------------------------------------------ creath proc nearpush axpush cxpush dxshowmsg 21call near ptr get_pathcrlfmmov ah,3chmov cx,0lea dx,pathnamint 21hjc a1mov filehandle,axpop dxpop cxpop axreta1:lea dx,opnmsgcall errmpop dxpop cxpop axretcreath endp;------------------------------------------------------------------------ clseh proc nearpush axpush bxmov ah,3ehmov bx,filehandleint 21hpop bxpop axretclseh endp;------------------------------------------------------------------------ writh proc nearmov ax,stusavedmov bl,17mul bllea dx,studentxadd dx,ax;dxmov ah,40hmov bx,filehandlemov cx,17;cxint 21hinc stusavedjnc d1lea dx,wrtmsgcall near ptr errmd1:retwrith endp;------------------------------------------------------------------------ clear proc nearpush axpush bxpush cxpush dxmov AX,0600H ;clear screenmov CX,0mov DX,174FHmov BH,07int 10Hpop dxpop cxpop bxpop axretclear endp;------------------------------------------------------------------------ cursor proc nearpush axpush bxpush dxmov ah,2mov bh,0mov dx,0;dh:row,dl:columnint 10hpop dxpop bxpop axretcursor endpcode endsend start三.实验总结(心得、体会、实验设计不足之处)。

云南大学软件学院汇编语言实验报告五

云南大学软件学院汇编语言实验报告五

练习:多字节的二进制加法程序实验
1.实验内容
将两个4字节长的二进制数相加,运算结果存放在相应结果单元中。

2.说明
首先应安排程序的结构,其中代码段和数据段是必须有的。

代码段里实现数的相加,可用带进位的加法指令;数据段中存放被加数、加数和结果单元这些数据。

考虑到编程的方便,在定义加数和被加数时,将低位字节放到低地址,高位字节放在高地址。

进行加法运算时,按照由低地址到高地址的顺序取得数据,而每一步运算的结果也按照低位放在低地,高位放在高地址的方式进行存储。

源程序:
DATAS SEGMENT
DATA1 DD AB464431H
DATA2 DDAC5434H
DATA3 DW 2 DUP(0);
DATAS ENDS
STACKS SEGMENT
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV BP,0
LEA SI,DATA1 ;
LEA DI,DATA2
MOV AX,[SI]
ADD AX,[DI] ;
JC L ;
MOV 4[DATA3],AX ;
MOV AX,0
LOOP1: MOV AX,4[SI] ;
ADD AX,4[DI]
JMP LOOP3
LOOP2: MOV AX,1 ;
JMP LOOP3
LOOP3: MOV [DATA3],AX ;
MOV AH,4CH
INT 21H
CODES ENDS
END START。

大学物理实验8-实验报告

大学物理实验8-实验报告

云南大学软件学院实验报告
课程:大学物理实验学期:2014-2015学年第一学期任课教师:朱艳萍专业:学号:姓名:成绩:
实验8 光的干涉
一、实验目的
1.了解迈克耳逊干涉仪的结构,掌握调节方法;
2、观察光的干涉条纹。

二、实验步骤(用截图来表示)
1、调整干涉仪,为实验做好准备。

2、测量He-Ne激光的波长。

波长经计算得:631nm
3、测量钠光波长、波长差及相干长度。

缓慢转动微动手轮,移动M1,中心每生出或吞进n个条纹,几下移动的距离,用公式2h/n求出波长调节过程中发现钠光条纹的清晰度会产生变化。

4、测量透明薄片的折射率。

换用白光光源。

在d=0的附近可看到白色的干涉花纹:中央是直线黑纹,即中央花纹;两旁是对称分布的彩色花纹。

D稍大时,显不出条纹,当视场中出现中央花纹后,在M1与G1之间放入折射率为n,厚度为l的透明薄片,则此时光程差要比原来增大2l(n-1),中央花纹既移出视场范围,如果将M1向G1前移动d,使d=l(n-1) ,则中央花纹重新出现,测出d,则可由d=l(n-1)求出折射率n.。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

计算机组成原理与汇编元程序设计实验报告实验八实验考核:汇编程序综合设计实验
姓名:学号:序号:班级:分数:
1.编写程序,实现表的处理:内存单元中有一个ASCII码表,编写程序完成下面的功能:
①首先输出表的内容;
②插入一个数据,插入的数据和插入的位置从键盘输入;
③对表中的数据进行排序,按升顺或降顺排序可以进行选择;
④在表中查找某一个关键字,要查找的关键字从键盘输入;如果找到,输出查找的关键字并给出提示“find”,否则给出提示“no find”;
⑤程序执行以后,输出表中的插入以后的内容和排序以后的内容;
⑥程序有友好的运行界面;
⑦要求程序能够处理基本的错误信息;
2.
1)首先首先程序应该显示版权信息(自己考虑)。

2)其次显示今天的日期,显示格式是year:**** month:** day:**
3)然后再编写功能完善运算器程序,实现四则运算及进制转换。

要求:提供设计报告。

所有程序要求提供算法,程序框图,程序测试截图。

重要内容要求有解释!
- 1 -。

相关文档
最新文档