2022年复旦计算机级春季期末考试试题A .pdf





《2022年复旦计算机级春季期末考试试题A .pdf》由会员分享,可在线阅读,更多相关《2022年复旦计算机级春季期末考试试题A .pdf(20页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1 复旦大学计算机科学技术学院计算机原理期末考试试卷A卷共 13 页课程代码: INFO130054.01-02 _ 考试形式:开卷2010 年 6 月(本试卷答卷时间为100 分钟,答案必须写在答卷上,做在试卷上无效)专业学号姓名成绩题号1 2 3 4 5 6 7 总分得分Problem 1.Number Conversion: IEEE 754 single precision 32-bit float standard representation with a little change is illustrated below. Normalized: (-1)sign * (1.f
2、raction) * 2exponent-127(exp=1 to 254)Denormalized: (-1)sign * (0.fraction) * 2-126(when exp=0, fraction0)Zero: all 0s in all 3 fields1)Convert the number -35.390625 into this changed IEEE 754 FP single precision representation (in hex). (-35.390625)10= (0 x )16名师资料总结 - - -精品资料欢迎下载 - - - - - - - - -
3、 - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 20 页 - - - - - - - - - 2 2)With changed 32-bit float representation, what is the equivalent value as a decimal number? A: (0011 1111 0001 0000 0000 0000 0000 0000)2B: (0000 0000 0011 0101 0000 0000 0000 0000)23)Calculate the sum of (35.390625)10 and (0
4、011 1111 0001 0000 0000 0000 0000 0000)2using changed 32-bit float representation, and then round the sum (in binary number value, e.g. (1000.11)2for (8.75)10 ) to 4 bits to the right of the binary point by both round-up and round-down. Give your steps detailed. 4)Given three numbers f1, f2 and f3 o
5、f this changed 32-bit representation, none of them equals +, -or NaN, and x is signed 32-complement representation. Please tell whether two C expressions below are always true. If yes, give the reason in detail; If no, give a counterexample and show the detail computation steps to get false. A: x =
6、= (int) (float) x; B: (f1 f2) = = (f1 + f3) (f2 + f3) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 20 页 - - - - - - - - - 3 Problem 2.Please read the following C code and assembly code and then fill in the blanks. #include int p54 = 43,56,78,69,-7,89,7,23,24,
7、36,88,67, 12,56,78,90,62,93,-78,9; int main(void) int result = cal(5,4); printf(The result is %dn, result); int cal(int a, int b) int i; int result=0; for ( i = 0; i b; i+) if (i a-1) result -= i*pi+1i; return result; The assembly code:cal: pushl %ebp movl %esp, %ebp subl $8, %esp movl $0, -8(%ebp)
8、movl $0, -4(%ebp) .L3: movl -4(%ebp), %eax cmpl 12(%ebp), %eax jl .L6 jmp .L4 .L6: movl 8(%ebp), %eax decl %eax cmpl %eax, -4(%ebp) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 20 页 - - - - - - - - - 4 jge .L5 movl -4(%ebp), %eax sall _ _, %eax movl %eax, %ed
9、x addl -4(%ebp), %edx movl -4(%ebp), %eax imull _ _(,%edx,4), %eax movl %eax, %edx leal -8(%ebp), %eax subl %edx, (%eax) .L5: leal -4(%ebp), %eax incl (%eax) jmp .L3 .L4: movl -8(%ebp), %eax leave retPlease give the reason for the blanks you filled in the assembly code and the result of the printf i
10、n main function.名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 20 页 - - - - - - - - - 5 Problem 3.The following figure illustrates a five stage pipeline processor similar to that in your text book (Figure 4.53, Page 334 in English Book). Notice there are three
11、differences for this architecture from that in your book. First difference is that Function Units in Stage E become multi-cycle function units. Now stage E contains three function units, two Adder and one Subtracter. The Subtracter can only handle subtraction operations and takes 3 cycles to complet
12、ion. The Adder can handle other calculation exception subtraction and takes 2 cycles to completion. Notice one Adder or Substracter can handle only one instruction at a time, that is, other instructions must wait in its Stage D until the expected Adder or Substracter is free. Second difference is th
13、at Memory Units will consume different cycle to complete a memory access. For a cache hit, it takes 1 cycle; for a cache miss , it takes 6 cycles; for a non-memory instruction , it takes 1 cycle to pass Stage M. And only one instruction can occupy the memory units, that is, if two memory instruction
14、s are entering the Stage M at the same time, the second instruction will wait the first instruction to complete before retrieve its own memory data. Third difference is that this architecture is 2-issue in-order pipeline processor. It means the fetch stage can fetch at most two instructions and all
15、the state registers between stages can also store at most two instructions states. The fetch units will fetch as many instructions as possible to fill the state registers between Stage F and Stage D. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 20 页 - - - - -
16、 - - - - 6 1)This problem is based on the code in figure, which will be executed on the processor described above. Assume in cycle 0, no instruction is executed, and in cycle 1, the first two instructions are fetched. Fill in the blanks. (Stage: F, D, E, M, W, finished or not fetched , undecidable v
17、alue marked with “-”) (10 )名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 20 页 - - - - - - - - - 7 2) The cache miss in the above code cause the CPU to waste several cycles, because the next instruction depends on the value fetched by the cache miss instruction
18、. So, we have a technical called “ code motion” which changes the order of instructions so that the time used to load the data from memory can be hidden by the instructions do not use memory and do not depends on the memory instruction. Use this technology to optimize the original code in figure to
19、get least execution time and write you code down. 3) How many cycles are saved from this optimization?_1_ 4) The last instruction in this optimized instruction flow will exit its write-backstage in Cycle_2_ 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 20 页 -
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年复旦计算机级春季期末考试试题A 2022 复旦 计算机 春季 期末考试 试题

限制150内