Download presentation

Presentation is loading. Please wait.

Published byMilo Maher Modified over 2 years ago

2
EECC201 Freshman Seminar Intro to Micro controller Dr. Ken Hsu WEEK 7 ADDITION, SUBTRACTION AND COMPARE OF BINARY NUMBERS Important: Irritant sounds may be heard during browsing. Better turn the volume off.

3
Binary numbersUnsigned decimalSigned DecimalHexadecimal 0000000 0001111 0010222 0011333 0100444 0101555 0110666 0111777 10008-88 10019-79 101010-6A 101111-5B 110012-4C 110113-3D 111014-2E 111115-1F

4
2’S COMPLEMENT 0100 Take 1’s complement 1011Add 1 to result 1 + 1100Get 2’s complement

5
To distinguish between two numbers with the same sign and two numbers with different signs in assembly language programming ANDNum1,#80H ANDNum2,#80H XORNum1,Num2 If result of XOR = 0 then Z flag is set to 1 and sign of both numbers is the same If result of XOR = 1 then Z flag is set to 0 and sign of the numbers are different. NOTE: 80H is called a MASK.

6
ADDITION Unsigned number addition (1)Numbers with same sign (a)Positive c 1111 111115 101111 1101026 CY flag set to 1 This means that more than 4 bit is needed to represent sum. Carry 1 bit + 1 XOR 1 = No overflow

7
ADDITION Signed number addition (1)Numbers with same sign (a)Negative 1111 1111-1 1011-5 11010-6 + 1 XOR 1 = No overflow CY flag set to 1 Ignore carry since there is no overflow

8
ADDITION Signed number addition (1)Numbers with different sign 1000-8 0111+7 01111-1 + CY flag set to 0

9
SUBTRACTION (COMPARE CMP) Unsigned number subtraction (1)Numbers with different sign 0011+3 1011-5 - Do 2’s Complement with second number and add with first number 01 0011 0101 010008 + Carry is 0. Make sign bit positive and thus equal to 8 and not -8. 0 XOR 1 = overflow

10
SUBTRACTION (COMPARE CMP) Unsigned number subtraction (1)Numbers with same sign (a)Positive 111115 101111 - Do 2’s Complement with second number and add with first number 1111 0101 101004 + Ignore carry since there is no overflow 1 XOR 1 = No overflow

11
SUBTRACTION (COMPARE CMP) Unsigned number subtraction (1)Numbers with same sign (a)Negative 1111-1 1011-5 - Do 2’s Complement with second number and add with first number 1111 0101 101004 + Ignore CY since there is no overflow 1 XOR 1 = No overflow

12
SUBTRACTION (COMPARE CMP) Unsigned number subtraction (1)Numbers with different sign 1000-8 0111+7 - Do 2’s Complement with second number and add with first number 10 1000 1001 10001-15 + Overflow. This means that more than 4 bit is needed to represent number. 1 XOR 0 = overflow

13
AVERAGE OF 2 NUMBERS NOTE: If the average of a positive number gives a fraction, round fraction down. 111115 101111 1111 11010 + 26Rotate right with carry by 1 bit. RORC 0110113 (1) Average of a positive number with a whole result

14
10008 01117 01111 + 15Rotate right with carry by 1 bit. RORC 01117.5 (1) Average of a positive number with a fractional result. AVERAGE OF 2 NUMBERS NOTE: If the average of a positive number gives a fraction, round fraction down. 7

15
1111-1 1011-5 11010 + -6Rotate right with carry by 1 bit. RORC 01101-3 (1) Average of a negative number with a whole result. AVERAGE OF 2 NUMBERS NOTE: If the average of a negative number gives a fraction, round fraction down. 1111

16
1000-8 0111+7 01111 + Rotate Right with carry by 1 bit. RORC 11111 -0.5 (1) Average of a negative number with a fractional result. AVERAGE OF 2 NUMBERS NOTE: If the average of a negative number gives a fraction, round fraction down. 11111 NOT1 CY

Similar presentations

OK

Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:

Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on tricks in mathematics Ppt on business environment nature concept and significance A ppt on loch ness monster pictures Ppt on history of china Ppt on rc coupled amplifier definition Ppt on infosys company profile Ppt on human eye and colourful world free download Ppt on different dances of india Ppt on beer lambert law practice Ppt online downloader and converter