代写CSC 252 Computer Organization Midterm Exam代做回归

Midterm Exam

CSC 252

7 March 2025

Problem 0: Warm-up (2 Points)

What’s the most surprising thing you’ve learned so far?

Problem 1: Fixed-Point Arithmetics (12 points)

Part a) (2 points) Represent decimal number 31 in the hexadecimal form.

Part b) (4 points) Represent octal (base 8) number 73 in the decimal form. and binary form.

Part c) (6 points) Consider two signed binary numbers A = 10101 and B = 11001, both are represented using two’s complement representation. Do the math below.

(2 points) What’s the result of !A || B (! is NOT and || is OR)?

(2 points) What’s the result of A^B (^ is XOR)?

(2 points) How to write A in base 7?

Problem 2: Floating-Point Arithmetics (21 points)

Part a) (4 points)

(2 points) Write 10 8/7 using the normalized scientific notation.

(2 points) Write 32 16/5 using the normalized scientific notation.

Part b) (8 points) The engineering team is designing a new 12 bit floating point standard. The format follows the principles of the IEEE-style. floating point representation we discussed in the class. The engineering team is considering two possible standard:

● Standard A: 6 fraction bits

● Standard B: 9 fraction bits

(4 points) What are the biases for Standard A and Standard B?

(4 points) Given the requirement that the smallest gap between two representable numbers is at most 224/1, which of the two options meets the requirement? Show your work.

Part c) (9 points) Now the engineering team wants to design another 12-bit floating point representation. They want the representation to be able to precisely represent -100 and 100.

(5 points) What is the representation that meets this requirement while having the smallest gap between two consecutive, representable numbers?

(4 points) What is the smallest positive number that can be precisely represented in this format?

Problem 3: Logic Design (27 points)

Part a) (4 points)

(2 points) What is the result of a bitwise XOR operation between 01100 and 00111?

(2 points) What is the result of a bitwise NAND operation between 01000 and 01010?

Part b) (13 points)

(8 points) Given the circuit above, complete the following truth table. Additional columns are provided to show your partial work (for partial credit).

(2 points) Briefly describe the behaviour of the circuit above in words.

(3 points) Using the same circuit, it is possible to implement the equivalent of an AND gate. Complete the following table by assigning each of the three input wires to variables A, B or constants 0, 1 such that UTPUT = A AND B.

Part c) (8 points)

Consider the circuit below, which consists of N+1 XOR gates cascaded with a single NOT gate placed immediately before the (N+1) th XOR gate.

(6 points) What is the output of the circuit for the following values of N? You can write the output as a function of A.

N = 50

N = 63

(4 points) Draw a simpler circuit that will achieve the same output as the circuit above.

Problem 4: Assembly Programming (28 points)

Conventions:

1. For this section, the assembly shown uses the AT&T/GAS syntax opcode src, dst for instructions with two arguments where src is the source argument and dst is the destination argument. For example, this means that mov a, b moves the value a into b.

2. All C code is compiled on a 64-bit machine, where arrays grow toward higher addresses.

3. We use the x86 calling convention. That is, for functions that take two arguments, the first argument is stored in %edi (%rdi) and the second is stored in %esi (%rsi) at the time the function is called; the return value of a function is stored in %eax (%rax) at the time the function returns.

4. We use the Little Endian byte order when storing multi-byte variables in memory.

Part a) (10 points)

Consider the following function `fibonacci` and the assembly code that implements the C function.

int fibonacci(int n) { if (n <= 1) return n; return fibonacci(n - 1) + fibonacci(n - 2); } 0000000000401106 : 401106: push %rbp 401107: mov %rsp,%rbp 40110a: push %rbx 40110b: sub $0x18,%rsp 40110f: mov %_A_, -0x14(%rbp) 401112: _B_ $0x1, -0x14(%rbp) 401116: _C_ 40111d 401118: mov -0x14(%rbp), %eax 40111b: jmp 40113b 40111d: mov -0x14(%rbp), %eax 401120: sub $0x1, %eax 401123: mov %eax, %edi 401125: call 401106 40112a: mov %eax, %ebx 40112c: mov _D_(%rbp), %eax 40112f: ___________E___________ 401132: mov %eax, %edi 401134: call 401106 401139: add %ebx, %eax 40113b: mov -0x8(%rbp), %rbx 40113f: leave 401140: ret

Your Task: Fill in the missing instructions A, B, C, D, and E to complete the assembly code.

(2 points) A:

(2 points) B:

(2 points) C:

(2 points) D:

(2 points) E:

Part b) (18 points)

Consider the following unknown x86_64 assembly function: 000055555555516d : 0x55555555516d: mov $0x1,%eax 0x555555555172: cmp $0x1,%rsi 0x555555555176: jbe 0x5555555551aa 0x555555555178: mov %rdi,%rdx 0x55555555517b: lea -0x4(%rdi,%rsi,4),%r8 0x555555555180: mov $0x1,%r9d 0x555555555186: mov $0x0,%edi 0x55555555518b: jmp 0x555555555199 0x55555555518d: mov %edi,%r9d 0x555555555190: add $0x4,%rdx 0x555555555194: cmp %r8,%rdx 0x555555555197: je 0x5555555551a7 0x555555555199: mov 0x4(%rdx),%esi 0x55555555519c: mov (%rdx),%ecx 0x55555555519e: cmp %ecx,%esi 0x5555555551a0: jg 0x55555555518d 0x5555555551a2: cmovl %edi,%eax 0x5555555551a5: jmp 0x555555555190 0x5555555551a7: or %r9d,%eax 0x5555555551aa: ret

At the start of the function, the first argument is set to a pointer to the following integer array: [1, 1, 3, 2]. The second argument is set to 0x4.

The cmovl instruction conditionally moves a value from the source register to the destination register only if the sign flag is not equal to the overflow flag.

(3 points) Which line of assembly sets the condition codes for the cmovl operation on line 0x555555551a2?

(3 points) How many times is the jump at 0x5555555551a5 taken?:

(3 points) How many times is the jump at 0x5555555551a0 taken?

(3 points) Assume that the following line of assembly was executed immediately after the first execution of the instruction located at 0x55555555517b:

mov (%r8), %r9

What would the value in r9 be after this instruction?

(3 points) What is the meaning of the second argument of the function?

(3 points) Describe the function. What does it do?





热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图