SWEN-340: Data Representation - Homework 1 Instructions: 1. Assume all values are stored in the smallest variable size necessary for the value to fit. (I.E. 8 bit values are stored in a char and 16 bit values are stored in a short). (Signed value uses 2's complement format). 2. Provide hexadecimal values in 0x... format (C language format) 3. Edit this text file and record your answer. 4. Also for every answer show the manual steps required to arrive at you answer by editing this text file. 5. Submit your edited text file to the MyCourses assignment folder "Homework 1". All submissions MUST be text files. 6. All questions are worth one point Questions: 1. Convert decimal 95 to hexadecimal. Answer: Reasoning: 2. Convert 0x1CD to unsigned decimal. (Hint: Convert it to binary first!) Answer: Reasoning: 3. What is the value of binary 10101011 in decimal if this is a negative number? Decimal Answer: Reasoning: 4. What is the value of binary 111001111 in decimal if this is an unsigned number? Decimal Answer: Reasoning: 5. Add 0x8BCD and 0x02E6 (assume unsigned numbers): Hexadecimal Answer: Reasoning: 6. Add 8 bit binary integers 10101111 and 11011011 Hexadecimal Answer: Reasoning: 7. How many bits are in each of the following data types? a. Byte Answer: b. Word Answer: c. Doubleword Answer: d. Quadword Answer: e. Nibble Answer: (Questions 8-10 deal with the following registers. This register is taken from ST Microelectronics' reference manual for their STM8S and STM8AF series microcontrollers, for those who are curious) Assume you have an embedded device with the following register: Port X Output Data Register (Px_ODR) Address Offset: 0x00 Reset Value: 0x00 7 6 5 4 3 2 1 0 ODR7 | ODR6 | ODR5 | ODR4 | ODR3 | ODR2 | ODR1 | ODR0 Suppose you are given C code that defines the register as follows (assume P1_BASE_ADDR is defined elsewhere): uint8_t *p1_odr = (uint8_t *) P1_BASE_ADDR; 8. Suppose current value of the register is 0xC1. You are asked to set ONLY the ODR2 bit in P1_ODR to 1. What will be new register value? Hexadecimal Answer: Reasoning: 9. Suppose current value of the register is 0xC1. You are asked to set ODR2 & ODR5 bits in P1_ODR to 1 AND clear 0DR0 bit (i.e. set to zero). What will be new register value? Hexadecimal Answer: Reasoning: = 10. Write C code that sets ONLY the ODR2 bit in P1_ODR to 1 Answer: