【特别注意】
答案来源于@wolf
是我在备考时自己做的,仅供参考,若有不同的地方欢迎讨论。
【试卷评析】
有必要一做。
【试卷与答案】
1.简答题(10 分)
小明设计了一款机器,整数和浮点数都占 10 个 bit,其中整数采用补码表示,浮点数采用
2.程序填空题(20 分,每空 4 分)
#include <stdio.h>
#define X (1)
#define Y 23
int array1[X][Y];
int array2[X];
int test()
{
int sum= (2) ;
int i=0;
do
{
if( (3) ) continue;
sum+= (4) ;
}while(i<X && i<Y);
return (5) ;
}
int main()
{
return 0;
}
test:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $14, -8(%ebp)
movl $0, -4(%ebp)
.L5:
movl -4(%ebp), %eax
movl array2(,%eax,4), %ecx
movl -4(%ebp), %edx
movl %edx, %eax
addl %eax, %eax
addl %edx, %eax
sall $5, %eax
addl $array1, %eax
movl (%eax), %eax
imull %ecx, %eax
cmpl $6, %eax
jle .L2
movl -4(%ebp), %eax
movl array2(,%eax,4), %ecx
movl -4(%ebp), %edx
movl %edx, %eax
addl %eax, %eax
addl %edx, %eax
sall $5, %eax
addl $array1, %eax
movl (%eax), %eax
movl %ecx, %edx
subl %eax, %edx
movl %edx, %eax
cmpl $7, %eax
jle .L6
.L2:
movl -4(%ebp), %edx
movl %edx, %eax
addl %eax, %eax
addl %edx, %eaxsall $5, %eax
addl $array1, %eax
movl (%eax), %edx
movl -4(%ebp), %eax
movl array2(,%eax,4), %eax
addl %edx, %eax
addl -4(%ebp), %eax
addl %eax, -8(%ebp)
addl $1, -4(%ebp)
jmp .L3
.L6:
nop
.L3:
cmpl $18, -4(%ebp)
jg .L4
cmpl $22, -4(%ebp)
jle .L5
.L4:
movl -8(%ebp), %eax
subl $5, %eax
imull -8(%ebp), %eax
leave
ret
【答案】
文章来源地址https://www.toymoban.com/news/detail-481571.html
3.综合应用题(20 分)
0804841d <main>:
804841d: 55 push %ebp
804841e: 89 e5 mov %esp,%ebp
8048420: 83 e4 f0 and $0xfffffff0,%esp
8048423: 83 ec 20 sub $0x20,%esp
8048426: c7 44 24 18 0a 00 00 movl $0xa,0x18(%esp)
804842d: 00
804842e: c7 44 24 1c 00 00 00 movl $0x0,0x1c(%esp)
8048435: 00
8048436: 8b 44 24 18 mov 0x18(%esp),%eax
804843a: 89 04 24 mov %eax,(%esp)
804843d: e8 1a 00 00 00 call 804845c <function>
8048442: 89 44 24 1c mov %eax,0x1c(%esp)
8048446: 8b 44 24 1c mov 0x1c(%esp),%eax
804844a: 89 44 24 04 mov %eax,0x4(%esp)
804844e: c7 04 24 50 85 04 08 movl $0x8048550,(%esp)8048455: e8 96 fe ff ff call 80482f0 <printf@plt>
804845a: c9 leave
804845b: c3 ret
0804845c <function>:
804845c: 55 push %ebp
804845d: 89 e5 mov %esp,%ebp
804845f: 53 push %ebx
8048460: 83 ec 24 sub $0x24,%esp
8048463: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
804846a: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
804846e: 75 09 jne 8048479 <function+0x1d>
8048470: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
8048477: eb 38 jmp 80484b1 <function+0x55>
8048479: 83 7d 08 01 cmpl $0x1,0x8(%ebp)
804847d: 74 06 je 8048485 <function+0x29>
804847f: 83 7d 08 02 cmpl $0x2,0x8(%ebp)
8048483: 75 09 jne 804848e <function+0x32>
8048485: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp)
804848c: eb 23 jmp 80484b1 <function+0x55>
804848e: 8b 45 08 mov 0x8(%ebp),%eax
8048491: 83 e8 01 sub $0x1,%eax
8048494: 89 04 24 mov %eax,(%esp)
8048497: e8 c0 ff ff ff call 804845c <function>
804849c: 89 c3 mov %eax,%ebx
804849e: 8b 45 08 mov 0x8(%ebp),%eax
80484a1: 83 e8 02 sub $0x2,%eax
80484a4: 89 04 24 mov %eax,(%esp)
80484a7: e8 b0 ff ff ff call 804845c <function>
80484ac: 01 d8 add %ebx,%eax
80484ae: 89 45 f4 mov %eax,-0xc(%ebp)
80484b1: 8b 45 f4 mov -0xc(%ebp),%eax
80484b4: 83 c4 24 add $0x24,%esp
80484b7: 5b pop %ebx
80484b8: 5d pop %ebp
80484b9: c3 ret
#include "stdio.h"
void main()
{
int v=10,result=0;
result=function(v);//这是 p.c 文件
double d;
void p1() {
d=1.0;
}
printf("%d\n",result);
}
int function(int f)
{
int e=0;
if(f==_①_) e=0;
else if(f==_②_||f==_③_) e=1;
else e=function(_④_)+function(_⑤_);
return e;
}
4.综合应用题(25 分)
注意输出为什么是x=1072693248
5.综合应用题(25 分)
文章来源:https://www.toymoban.com/news/detail-481571.html
到了这里,关于湖南大学CS-2021期末考试解析的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!