1 / 14

Exercise Class

Exercise Class. f rom HW1 to HW3 Author: Zhou Yuwei ( 11302010067@fudan.edu.cn ). HARD RULES. Plagiarism: No Tolerance Forbid C&P and Typo from Network from classmates Punishment 0 point for all!!! Deadline : No Extension. Homework1. 4 C-programs

wren
Download Presentation

Exercise Class

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Exercise Class from HW1 to HW3 Author: Zhou Yuwei (11302010067@fudan.edu.cn )

  2. HARD RULES Plagiarism: No Tolerance Forbid C&P and Typo from Network from classmates Punishment 0 point for all!!! Deadline: No Extension

  3. Homework1 4 C-programs conversion

  4. Problem 2. Convert the numbers below in given base to target radix HW 1 • a) (100101001)2 (451) 8 • b) (C32148)16 (12788040)10 • c) (33195)10 (1000000110101011)2 • d) (7242)8 (EA2)16 • e) (5D76CB)16 (10111010111011011001011)2 • f) (101110101101)2 (BAD)16

  5. Homework2 Binary representation Equation Distinguish the machine order Bit operator

  6. Problem 1. You have a 6-bit machine using two’s complement arithmetic for signed integers. short integers are encoded using 3-bits. Right shifts of ints are arithmetic. Sign extension is performed whenever a short is casted to an int. And now you get definitions: int a = -29; short b = (short) a; int x = -21; short y = (short) x; unsignedint ux = x; short sp = -2; int p = sp; int q = -31; HW 2

  7. HW 2

  8. Problem 2 .It’s a pair of unsigned Multiplication, and each value is represented by 4-bits unsigned integer. Please solve the equation. 0011 * x + 0100 * y = 1001 …(a) 0100 * x + 0011 * y = 1000 … (b) HW 2 (b)-(a) 0001 * x + 1111 * y = 1111 ……(c) (c)*2 0010 * x + 1110 * y = 1110 ……(d) (c)+(d) 0011 * x + 1101 * y = 1101 ……(e) (e)-(a) 1001 * y = 0100 y = 0100 0011 * x = 1001 x = 0011 result: x = 0011, y = 0100

  9. Problem 3 ,write the codes to distinguish the “big endian” and “little endian” order HW 2 /* * hufflepuff – return 1 if little endian * else return 0 */ inthufflepuff(void) { inti= 1; char*p = (char *)&i; return*p; } p &i

  10. Homework3 Linux commands Signed and unsigned Memory operation

  11. Problem 2, Signed and unsigned HW 3 • B2T(X) —— binary to two’s-complement • B2U(X) —— binary to unsigned ——refer to chapter 2.2.2 & 2.2.3

  12. Problem 3, Byte OrderingSuppose a 16-bits little-endian machine has two interfaces WRITE and READ to access memory. WRITE(addr, value) stores the 16-bits valueinto memory with the start address addr; Read(addr) reads a byte data from the memory at address addr. Then see the following code pieces and give your answer in hexadecimal form for the READ operations.WRITE(0x4001, 0xF3E2)WRITE(0x4004,0xAB)WRITE(0x4003,0x12)Then,READ(0x4002): 0xF3 READ(0x4004): 0x0 HW 3

  13. Problem 3, Byte Ordering HW 3 WRITE(0x4001, 0xF3E2)WRITE(0x4004,0xAB)WRITE(0x4003,0x12)Then,READ(0x4002): 0xF3 READ(0x4004): 0x0 0xE2 0xF3 0x12 0x00 0xAB WRITE(0x4004, 0x00AB) WRITE(0x4003, 0x0012) WRITE(0x4001, 0xF3E2) 0x00

  14. THANKS …Any question,contact your TAs Author: Zhou Yuwei (11302010067@fudan.edu.cn )

More Related