Computer Organization: Microprocessors, Microcontrollers, and Number Systems, Study notes of Computer Science

A handout for a university course, ecs 50, on computer organization. It covers the basics of computers, including the history of computers, desktop computers, general purpose microprocessors and microcontrollers, and number systems. The document also includes information on course objectives, lecture format, homework assignments, and exam dates.

Typology: Study notes

Pre 2010

Uploaded on 07/31/2009

koofers-user-0xf
koofers-user-0xf 🇺🇸

10 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
ECS 50: Computer Organization and
ECS 50: Computer Organization and
Machine
Machine-
-Dependent Programming
Dependent Programming
Spring 2008
Spring 2008
Shoukat Ali
Introduction and Review
Introduction and Review
Handout 1
22
My Contact Information
My Contact Information
Name: Dr. Shoukat Ali (pronounced Shaw Cut Uh Li)
Phone: 916-934-9956
Office:
Office Hours: 7:30—8:30 PM Thursday
33
What I Plan To Do Today
What I Plan To Do Today
explain why this course is very important
Some history of computers
talk about some administrative matters
44
What This Course Is About
What This Course Is About
Introduction to Processor Architecture
Introduction to instruction sets, addressing modes and register
sets, and their variation from one machine to another.
The Role of System Software in Producing an Abstract Machine
Distinction between the roles of hardware and software. The
use of compilers and operating systems in providing
abstractions and machine independence to the programmer
Machine Capability and Speed
Transportability/nontransportability of programs on different
machines, and under different operating systems and
compilers.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Computer Organization: Microprocessors, Microcontrollers, and Number Systems and more Study notes Computer Science in PDF only on Docsity!

ECS 50: Computer Organization andECS 50: Computer Organization and

MachineMachine-

-Dependent Programming

Dependent Programming

Spring 2008Spring 2008

Shoukat Ali

[email protected]

Introduction and Review Introduction and Review

Handout 1

22

My Contact Information^ My Contact Information

„

Name: Dr. Shoukat Ali (pronounced Shaw Cut Uh Li)

„

Email: [email protected]

„

Phone: 916-934-

„

Office:

„

Office Hours: 7:30—8:30 PM Thursday

33

What I Plan To Do TodayWhat I Plan To Do Today

„

explain why this course is very important

„

Some history of computers

„

talk about some administrative matters

44

What This Course Is AboutWhat This Course Is About

„

Introduction to Processor Architecture^ „

Introduction to instruction sets, addressing modes and registersets, and their variation from one machine to another.

„

The Role of System Software in Producing an Abstract Machine^ „

Distinction between the roles of hardware and software. Theuse of compilers and operating systems in providingabstractions and machine independence to the programmer

„

Machine Capability and Speed^ „

Transportability/nontransportability of programs on differentmachines, and under different operating systems andcompilers.

55

Course Objectives Course Objectives

„

understand terms computer, microprocessor, and microcontroller

„

understand the organization of a simple microprocessor

„

understand the use of an instruction set

66

Definition: Computer Definition: Computer

„

computer: a device that stores and retrieves data and sequentiallyexecutes a stored program

„

what is the distinction between program and data?

77

A Short History of ComputersA Short History of Computers

„

1960s – era of large mainframes, machines costing millions ofdollars, stored in computer rooms, and run by multiple operators^ „

typical applications: business data processing and large-scalescientific computing

„

1970s – era of minicomputers, smaller-sized machines mostlyused by multiple users in a “time share” fashion^ „

each user would access the machine through a dumb terminal

88

More: A Short History of ComputersMore: A Short History of Computers

„

1980s – era of desktop computers based on microprocessors^ „

personal computers and workstations „

individually owned, no time-sharing „

led to servers, computers that provided larger-scale servicessuch as reliable, longterm file storage (file servers) and morecomputing power (compute servers)

„

1980s – also saw microcontrollers aka embedded computers^ „

