these are all different interpretations of the same bit ...jmconrad/ecgr2181-2008... · to add...

26
These are all different interpretations of the same bit string. 1

Upload: others

Post on 29-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

These are all different interpretations of the same bit string.

1

Page 2: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

Problems with non-positional: (1) large numbers require lots of bits, (2) arithmetic is not easy.

Positional: compact, simple arithmetic.

2

Page 3: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

3

Page 4: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

100110

4

Page 5: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

5

Page 6: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

To add sign-magnitude numbers:

(1) if signs are the same, just add magnitudes and preserve sign (ignoring overflow for now)

(2) if signs are different, subtract smaller magnitude from larger and set sign according to larger

To add one’s complement:

Add normally, then increment by carry-out.

6

Page 7: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

Common mistake: I say, “What is the two’s complement representation of +5?”

Student takes the two’s complement of +5 (00101) and tells me “11011”.

7

Page 8: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

8

Page 9: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

9

Page 10: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

Memorize this table!

10

Page 11: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

11

Page 12: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

12

Page 13: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

13

Page 14: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

14

Page 15: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

15

Page 16: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

16

Page 17: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

17

Page 18: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

18

Page 19: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

Could also subtract, with borrows, from left to right.

This way, they only have to learn addition and they're prepared for LC-2, which doesn't have a subtract instruction.

19

Page 20: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

11001000

11110010 = -14

20

Page 21: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

21

Page 22: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

22

Page 23: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

Memorize this table!

23

Page 24: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

24

Page 25: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

25

Page 26: These are all different interpretations of the same bit ...jmconrad/ECGR2181-2008... · To add sign-magnitude numbers: (1) if signs are the same, just add magnitudes and preserve

26