HW1_S - 0306-250 Assembly Language Programming Fall 2009...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0306-250 Assembly Language Programming Fall 2009 Homework One Solution 1. Convert each of the following decimal integers into its natural binary equivalent. a. 13 Use division-remainder method. ¸ 2: Quotient Remainder 6 1 LSB 3 0 1 1 0 1 MSB Therefore, 13 in binary is 1101. (The last remainder is the most significant bit, and the first remainder is the least significant bit). Remember that this process works for all radices—not just binary. b. 44 Again, use division-remainder method. ¸ 2: Quotient Remainder 22 0 LSB 11 0 5 1 2 1 1 0 0 1 MSB Therefore, 44 in binary is 101100. 2. Convert the following natural binary integer into its decimal equivalent: 1010110. Add the decimal contribution from each binary digit. 10101102 = 1 ´ 26 + 0 ´ 25 + 1 ´ 24 + 0 ´ 23 + 1 ´ 22 + 1 ´ 21 + 0 ´ 20 10101102 = 64 + 16 + 0 + 4 + 2 + 0 10101102 = 8610 Alternatively, use the double-dabble method to convert to decimal. 1 x2 2 0 +0 = 2 x2 4 1 +1=5 x2 10 0 +0 = 10 x2 20 1 1 +1 = 21 x2 42 0 +1 = 43 x2 86 +0 = 86 Page 1 of 3 0306-250 20091 Homework One Solution Page 2 of 3 3. Perform the following binary addition: 10100 + 00111. 1 % 10100 +% 00111 %11011 4. Perform the following hexadecimal addition: $66 + $75. $6 6 +$ 7 5 $DB 5. Suppose that P = 123416, and Q = ABEF16. In 16-bit hexadecimal arithmetic, calculate the value of the following expressions. a. P + Q 11 $1 2 3 4 +$ ABEF $BE2 3 b. P - Q 1 1 1 0121 $1 2 3 4 -$ ABEF $6 6 4 5 OR $ 1234 +$ 5411 $6645 6. Perform the following decimal subtraction operations in 8-bit two’s complement arithmetic. In addition, indicate whether or not arithmetic overflow occurs. a. (+25) - (-11) First the numbers must be converted to 8-bit two’s complement binary. The first step is to determine the 8-bit binary equivalent for the magnitude of the numbers: 2510 = 0001 10012 1110 = 0000 10112 Getting the 8-bit 2’s complement for -11 would require taking the two’s complement of the 8-bit magnitude 5; however, since -5 is to subtract from 20, the two’s complement of -11 must be added to 20. The 8-bit two’s complement of -11 is the same as the 8-bit magnitude 11. 1 11 0 001 1001 +0 000 1011 0010 0100 There is no overflow because the two operands and the result all have the same sign (positive). There was potential for overflow because a negative number was being subtracted from a positive number. 0306-250 20091 Homework One Solution Page 3 of 3 b. (-62) - (+49) First the numbers must be converted to two’s complement binary. The first step is to determine the 8-bit binary equivalent for the magnitude of the numbers: 6210 = 0011 11102 4910 = 0011 00012 Next, calculate the two’s complement of the values. 0 011 1110 (natural binary value) 0011 0001 1 100 0001 (1’s complement) 1100 1110 (1) +0 000 0001 +0000 0001 1100 0010 (2’s complement)0 1100 1111 Finally, the subtraction can be performed by adding -62 to -49: 11 1 11 1 100 0010 +1 100 1111 1001 0001 There is no overflow because the two operands and the result all have the same sign (negative). There was potential for overflow because a positive number was being subtracted from a negative number. ...
View Full Document

This note was uploaded on 05/06/2010 for the course EECC 0306-250 taught by Professor Roymelton during the Fall '10 term at RIT.

Ask a homework question - tutors are online