computers lodged in other devices where the presence of thecomputers is not immediately obvious „

these computers interface with real world and turn somedevices on and off and monitor conditions

„

1990s – era of the Internet and the World Wide Web

1313

Microcontrollers Are Embedded In These Home Items Microcontrollers Are Embedded In These Home Items

1414

More Microcontroller Applications^ More Microcontroller Applications

„

Consumer electronics

„

Industrial Controls^ „

Labeling machines „

Coin Acceptors

„

Aerospace^ „

Flight control systems „

Navigation systems

1515

Administrative MattersAdministrative Matters

1616

Do Not Jeopardize Your Success In ECS50Do Not Jeopardize Your Success In ECS

„

every one of you can do well on this course

„

do not jeopardize your success by:^ „

skipping classes „

failing to do the homework „

procrastinating „

expecting to “learn by osmosis” „

being dishonest in any way

Slide adapted from Dr. David Meyer.

1717

Bad Ways of Learning Design Bad Ways of Learning Design

„

relying solely on lectures on how to solve course problems

„

only reading about how to solve course problems

„

watching someone else solve the course problem, or reading theirsolution

„

you will forget most of what you hear, but will remember most ofwhat you put into practice

Slide adapted from Dr. David Meyer.

1818

Course Prerequisites^ Course Prerequisites

„

ECS 40

1919

TextbookTextbook

„

Principles of Computer Systems^ „

Gerald M. Karam and John C. Bryant „

Prentice Hall, 1992.

2020

Typical Lecture FormatTypical Lecture Format

„

5 minute review of the previous lecture

„

35 minute lecture

„

5 minute break (water, stretch) – not always given

„

35 minute lecture

„

I will come to class early and stay after to answer questions

„

in most lectures, slides will have to be filled in by students in class

2525

Academic Honesty^ Academic Honesty

„

Do not take someone else's work and present it as your own.

„

I encourage you to study in groups. Discussions on HW arewelcome. However, you must not take someone else’s work andpresent it as your own.

„

If in doubt, please check with me.

„

Any instances of cheating will be reported to universityadministrative officials for further action and possible suspensionor expulsion from the University

2626

Feedback Feedback

„

Will take surveys from time to time

„

Your comments are welcome throughout the semester

2727

Number Systems^ Number Systems

2828

SignalsSignals

2929

Basic Electronic Signal Concepts^ Basic Electronic Signal Concepts

„

signal^ „

a voltage or a current that conveys information

„

so how many pieces of information are in a signal?^ „

depends on how you interpret the signal!!

„

analog signal^ „

signal changes in a range, and every value of the signalrepresents a different piece of information

„

binary digital signal^ „

signal still changes in a range, but we interpret only two piecesof information

„

0 or 1, false or true, no or yes,negated or asserted, bad or good

3030

So What Is A Digital Signal Like? So What Is A Digital Signal Like?

„

the way a signal is interpreted can be different^ „

the digital way of interpreting a signal „

the analog way of interpreting a signal

5 volts 0 volts

any voltage in the red rangeis interpreted as logic 1any voltage in the gray rangecannot be interpreted; invalidany voltage in the green rangeis interpreted as logic 0

3131

Why Are We Talking About Number Systems?Why Are We Talking About Number Systems?

„

Information is represented using “bit patterns” in computers^ „

„

Why?

1 0 1 1

3232

Different Types of NumbersDifferent Types of Numbers

„

integers^ „

„

real numbers^ „

„

„

questions:^ „

how do we represent integers and real numbers in a binarydigital system? „

how should we implement arithmetic operations like add,subtract, multiply, and divide?

3737

Converting From Decimal to Base N Converting From Decimal to Base N

„

analogous to the method for converting from decimal to binary^ „

repeatedly divide by N until quotient is zero „

save all remainders „

the first remainder is the least significant digit, and the lastremainder is the most significant digit

3838

Converting From Decimal to Base N Converting From Decimal to Base N

