Title: Intro
1Intro Data Rep 1
- CSCI130
- Instructor Dr. Imad Rahal
2General vs. Special Computers
- Computers can either be
- Special-purpose computers (Majority)
- Hardwired to do specific tasks only (usually one)
- i.e. execute one program
- Ubiquitous --- we interact with them almost daily
--- embedded - Examples?
- General-purpose computers
- Provide means to change their programs thus
becoming multi- or general-purpose machines - Include desktops, laptops/notebooks, servers,
etc - People tend to associate the word computer only
with them - Limit ourselves to the latter type only
3Analog and Digital Signals
- Signals are the basis of all communications
- Any communication that encodes a message is a
signal - Lights on traffic signals (G, R, Y), grade
(performance), etc - Phones Computers (electric signals)
- A piece of data moving from place to another that
calls for action
4Analog and Digital Signals
- Analog signals take on a continuous set of values
- Grades
- Between any two analog signal values points, you
can always find a 3rd value no matter what! - Infinite possibilities
- Instruments for measurement usually give
estimates since any value is possible - Thermometer
- Weight scale
5Analog and Digital Signals
- Digital signals take on a discrete/finite set of
values - Traffic signals
- R, Y, and G
- Letter grades
- Between any two adjacent digital signal values
points, you cant find a 3rd value - Finite possibilities
- We can measure the exact value cannot have
fractions - What makes them attractive for use in computers?
- Voltage on ? 1 (0 otherwise)
- Early attempts to use decimal system 0 V ? 0, 1
V ? 1, 2 V ? 2, etc - 0,1.3 V ? 0 while gt1.7 V ?1 (error in the
middle) - We have bits
- hence the name digital computers
6Overview of Computer Design
- Intro to PC hardware
- http//computer.howstuffworks.com/pc.htm
- Computers composed of 4 main components
- CPU (brain)
- Main Memory (STM)
- I/O devices (Mouth, Eyes Ears)
- Auxiliary/secondary storage (LTM)
- theoretically not needed for a functional
computer
7Overview of Computer Design
- Data (e.g. math equation) is input through some
input device - Keyboard, mouse, etc
- Stored in main memory
- Think of it as our short term memory where we
keep all things we are thinking of right now - Stores data before and after CPU processes it
- Processed by CPU and result is stored again in
main memory - CPU only processes data in main memory
- Output to the user through some output device
- Screen, printer, etc
- Main memory is emptied when we turn off computer,
if we want to save data for some period of time - Transferred to some secondary/auxiliary storage
- Hard disk, CD, DVD, floppy disk
- Analogous to our long term memory
8Overview of Computer Design
- Memory is divided into locations/registers/words
- Each holds a fixed amount of data
- Numbers, characters
- Each has an address used to access its contents
- P.O. boxes number is address and the box is the
register - Each word is made of a fixed number of memory
units called bits (Binary digITs) each having one
of two states - 1 means electric current is strong
- 0 no/weak electric current
- A word is usually 8 bits (1 byte)
- Data and addresses are represented in binary
- Memory sizes are measured in bytes in groups of
- 1024 103(or 1 KB) or 1,048,576106 (or 1 MB) or
109 (or 1 GB)
9Overview of Computer Design
- The number system that we use daily is called the
decimal system - How many different digits?
- Why?
- In computers, we have only two possibilities (0
or 1) ? we can use the binary system - 104103102101100 becomes 2423222120
...168421 - 37 3x101 7x100
- 100101 1x25 0x24 0x23 1x22 0x21 1x20
10Binary to Decimal and Vice Versa
- Binary ? decimal
- 1100 10012 ?
- 1001 10012 ?
- 0010 10012 ?
- Decimal ? Binary
- 1410 ?
- 910 ?
- 129 10 ?
- This is how we can represent (positive) numbers
11Hexadecimal
- Binary is not very convenient for humans to use
- 1001000010010010
- Instead we use the hexadecimal system (base 16)
- Group every four binary digits into a single
hexadecimal value - In base 10, we have 10 digits (0-9)
- In base 2, we have 2 digits (0-1)
- What about base 16 (hexadecimal)?
- 0, 1, 2, 3.. 9, A, B, C, D, E, and F
- 163162161160 4096256161
- A1F A162 1161 F160 101616
116 15 259110
12Binary to Hexa and Vice Versa
- From binary ? hexadecimal group 4 bits at a time
as one hex. digit - 10011111100100102 1001 1111 1001 0010 9F9216
- 110010012 ?
- 100110012 ?
- Group starting from left or right?
- 01010012 ?
- From hexadecimal ? binary
- 9A9216 1001 1010 1001 0010 2
- A416 ?
- 916 ?
- BC16 ?
13Unsigned Integers
- Range of values for 8-bit unsigned?
- What if we want to represent higher values? Say
up to 300? Up to 600? - How many bytes (or memory locations) would that
require?
14Signed Integers
- Easy to store positive numbers
- Negative numbers?
- Signed-magnitude representation
- Use the last (leftmost) bit as the sign bit
- 1 for negative and 0 for positive
- 1000 0011 ?
- 0100 0011 ?
- 1000 0000 ?
- 0000 0000 ?
15Signed Integers
- Problems
- Two values for zero!
- Problems for comparisons
- Addition wont work well
- Adding in binary?
- 1000 0011 (-3)
- 0100 0011 (67)
- -----------------1100 0110 (-70)
- Obviously, we need something better
- ? 2s complement representation
162s Complement Representation
- Used by almost all computers today
- All places hold the value they would in binary
except for the leftmost place which is negative - 8 bit integer -128 64 32 16 8 4 2 1
- Range????
- If last bit
- is 0, then positive ? looks just as before
- is 1, then negative ?add values for first 7
digits and then subtract 128 - 1000 1101 148-128 -115
- What if I wanted to represent numbers up to -200?
172s Complement Representation
- Converting from decimal to 2s complement
- For positive numbers find the binary
representation - For negative numbers
- Find the binary representation for its positive
equivalent - Flip all bits
- Add a 1
- 43
- 43 0010 1011
- -43
- 43 0010 1011 ? 1101 0100 ? 1101 0101
- 1101 0101 -128641641 -43
- We can use the usual laws of binary addition
182s Complement Representation
- 125 - 19 106
- 0111 1101 1110 1101 ------------- 0110 1010
106 ! - What happened to the one that we carried at the
end? - Got lost but still we got the right answer!
- We carried into and carried out of the leftmost
column - Try 12565 and -125-65
192s Complement Representation
- 12565 190
- 0111 11010100 0001 -------------1011 1110 -
66 !!! - We only carried into ? overflow
- Number too big to fit in 8 bits since
range-128,127 - 12565 190 gt 127
202s Complement Representation
- -125-65 -190
- 1000 00101011 1111 -------------0100 0001 65
!!! - We only carried out of ? underflow
- -190 lt -127
- Solution
- use larger registers (more than 8 bits)
- Very large positive and very small negative we
might still have a problem ? combine two
registers (double precision)