C0扩充文法编译器测试报告.doc

上传人:仙人指路1688 文档编号:3022301 上传时间:2023-03-08 格式:DOC 页数:19 大小:83KB
返回 下载 相关 举报
C0扩充文法编译器测试报告.doc_第1页
第1页 / 共19页
C0扩充文法编译器测试报告.doc_第2页
第2页 / 共19页
C0扩充文法编译器测试报告.doc_第3页
第3页 / 共19页
C0扩充文法编译器测试报告.doc_第4页
第4页 / 共19页
C0扩充文法编译器测试报告.doc_第5页
第5页 / 共19页
点击查看更多>>
资源描述

《C0扩充文法编译器测试报告.doc》由会员分享,可在线阅读,更多相关《C0扩充文法编译器测试报告.doc(19页珍藏版)》请在三一办公上搜索。

1、C0扩充文法编译器测试报告学号:_37230118_姓名:_罗杨_2010年 1月 16日1测试样例一(正确)测试样例int fib(int k)if (k=0)return (1);if (k=1)return (1);return (fib(k-1)+fib(k-2);void main()int n,result;printf(Please enter n: );scanf(n);printf(Fib(n) is: );result=fib(n);printf(result);return ;程序输出输入一个数字,输出其斐波那契数目标代码.386.model flat,stdcallop

2、tion casemap:noneincludeC:RadASMMasm32includewindows.incincludeC:RadASMMasm32includekernel32.incincludeC:RadASMMasm32includemsvcrt.incincludelib C:RadASMMasm32libmsvcrt.libincludelib C:RadASMMasm32libkernel32.libincludeC:RadASMMasm32includemacros.asm.datapiequ40490FCFh.codefibprocpushebpmovebp,espsu

3、besp,100hmoveax,dword ptr ebp+08hcmpeax,0jnelabel0_1movdword ptr ebp-04h,1jmplabel0_2label0_1:movdword ptr ebp-04h,0label0_2:cmpdword ptr ebp-04h,0jzl1moveax,1addesp,100hpopebpret04hl1:moveax,dword ptr ebp+08hcmpeax,1jnelabel1_1movdword ptr ebp-08h,1jmplabel1_2label1_1:movdword ptr ebp-08h,0label1_2

4、:cmpdword ptr ebp-08h,0jzl2moveax,1addesp,100hpopebpret04hl2:moveax,dword ptr ebp+08hsubeax,1movebx,eaxmoveax,ebxpusheaxcallfibmovdword ptr ebp-010h,eaxmoveax,dword ptr ebp+08hsubeax,2movebx,eaxmoveax,ebxpusheaxcallfibmovdword ptr ebp-018h,eaxmoveax,dword ptr ebp-010haddeax,dword ptr ebp-018hmovebx,

5、eaxmoveax,ebxaddesp,100hpopebpret04hfibendpstart:pushebpmovebp,espsubesp,100hinvokecrt_printf,SADD(Please enter n: )invokecrt_scanf,SADD(%d),addr dword ptr ebp-04hinvokecrt_printf,SADD(Fib(n) is: )moveax,dword ptr ebp-04hpusheaxcallfibmovdword ptr ebp-0ch,eaxmoveax,dword ptr ebp-0chmovdword ptr ebp-

6、08h,eaxinvokecrt_printf,SADD(%d),dword ptr ebp-08haddesp,100hpopebpinvokeExitProcess,NULLaddesp,100hpopebpinvokeExitProcess,NULLendstart执行结果正确2测试样例二(正确)测试样例void main()int i,n,sum,sum2,temp;printf(Please enter the total count:);scanf(n);sum=0;sum2=0;for ( i=0; i= a * 5)c = c + 2;a = a * 2;d = d - 4;e

7、lsed = d + 5;printf(c);程序输出屏幕输出67108918,此为溢出值目标代码.386.model flat,stdcalloption casemap:noneincludeC:RadASMMasm32includewindows.incincludeC:RadASMMasm32includekernel32.incincludeC:RadASMMasm32includemsvcrt.incincludelibC:RadASMMasm32libmsvcrt.libincludelibC:RadASMMasm32libkernel32.libincludeC:RadASMM

8、asm32includemacros.asm.data_adword?_bdword?_cdword?_ddword?.codestart:pushebpmovebp,espsubesp,100hmoveax,20mov_b,eaxmoveax,4mov_a,eaxmoveax,1mov_d,eaxmoveax,0mov_c,eaxl0:moveax,_dcmpeax,0jelabel0_1movdword ptr ebp-04h,1jmplabel0_2label0_1:movdword ptr ebp-04h,0label0_2:cmpdword ptr ebp-04h,0jzl1move

9、ax,10movecx,_dimulecxmovedi,eaxmoveax,ediaddeax,1movesi,eaxmoveax,_amovecx,5imulecxmovebx,eaxmoveax,esicmpeax,ebxjllabel1_1movdword ptr ebp-014h,1jmplabel1_2label1_1:movdword ptr ebp-014h,0label1_2:cmpdword ptr ebp-014h,0jzl5moveax,_caddeax,2movedi,eaxmoveax,edimov_c,eaxmoveax,_amovecx,2imulecxmoves

10、i,eaxmoveax,esimov_a,eaxmoveax,_dsubeax,4movebx,eaxmoveax,ebxmov_d,eaxjmpl8l5:moveax,_daddeax,5movebx,eaxmoveax,ebxmov_d,eaxl8:jmpl0l1:invokecrt_printf,SADD(%d),_caddesp,100hpopebpinvokeExitProcess,NULLendstart执行结果正确6测试样例六(错误)测试样例const int a = 1;float b;int c;void main()b = 123.456;c = b / 1.5 + 1;p

11、rintf c;程序输出出错,printf缺少括号执行结果错误7测试样例七(错误)测试样例void main() int a; scanf(a); a = a+1; printf(a=, a); return程序输出出错,return缺少分号执行结果错误8测试样例八(错误)测试样例int g(int aa)int a;if(aa=1)a=1;else a=aa*g(aa-1);void main()int i;scanf(i);a=g(i);printf(a);程序输出出错,标识符a未定义执行结果错误9测试样例九(错误)测试样例void main()int fahr,celsius,lower

12、,step;lower=0;celsius=0;step=20;fahr=lower;printf(/while statementn);while(fahr=upper)celsius=2*(fahr-32);printf(celsius);printf(n);fahr=fahr+step;printf(/while statementn);程序输出标识符upper未定义执行结果错误10测试样例十(错误)测试样例int f(int a)if(a=1)a=1;else a=a*f(a-1,1);return(a);void main()int i,a;printf(please input n =:n);scanf(i);a=f(i);printf(n! = %dn,a);程序输出出错,函数调用时参数个数不符定义执行结果错误

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

当前位置:首页 > 教育教学 > 成人教育


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号