„

Say we want to know how to represent 257 in base 16 using 4digits in base 16^ „

We want to know d

d 3

d 2

d 1

0

such that

d

3

  • d

2

  • d

1

  • d

0

„

From previous slide we know that d

d 3

d 2

d 1

0

is 0101

„

In general representing X in base N using y digits requires solvingd

y-

*N

y-

  • d

y-

*N

y-

  • … + d

2

*N

2

  • d

*N 1

1

  • d

0

= X,

„

each digit is less than N and larger than 0

„

LHS divided by N = (d

y-

*N

y-

  • d

y-

*N

y-

  • … + d

1

) + d

/N 0

„

the quotient is d

y-

*N

y-

  • d

y-

*N

y-

  • … + d

1

„

the remainder is d

0

„

Notation: remainder of X divided by N = X mod N

„

Notation: quotient of X divided by N = X/N

3939

Converting From Decimal to Base NConverting From Decimal to Base N

„

How do we determine d

„

(d

y-

*N

y-

  • d

y-

*N

y-

  • … + d

*N + d 2

) = X/N 1

„

LHS divided by N results in:^ „

Quotient of d

y-

*N

y-

  • d

y-

*N

y-

  • … d

2

„

Remainder is d

1

4040

Representing Negative NumbersRepresenting Negative Numbers

„

three methods exist^ „

signed-magnitude representation „

radix complement representation

„

method 1 is most intuitive but least easy to use foraddition/subtraction^ „

will see why

„

the so-called “complement representations” are a better suited foraddition/subtraction^ „

will see why

4141

Signed- Signed

-Magnitude (SM) Representation

Magnitude (SM) Representation

„

use a symbol to specify whether the magnitude is positive ornegative

„

for decimal numbers, positive/negative are indicated by + and –signs^ „

„

for binary numbers, positive/negative are indicated by using anextra bit position (0 for positive, 1 for negative)^ „

2

10

2

10

„

2

10

2

10

„

2

10

2

10

4242

Problem With Using SM Representation^ Problem With Using SM Representation

„

how to add two numbers represented in SM?^ „

examine the sign of the addends „

if both have the same sign, just add and use the sign of theaddends as the sign of the sum „

if the addends have different signs,

„^

determine which number has the larger magnitude „^

subtract the smaller magnitude number from the larger magnitudenumber „^

append the sign of the larger magnitude number with thedifference

„

so what? what is the problem with the above?^ „

There are two strings that represent 0 „

“complement representation” of negative numbers does nothave this problem!!

4343

Complement Number (CN) RepresentationComplement Number (CN) Representation

„

in SM, a positive number and its negation differ only in sign (or asign bit for binary numbers)

„

in CN, the negative of a number is equal to the so-called“complement” of the number

„

radix complement of an n digit number D is given bynr^

  • D, where r is the radix (or base of the number)

„

10’s complement of 49 is 10

2

„

i.e., negative of 49 in 10’s complement is 51

4444

More on Radix Complement RepresentationMore on Radix Complement Representation

of Negative Numbersof Negative Numbers

„

for binary numbers, radix complement is called “two’scomplement”^ „

the complement equals r

n

– D = 2

n^

– D

„

alternative convenient way of finding 2’s complement^ „

write the number in the binary form „

flip all bits „

add one

„^

drop any carry out of MSB

„

8-bit examples

100000000

2

11111111

2

0

10

= 00000000

2

11111111

2

11101111

2

11111110

2

11101110

2

1

10

= 00000001

2

17

10

= 00010001

2

flip bits

add 1

fact: a –ve number will always have a 1 in the MSB

4949

Encoding A Number In 2’^ Encoding A Number In 2

’s Compliment Binarys Compliment Binary

„

how do we encode a negative number, say -7, using 4-bit 2’scomplement binary?^ „

many methods exist „

one neat trick

„

encode the magnitude in simple binary

„

7 = 0111

