C0扩充文法编译器测试报告模板Word格式文档下载.docx
- 文档编号:21812702
- 上传时间:2023-02-01
- 格式:DOCX
- 页数:23
- 大小:18.27KB
C0扩充文法编译器测试报告模板Word格式文档下载.docx
《C0扩充文法编译器测试报告模板Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C0扩充文法编译器测试报告模板Word格式文档下载.docx(23页珍藏版)》请在冰豆网上搜索。
scanf(n);
Fib(n)is:
result=fib(n);
printf(result);
return;
}程序输出
输入一个数字,输出其斐波那契数
目标代码
.386
.modelflat,stdcall
optioncasemap:
none
includeC:
\RadASM\Masm32\include\windows.inc
\RadASM\Masm32\include\kernel32.inc
\RadASM\Masm32\include\msvcrt.inc
includelibC:
\RadASM\Masm32\lib\msvcrt.lib
\RadASM\Masm32\lib\kernel32.lib
\RadASM\Masm32\include\macros.asm
.data
piequ40490FCFh
.code
fibproc
pushebp
movebp,esp
subesp,100h
moveax,dwordptr[ebp+08h]
cmpeax,0
jne@label0_1
movdwordptr[ebp-04h],1
jmp@label0_2
@label0_1:
movdwordptr[ebp-04h],0
@label0_2:
cmpdwordptr[ebp-04h],0
jz@l1
moveax,1
addesp,100h
popebp
ret04h
@l1:
cmpeax,1
jne@label1_1
movdwordptr[ebp-08h],1
jmp@label1_2
@label1_1:
movdwordptr[ebp-08h],0
@label1_2:
cmpdwordptr[ebp-08h],0
jz@l2
@l2:
subeax,1
movebx,eax
moveax,ebx
pusheax
callfib
movdwordptr[ebp-010h],eax
subeax,2
movdwordptr[ebp-018h],eax
moveax,dwordptr[ebp-010h]
addeax,dwordptr[ebp-018h]
fibendp
start:
invokecrt_printf,SADD("
)
invokecrt_scanf,SADD("
%d"
),addrdwordptr[ebp-04h]
moveax,dwordptr[ebp-04h]
movdwordptr[ebp-0ch],eax
moveax,dwordptr[ebp-0ch]
movdwordptr[ebp-08h],eax
),dwordptr[ebp-08h]
invokeExitProcess,NULL
endstart
执行结果
正确
2测试样例二(正确)
voidmain()
inti,n,sum,sum2,temp;
Pleaseenterthetotalcount:
"
sum=0;
sum2=0;
for(i=0;
i<
n;
i=i+1)
{
scanf(temp);
sum=sum+temp;
sum2=sum2+temp*temp;
}
Sum="
printf(sum);
Avg="
printf(sum/n);
Var="
printf(sum2/n-(sum/n)*(sum/n));
return;
程序输出
先输入数n,回车,再输入n个数,用回车分隔,最后显示这n个数的和,平均数和方差。
.386
),addrdwordptr[ebp-08h]
moveax,0
movdwordptr[ebp-04h],eax
@l5:
cmpeax,dwordptr[ebp-08h]
jge@label0_1
movdwordptr[ebp-018h],1
movdwordptr[ebp-018h],0
cmpdwordptr[ebp-018h],0
jz@l6
addeax,1
),addrdwordptr[ebp-014h]
addeax,dwordptr[ebp-014h]
movedi,eax
moveax,edi
moveax,dwordptr[ebp-014h]
movecx,dwordptr[ebp-014h]
imulecx
movesi,eax
moveax,esi
addeax,dwordptr[ebp-010h]
jmp@l5
@l6:
),dwordptr[ebp-0ch]
cdq
movecx,dwordptr[ebp-08h]
idivecx
movdwordptr[ebp-028h],eax
),dwordptr[ebp-028h]
movdwordptr[ebp-02ch],eax
movdwordptr[ebp-030h],eax
moveax,dwordptr[ebp-030h]
movecx,dwordptr[ebp-030h]
moveax,dwordptr[ebp-02ch]
subeax,ebx
movdwordptr[ebp-03ch],eax
),dwordptr[ebp-03ch]
3测试样例三(正确)
voidmain(){
inta,b;
floatc,d;
Pleaseentertwointergers(A,B):
scanf(a,b);
A+B="
printf(a+b);
A-B="
printf(a-b);
A*B="
printf(a*b);
A/B="
printf(a/b);
Pleaseentertworealnumbers(C,D):
scanf(c,d);
C+D="
printf(c+d);
C-D="
printf(c-d);
C*D="
printf(c*d);
C/D="
printf(c/d);
先输入两个整数,会显示其四则运算结果,再输入两个实数,会显示其浮点数四则运算结果。
addeax,dwordptr[ebp-08h]
movdwordptr[ebp-014h],eax
),dwordptr[ebp-014h]
subeax,dwordptr[ebp-08h]
),dwordptr[ebp-018h]
movdwordptr[ebp-01ch],eax
),dwordptr[ebp-01ch]
movdwordptr[ebp-020h],eax
),dwordptr[ebp-020h]
%f"
),addrdwordptr[ebp-0ch]
),addrdwordptr[ebp-010h]
movecx,dwordptr[ebp-0ch]
pushecx
movecx,dwordptr[ebp-010h]
flddwordptr[esp+4]
fadddwordptr[esp]
fstpdwordptr[ebp-024h]
addesp,8
flddwordptrdwordptr[ebp-024h]
subesp,08h
fstpqwordptr[esp]
fsubdwordptr[esp]
fstpdwordptr[ebp-028h]
flddwordptrdwordptr[ebp-028h]
fmuldwordptr[esp]
fstpdwordptr[ebp-02ch]
flddwordptrdwordptr[ebp-02ch]
fdivdwordptr[esp]
fstpdwordptr[ebp-030h]
flddwordptrdwordptr[ebp-030h]
4测试样例四(正确)
floata,b,c,d;
floate;
scanf(a);
input+1.5"
a+1.5);
scanf(b);
input*2-lastinput/10"
b*2-a/10);
输入一个实数,对其进行实数运算。
_adword?
_bdword?
_cdword?
_ddword?
_edword?
),addr_a
movecx,_a
movecx,3FC00000h
fstpdwordptr[ebp-04h]
flddwordptrdwordptr[ebp-04h]
),addr_b
moveax,2
movdwordptr[esp-4],eax
filddwordptr[esp-4]
fstpdwordptr[esp-4]
moveax,dwordptr[esp-4]
moveax,10
flddwordptrdwordptr[ebp-018h]
5测试样例五(正确)
inta,b,c,d;
b=20;
a=4;
d=1;
c=0;
while(d!
=0){
if((10*d+1)>
=a*5){
c=c+2;
a=a*2;
d=d-4;
}
else
d=d+5;
printf(c);
屏幕输出67108918,此为溢出值
.modelflat,st
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C0 扩充 文法 编译器 测试报告 模板
![提示](https://static.bdocx.com/images/bang_tan.gif)