计算机系统基础(一):程序的表示、转换与链接(第七周小测验)

2年前 (2022) 程序员胖胖胖虎阿
142 0 0

1.假设P为调用过程,Q为被调用过程,程序在IA-32处理器上执行,以下有关过程调用的叙述中,错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice1">A.从Q跳回到Q执行应使用RET指令<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice1">B.从P传到Q的实参无需重新分配空间存放<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice1">C.C语言程序中的函数调用就是过程调用<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice1">D.从P跳转到Q执行应使用CALL指令<br> </div>

2.以下是有关IA-32的过程调用方式的叙述,错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice2">A.EBX、ESI、EDI、EBP和ESP都是被调用 者保存寄存器<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice2">B.入口参数使用栈(stack)传递,即所传递的实参被分配在栈中<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice2">C.返回地址是CALL指令下一条指令的地址,被保 存在栈中<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice2">D.EAX、ECX和EDX都是调用者保存寄存器<br> </div>

3.以下是有关IA-32的过程调用所使用的栈和栈帧的叙述,错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice3">A.只能通过将栈指针ESP作为基址寄存器 来访问用户栈中的数据<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice3">B.过程嵌套调用深度越深,栈中栈帧个数越多, 严重时会发生栈溢出<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice3">C.从被调用过程返回调用过程之前,被调用过程 会释放自己的栈帧<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice3">D.每进行一次过程调用,用户栈从高地址向低地 址增长出一个栈帧<br> </div>

4.以下是有关C语言程序的变量的作用域和生存期的叙述,错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice4">A.因为非静态局部变量被分配在栈中,所以其作 用域仅在过程体内<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice4">B.非静态局部变量可以和全局变量同名,是因为 它们被分配在不同存储区<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice4">C.静态(static型)变量和非静态局部(auto型)变量都分配在对应栈帧中<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice4">D.不同过程中的非静态局部变量可以同名,是因 为它们被分配在不同栈帧中<br> </div>

5.以下是一个C语言程序代码:

int add(int x, int y)
{
	return x+y;
}

int caller( )
{
	int t1=100 ;
	int t2=200;
	int sum=add(t1, t2);
	return sum;
}

以下关于上述程序代码在IA-32上执行的叙述中,错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice5">A.变量sum被分配在caller函数的栈帧中<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice5">B.add函数返回时返回值存放在EAX寄存器中<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice5">C.变量t1和t2被分配在caller函数的栈帧中<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice5">D.传递参数时t1和t2的值从高地址到低地址依次存入栈中<br> </div>

6.第5题中的caller函数对应的机器级代码如下:

1      pushl       %ebp
2      movl       %esp, %ebp
3      subl         $24, %esp
4      movl        $100, -12(%ebp)
5      movl        $200, -8(%ebp) 
6      movl       -8(%ebp), %eax
7      movl        %eax, 4(%esp)
8      movl        -12(%ebp), %eax
9      movl        %eax, (%esp)  
10    call          add  
11    movl        %eax, -4(%ebp) 
12    movl        -4(%ebp), %eax
13    leave        
14    ret 

假定caller的调用过程为P,对于上述指令序列,以下叙述中错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice6">A.第1条指令将过程P的EBP内容压入caller栈帧<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice6">B.第3条指令将栈指针ESP向高地址方向移动,以生成当前栈帧<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice6">C.第2条指令使BEP内容指向caller栈帧的底部<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice6">D.从上述指令序列可看出,caller函数没有使用 被调用者保存寄存器<br> </div>

7.对于第5题的caller函数以及第6题给出的对应机器级代码,以下叙述中错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice7">A.变量t1和t2的有效地址分别为R[ebp]-12和R[ebp]-8<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice7">B.参数t1所在的地址低(或小)于参数t2所在的 地址<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice7">C.参数t1和t2的有效地址分别为R[esp]和R[esp]+4<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice7">D.变量t1所在的地址高(或大)于变量t2所在的地址<br> </div>

8.以下有关递归过程调用的叙述中,错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice8">A.可能需要执行递归过程很多次,因而时间开销 大<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice8">B.递归过程第一个参数的有效地址为R[ebp]+8<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice8">C.每次递归调用都会生成一个新的栈帧,因而空 间开销大<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice8">D.每次递归调用在栈帧中保存的返回地址都不相同<br> </div>

9.以下关于if (cond_expr) then_statement else else_statement选择结构对应的机器级代码表示的叙述中,错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice9">A.一定包含一条无条件转移指令<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice9">B.一定包含一条条件转移指令(分支指令)<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice9">C.对应then_statement的代码一定在对应else_statement的代码之前<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice9">D.计算cond_expr的代码段一定在条件转移指令之前<br> </div>

10.以下关于循环结构语句的机器级代码表示的叙述中,错误的是( )。

<div> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled checked type="radio" name="choice10">A.循环体内执行的指令不包含条件转移 指令<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice10">B.循环结束条件通常用一条比较指令CMP来实现<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice10">C.一定至少包含一条条件转移指令<br> &nbsp;&nbsp;&nbsp;&nbsp;<input disabled type="radio" name="choice10">D.不一定包含无条件转移指令<br> </div>

相关文章

暂无评论

暂无评论...