logo资料库

北航软件学院计组期末试题_20140114.pdf

第1页 / 共14页
第2页 / 共14页
第3页 / 共14页
第4页 / 共14页
第5页 / 共14页
第6页 / 共14页
第7页 / 共14页
第8页 / 共14页
资料共14页,剩余部分请下载后查看
北京航空航天大学 2013-2014 学年 第一学期 《计算机组成与体系结构》期末考试 Class number 班级__________ Student ID 学号 ___________ Student Name 姓名______________ Score 成绩 ____________ 答题页 1 (答案全部填写在答题页中,其它地方无效) Problem 1.(20 points) 1____ 2____ 3____ 4____ 5____ 6____ 7____ 8____ 9____ 10_____ 11_____ 12_____ 13_____ 14_____ 15_____ 16_____ 17_____ 18_____ 19_____ 20 Function sizeof (char) sizeof (int) sizeof (void*) sizeof (long) Intel IA32 Intel x86 64 Problem 2.(10 points) Value 9/32 1 12 11 1/8 7/32 Floating Point Bits Rounded value 001 00 1/4 Problem 3.(8 points) Code Block Function Name A B C D Problem 4.(11 points) Cases ____________________ should have "break". 0x400590: ________________ 0x400598: ________________ 0x4005a0: ________________ 0x4005a8: ________________ 0x4005b0: ________________ 0x4005b8: ________________ 0x4005c0: ________________ 0x4005c8: ________________ 0x4005d0: ________________ 0x4005d8: ________________ Problem 5.(12 points) A: x = ______ B: string "0123456" is stored at ___________ C: buf[0] = 0x_____ _____ _____ _____ buf[1] = 0x_____ _____ _____ _____ buf[2] = 0x_____ _____ _____ _____ buf[3] = 0x_____ _____ _____ _____ buf[4] = 0x_____ _____ _____ _____
答题页 2 D: Value at %ebp is ___________ E: Value at %esp is ___________ F: Problem 6.(9 points) Answer: a=_____, b=_____, c=_____ Problem 7.(10 points) (a). Cache size is _____ bytes (b). Tag is _____ bits (c). Problem 8.(10 points) 1. ____________________ 2. ____________________ 3. ____________________ Problem 9.(10 points) 1. a. Physical address of PDE: ___________ b. Physical address of PTE: ___________ c. Success: The physical address accessed is ___________ or Failure: Address of table entry causing failure is ___________ 2. a. Physical address of PDE: ___________ b. Physical address of PTE: ___________ c. Success: The physical address accessed is ___________ or Failure: Address of table entry causing failure is ___________
Problem 1. 1. Consider the following code, what is the output of the printf? 下面代码的输出是什么? int x = 0x15213F10 >> 4; char y = (char) x; unsigned char z = (unsigned char) x; printf("%d, %u", y, z); (a) -241, 15 (b) -15, 241 (c) -241, 241 (d) -15, 15 2. In two’s compliment, what is −TMin? 补码中,−TMin 的值是多少? (a) TMin (b) TMax (c) 0 (d) −1 3. Let int x = −31/8 and int y = −31 >> 3. What are the values of x and y? (a) x = −3, y = −3 (b) x = −4, y = −4 (c) x = −3, y = −4 (d) x = −4, y = −3 4. In C, the expression ”15213U > −1” evaluates to: (a) True (1) (b) False (0) 5. In two’s compliment, what is the minimum number of bits needed to represent the number -1 and the number 1 respectively? 补码中,表示数字 -1 和 1 需要的最小位数分别是多少? (a) 1 and 2 (b) 2 and 2 (c) 2 and 1 (d) 1 and 1 6. Consider the following program. Assuming the user correctly types an integer into stdin, what will the program output in the end? 假设用户正确输入了一个整数,下面代码的输出是什么? #include int main() { int x = 0; printf ("Please input an integer:"); scanf ("%d",x); printf ("%d", (!!x)<<31); }
(a) 0 (b) T Min (c) Depends on the integer read from stdin 取决于用户输入的整数 (d) Segmentation fault 段错误 7. Which of the following registers stores the return value of functions in Intel x86 64? Intel x86 64 系统中哪个寄存器保存函数的返回值? (a) %rax (b) %rcx (c) %rdx (d) %rip (e) %cr3 8. The leave instruction is effectively the same as which of the following: Leave 指令相当于: (a) mov %ebp, %esp pop %ebp (b) pop %eip (c) mov %esp, %ebp pop %esp (d) ret 9. Select the two’s complement negation of the following binary value: 0000101101: 二进制数 0000101101 负值的补码是: (a) 1111010011 (b) 1111010010 (c) 1000101101 (d) 1111011011 10. Which line of C-code will perform the same operation as leal 0x10(%rax,%rcx,4),%rax? 下面哪行 c 代码和 leal 0x10(%rax,%rcx,4),%rax 操作相同? (a) rax = 16 + rax + 4 * rcx (b) rax = *(16 + rax + 4 * rcx) (c) rax = 16 + * (rax + 4 * rcx) (d) *(16 + rcx + 4 * rax) = rax (e) rax = 16 + 4 * rax + rcx 11. Which of the following assembly instructions is invalid in Intel IA32 Assembly? IA32 系统中,下面哪条汇编指令是非法的? (a) pop %eip (b) pop %ebp (c) mov (%esp),%ebp (d) lea 0x10(%esp),%ebp 12. For the Unix linker, which of the following accurately describes the difference between global symbols and local symbols? 对 UNIX 链接器,下面哪个说法准确描述了全局符号和本地符号的差异?
(a) There is no functional difference as to how they can be used or how they are declared. 它们的使用和声明没有功能上的区别。 (b) Global symbols can be referenced by other modules (files), but local symbols can only be referenced by the module that defines them. 全局符号可以被其它模块引用,而本地符号只能被定义它们的模块引用。 (c) Global symbols refer to variables that are stored in .data or .bss, while local symbols refer to variables that are stored on the stack. 全局符号指的是保存在.data 或.bss 中的变量,而本地符号指的是保存在栈里的变量。 (d) Both global and local symbols can be accessed from external modules, but local symbols are declared with the “static” keyword. 全局符号和本地符号都可以被外部模块访问,但本地符号用“static”关键字声明。 13. Which of the following is true concerning dynamic memory allocation? 关于动态存储器分配,下列哪项是正确的? (a) External fragmentation is caused by chunks which are marked as allocated but actually cannot being used. 外部碎片是由标记为已分配但实际上不能被使用的片引起的。 (b) Internal fragmentation is caused by padding for alignment purposes and by overhead to maintain the heap data structure (such as headers and footers). 内部碎片是由为了对齐目的的填充和保持堆数据结构(如头部和脚部)的开销引起的。 (c) Coalescing while traversing the list during calls to malloc is known as immediate coalescing. 调用 malloc 过程中遍历链表时的合并是立即合并。 (d) Garbage collection, employed by calloc, refers to the practice of zeroing memory before use. calloc 采用的垃圾收集是指存储器使用前归零。 For the next 3 questions, consider the following code running on a 32-bit Linux system. 下面 3 个问题,考虑运行在 32 位 linux 系统上的代码 int main() { long a, *b, c; char **p; p = calloc(8, sizeof(char)); /*calloc returns 0x1dce1000*/ a = (long) (p + 0x100); b = (long*) (*p + 0x200); c = (int) (b + 0x300); printf("p=%p a=%x b=%p c=%x\n", p, a, b, c); exit(0); } 14. When printf is called, what is the hex value of variable a? printf 被调用时,变量 a 的值是? (a) Can’t tell (b) 0x1dce1100 (c) 0x1dce1400 (d) 0x1dce1800
15. When printf is called, what is the hex value of variable b? printf 被调用时,变量 b 的值是? (a) Can’t tell (b) 0x1dce1200 (c) 0x1dce2000 (d) 0x200 (e) 0x800 16. When printf is called, what is the hex value of variable c? printf 被调用时,变量 c 的值是? (a) Can’t tell (b) 0x1dce2a00 (c) 0x1dce4400 (d) 0xc00 (e) 0xe00 17. Which of the following is not a default action for any signal type? 下面哪项不是对某个信号类型的默认行为? (a) The process terminates. 进程终止。 (b) The process reaps the zombies in the waitlist. 进程回收等待列表中的僵死进程。 (c) The process stops until restarted by a SIGCONT signal. 进程停止直到被 SIGCONT 信号重启。 (d) The process ignores the signal. 进程忽略信号。 (e) The process terminates and dumps core. 进程终止并转储存储器。 18. A system uses a two-way set-associative cache with 16 sets and 64-byte blocks. Which set does the byte with the address 0xdeadbeef map to? 一个系统使用 2 路组相联高速缓存,有 16 组和 64 字节的块。地址 0xdeadbeef 映射到哪组? (a) Set 7 (b) Set 11 (c) Set 13 (d) Set 14 19. When it suceeds, longjmp is called once and returns how many times? 调用成功时,longjmp 被调用一次,返回多少次? (a) 0 (b) 1 (c) 2 (d) 3 20. Please fill in the return value for the following function calls on both an Intel IA32 and Intel x86 64 system. 在答题页 1 的表中填写函数调用在 Intel IA32 和 Intel x86 64 系统中的返回值。
Problem 2. Consider the following 5-bit floating point representation based on the IEEE floating point format. This format does not have a sign bit – it can only represent nonnegative numbers. 考虑下面基于 IEEE 浮点格式的 5 位浮点表示,没有符号位,只能表示非负数。 • There are k = 3 exponent bits. The exponent bias is 3. 有 k = 3 个阶码位,偏置值是 3 • There are n = 2 fraction bits. 有 n = 2 个小数位 Below, you are given some decimal values, and your task is to encode them in floating point format. In addition, you should give the rounded value of the encoded floating point number. To get credit, you must give these as whole numbers (e.g., 17) or as fractions in reduced form (e.g., 3/4). Any rounding of the significand is based on round-to-even. 下面给出了一些十进制数值,你的任务是将它们编码为浮点格式。另外,给出被编码的浮点 数舍入后的值。给出整数(例如 17)或者分数(例如 3/4)。使用舍入到偶数的原则。 Value 9/32 1 12 11 1/8 7/32 Floating Point Bits Rounded value 001 00 1/4
Problem 3. Consider the following data structure declaration: struct ms_pacman{ short wire; int resistor; union transistor{ char bjt; int *mosfet; long vacuum_tube[2]; } transistor; struct ms_pacman *connector; }; Below are given four C functions and four x86-64 code blocks. 下面给出 4 个 c 函数和 4 段 x86-64 代码。 In the following table, next to the name of each x86-64 code block, write the name of the C function that it implements. 下表中,在 x86-64 代码块名字的右边写出对应 c 函数名。 Code Block Function Name A B C D
分享到:
收藏