# Computer Organisation Lab # LAB7 ## Question-1 Convert 0.1<sub>10</sub> to binary. ## Solution-1 0.1 * 2 = 0.2<br /> 0.2 * 2 = 0.4<br /> 0.4 * 2 = 0.8<br /> 0.8 * 2 = 1.6<br /> 0.6 * 2 = 1.2<br /> 0.2 * 2 = 0.4<br /> 0.4 * 2 = 0.8<br /> 0.8 * 2 = 1.6<br /> 0.6 * 2 = 1.2<br /> 0.1's binary representation is 0.0001100110011001011 ## Question-2 Convert 0.1<sub>10</sub> to binary using IEEE 754 standard. ## Solution-2 Binary form is 0.0001100110011001011. For IEEE-754 , converting in the scientific form leads to 1.1001100110001011 * 2<sup>-4</sup> ## Question-3 Convert 0.2<sub>10</sub> to binary using IEEE 754 standard and then convert it back to decimal. ## Solution-3 0.2 is twice of 0.1, so shifting the digits of IEEE754 format of 0.1 will lead to that of 0.2.<br /> Required IEEE754 format of 0.2<sub>10</sub> is :&nbsp; 1.1001100110001011 * 2<sup>-3</sup> ## Question-4 Design a representation for floating point numbers. Perform addition of two floating point numbers, and store the result in your defined representation. For example, your design should be able to add 5.391 with 3.012, and store the result 8.403. You can use multiple register-s/memory locations to store a single floating point number i.e. you might use two registers to store a single floating point number, one for before the decimal and one for after the decimal point. ## Solution-4 - Assuming single precisioon floating point numbers, which typically uses 32 bits for complete representation. - Consider the representation of floating popint numbers by two registers, one for the integral part and other for the decimal end. - Also, one bit will be assigned as the sign bit and thus the following operations hold &nbsp;: - Consider 5.391 + 8.012:<br /> &nbsp; &nbsp; &nbsp; 5 = **0** 0000 0000 0000 0101<br /> &nbsp; &nbsp; &nbsp; .0391 = 0110 0100 0001 1000<br /> &nbsp; &nbsp; &nbsp; 3 = **0** 0000 0000 0000 0011<br /> &nbsp; &nbsp; &nbsp; .012 = 0000 0011 0001 0010<br /> Thus, 5+3=8<br/> &nbsp; &nbsp; &nbsp; 5+3 = **0** 0000 0000 0000 1000<br /> Similarly, 0.391 + 0.012: <br /> &nbsp; &nbsp; &nbsp; 0.391+0.012 = 0110 0111 0011 1010<br /> Thus Final sum :<br /> &nbsp; &nbsp; &nbsp;**0** 0000 0000 0000 1000 . 0110 0111 0011 1010 ## Question-5 Assume two floating point numbers in IEEE 754 format are stored in memory. Write assembly code to add these two numbers and store the result in a third memory location. ## Solution-5 Consider the above design for storing the floating point number in IEEE 754 format , thus a memory register with first 16 bits of integers and last 16 bits. ```assembly= .text lw a0 0(f1) lw a1 0(f2) //function to add a0 a1 in a2 //store a2 ```