„

flip the bits

„

1000

„

add 1

„

1000 + 0001 = 1001

„

drop any carry out of leftmost bit „

check to make sure you got it right

„

1001 = 1x (-2)

(^3)

  • 0x

2

  • 0x

1

  • 1x

0

= -8 + 0 + 0 + 1 = -

5050

Is The Result Of An Addition Valid?^ Is The Result Of An Addition Valid?

„

Computers do all their processing in fixed size cells called“registers”^ „

Intel 8086, 80186, 80286 have 16 bit wide registers „

Intel 80386, i486, Pentium, Core have 32 bit wide registers „

Intel Itanium has 64 bit wide registers

„

Unless the result of an addition is too large to be accommodatedin the register where the result is deposited, the addition is valid

„

How do we know if it is invalid?

5151

Comparing Unsigned Binary and 2Comparing Unsigned Binary and 2’

’s Complements Complement

0

0

0000 0000

1

1

0000 0001

2

2

0000 0010

….

….

…………

126

126

0111 1110

127

127

0111 1111

128

1000 0000

129

1000 0001

…………

254

1111 1110

255

1111 1111

Value in 2’scomplement

Value inunsigned binary

Bit string

5252

Overflow in Unsigned BinaryOverflow in Unsigned Binary

„

Assume an 8-bit long string

„

If the sum is more than 255, we say that the addition hasoverflowed

„

Can be detected in the hardware by checking if there is a carry outof the most significant bit (MSB)

„

Usually computers store the value of the carry that comes out ofthe MSB in a special 1-bit cell called the “carry flag”^ „

After an unsigned addition, the carry flag is checked „

If it is 1, the addition has overflowed

= 129

= 1000 0001

  • 2

  • 0000 0010

127

0111 1111

= 127

= 0111 1111

  • 128

  • 1000 0000

255

1111 1111

= 255

= 1111 1111

  • 1000 0000

127

0111 1111

5353

Overflow in 2’ Overflow in 2

’s Compliment Binarys Compliment Binary

„

Assume an 8-bit long string

„

If the sum is more than 127 or smaller than -128, the addition hasoverflowed

„

Can only occur if the sign bits of the numbers being added are thesame

„

Can be detected in the hardware by checking if the sign bit of theresult is not the same as that of numbers being added

„

In computers, there is a special 1-bit cell called the “overflow flag”that is set by hardware to 1 for all cases like

= -

= 1000 0001

  • 2

  • 0000 0010

127

0111 1111

= 127

= 0111 1111

  • 128
  • 1000 0000

1111 1111

= 0

= 0000 0000

  • 127
  • 1000 0001

127

0111 1111

5454

Hexadecimal Numbers: Base 16^ Hexadecimal Numbers: Base 16

„

hexadecimal numbers can use 16 digits^ „

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

„

A

Î

10, B

Î

11, C

Î

„

D

Î

13, E

Î

14, F

Î

„

what is the value of B2FD if it is in base 16?^ „

B2FD = (Bx

3

) + (2x

2 ) + (Fx

1 ) + (Dx

= (11x

3 ) + (2x

2

) + (15x

(^1) ) + (13x

5555

Hex to Binary ConversionHex to Binary Conversion

„

Hexadecimal is a more compact representation of binary

„

Each hex digit represents 16 decimal values

„

Four binary digits represent 16 decimal values

„

Therefore, one hex digit can replace four binary digits

„

Example:^ „

binary

„

b

a

c

a

hex

„

the C language assumes that any number prefixed by “0x” ishexadecimal

„

e.g., 0x3b9aca00 is understood to be hexadecimal

5656

Which Base Should We Use?Which Base Should We Use?

„

decimal^ „

great for humans; most arithmetic is done with this base

„

2’s complement binary^ „

this is what computers use, so get used to them „

become familiar with how to do basic arithmetic with them

„

hex^ „

long strings of binary numbers are much better represented inhex