61
Intro to Math 230 Assembly Language Programming Lecture # 01 01/15/08

Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

Embed Size (px)

Citation preview

Page 1: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

Intro to Math 230

Assembly Language Programming

Lecture # 0101/15/08

Page 2: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

2

Lecture Overview

• Course Overview

• Short history of industry trends and

motivation for course need

• Lab: command line environment review

Page 3: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

3

M230 Course Description

• Hands-on programming course in C and

assembly language programming

• Covers low level programming and

debugging techniques, computer

architecture, input/output programming

Page 4: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

4

Math 230

• Meeting Times

� Lecture:

• Tue, Thu: 8:00 am - 9:15 am, rm 394

� Lab:

• Tue, Thu: 9:30 am - 10:45 am, rm 394

• Class Web Resources: � http://swccd.blackboard.com

� http://groups.google.com/group/swcClassMath230

Page 5: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

5

Instructor Contact Info

� Bruce Smith, Assist. Prof of Mathematics

� Phone: 421-6700, x5291

� e-mail: [email protected]

� Office: room 320F

� Office hours:

• M, W: 12:10 pm - 1:50 pm

• Fri: 12:00 pm - 12:50 pm

– You can also contact me to setup an

appointment outside these hours!

Page 6: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

6

Textbook and Materials

• Required:

� Computer Organization and Design,3rd Edition, by Patterson and Hennessy

� Programming in C, 2nd Edition, by Kernighan and Ritchie (K&R)

• On library reserve:

� Digital Principles and Applications, by Leach

� K&R

Page 7: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

7

Attendance

• You can be dropped if you have more than 4 absences (i.e., 2 weeks worth of classes)

• Tardiness and early departures may also be counted as absences

• Course material discussed during the Lab section may extend (or even add to) lecture material. You are responsible for all material covered in both lab and lecture

Page 8: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

8

Evaluation Policy

• Semester Grade

Evaluation Policy

Labs (~10) 10%

Homework (~10) 10%

Projects (~5) 30%

Midterm Exams (2) 25%

Final Exam 25%

Total: 100%

Assigned reading: P&H, Ch 1, 3.1, 3.2 (exclude Fig.3.1)

HW01 (due Thu, 1/24): Exercises 1.1 thru 1.28, 1.54

Lab01 (due Thu, 1/24): see Blackboard

Page 9: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

9

Homework, Labs and Projects

• Lab exercises

� every week; to be submitted by the

Thursday lab session

• Homework exercises

� ~every week

• Projects

� ~every 3 weeks

Page 10: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

10

Class Policies

• No food or drink (water bottles OK)

• Cell phones silent

• No children or visitors without prior

permission

Page 11: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

11

Class Policies

• If you are found cheating or helping

someone cheat, you may receive as much as

–50% of the assignment’s value

• Any further cheating will result in expulsion

from the course.

� Also see SWC Course Catalog regarding

student conduct.

Page 12: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

12

Class Resources

• Primarily the info that is packaged with your

textbook

� PCspim

• compiler/assembler

• see text book

� MARs

� Science of Computing Text

� Camera

� Vivio

� LogiSim

Page 13: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

13

Is MIPS relevant?

• MIPS

� Microprocessor Without Interlocked

Pipeline Stages

Page 14: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

14

Market Share

Page 15: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

15

The MIPS share

Page 16: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

17

Workstation Peformance

Page 17: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

18

Framework for the Course

Page 18: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

19

Assembly Language

Page 19: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

19

Assembly Language

• Machine language

Page 20: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

19

Assembly Language

• Machine language

� The numeric language understood by a computer’s processor (the CPU).

Page 21: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

19

Assembly Language

• Machine language

� The numeric language understood by a computer’s processor (the CPU).

� Consists entirely of 1’s and 0’s• low and high voltages

Page 22: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

19

Assembly Language

• Machine language

� The numeric language understood by a computer’s processor (the CPU).

� Consists entirely of 1’s and 0’s• low and high voltages

� The 1’s and 0’s are usually grouped and represented as larger numbers (hex or octal)

Page 23: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

19

Assembly Language

• Machine language

� The numeric language understood by a computer’s processor (the CPU).

� Consists entirely of 1’s and 0’s• low and high voltages

� The 1’s and 0’s are usually grouped and represented as larger numbers (hex or octal)

• Assembly Language

Page 24: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

19

Assembly Language

• Machine language

� The numeric language understood by a computer’s processor (the CPU).

� Consists entirely of 1’s and 0’s• low and high voltages

� The 1’s and 0’s are usually grouped and represented as larger numbers (hex or octal)

• Assembly Language

� Short mnemonics to represent the numeric (machine) language, e.g., ADD, LW, SUB, MUL, J, DIV, JAL

Page 25: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

19

Assembly Language

• Machine language

� The numeric language understood by a computer’s processor (the CPU).

� Consists entirely of 1’s and 0’s• low and high voltages

� The 1’s and 0’s are usually grouped and represented as larger numbers (hex or octal)

• Assembly Language

� Short mnemonics to represent the numeric (machine) language, e.g., ADD, LW, SUB, MUL, J, DIV, JAL

� Converted to machine language

Page 26: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

20

Babel

Page 27: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

21

Applications

• Embedded systems

� flight control

� air-conditioning

� home alarm

� digital phone

• Create device drivers

� printer drivers

� USB drivers

• Computer games needing HW access

� small, quick code

Page 28: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

22

What are “Machine Structures”?

I/O systemProcessor

Compiler

Operating

System

(Mac OSX)

Application (ex: browser)

Digital Design

Circuit Design

Instruction SetArchitecture

Datapath & Control

transistors

MemoryHardware

Software Assembler

Page 29: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

22

What are “Machine Structures”?

I/O systemProcessor

Compiler

Operating

System

(Mac OSX)

Application (ex: browser)

Digital Design

Circuit Design

Instruction SetArchitecture

Datapath & Control

transistors

MemoryHardware

Software Assembler

M 230

I/O systemProcessor

Compiler

Operating

System

(Mac OSX)

Application (ex: browser)

Digital Design

Instruction SetArchitecture

Datapath & Control

MemoryHardware

Software Assembler

Page 30: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

22

What are “Machine Structures”?

I/O systemProcessor

Compiler

Operating

System

(Mac OSX)

Application (ex: browser)

Digital Design

Circuit Design

Instruction SetArchitecture

Datapath & Control

transistors

MemoryHardware

Software Assembler

M 230

I/O systemProcessor

Compiler

Operating

System

(Mac OSX)

Application (ex: browser)

Digital Design

Instruction SetArchitecture

Datapath & Control

MemoryHardware

Software Assembler

* Coordination of many

Page 31: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

22

What are “Machine Structures”?

I/O systemProcessor

Compiler

Operating

System

(Mac OSX)

Application (ex: browser)

Digital Design

Circuit Design

Instruction SetArchitecture

Datapath & Control

transistors

MemoryHardware

Software Assembler

M 230

I/O systemProcessor

Compiler

Operating

System

(Mac OSX)

Application (ex: browser)

Digital Design

Instruction SetArchitecture

Datapath & Control

MemoryHardware

Software Assembler

* Coordination of many

levels (layers) of abstraction

Page 32: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

23

Levels of Representation

High Level Language Program (e.g., C)

Assembly Language Program (e.g.,MIPS)

Machine Language Program (MIPS)

Hardware Architecture Description (Logic, Logisim, Verilog, etc.)

Compiler

Assembler

Machine Interpretation

Logic Circuit Description (Logisim, etc.)

Architecture Implementation

Page 33: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

23

Levels of Representation

High Level Language Program (e.g., C)

Assembly Language Program (e.g.,MIPS)

Machine Language Program (MIPS)

Hardware Architecture Description (Logic, Logisim, Verilog, etc.)

Compiler

Assembler

Machine Interpretation

Logic Circuit Description (Logisim, etc.)

Architecture Implementation

temp = v[k];

v[k] = v[k+1];

v[k+1] = temp;

Page 34: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

23

Levels of Representation

High Level Language Program (e.g., C)

Assembly Language Program (e.g.,MIPS)

Machine Language Program (MIPS)

Hardware Architecture Description (Logic, Logisim, Verilog, etc.)

Compiler

Assembler

Machine Interpretation

Logic Circuit Description (Logisim, etc.)

Architecture Implementation

temp = v[k];

v[k] = v[k+1];

v[k+1] = temp;

lw $t0, 0($2)lw $t1, 4($2)sw $t1, 0($2)sw $t0, 4($2)

Page 35: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

23

Levels of Representation

High Level Language Program (e.g., C)

Assembly Language Program (e.g.,MIPS)

Machine Language Program (MIPS)

Hardware Architecture Description (Logic, Logisim, Verilog, etc.)

Compiler

Assembler

Machine Interpretation

Logic Circuit Description (Logisim, etc.)

Architecture Implementation

temp = v[k];

v[k] = v[k+1];

v[k+1] = temp;

lw $t0, 0($2)lw $t1, 4($2)sw $t1, 0($2)sw $t0, 4($2)

0000 1001 1100 0110 1010 1111 0101 1000

1010 1111 0101 1000 0000 1001 1100 0110

1100 0110 1010 1111 0101 1000 0000 1001

0101 1000 0000 1001 1100 0110 1010 1111

Page 36: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

24

Anatomy: 5 components of any Computer

Personal Computer

Processor

Computer

Control(“brain”)

Datapath(“brawn”)

Memory

(where programs, data live whenrunning)

Devices

Input

Output

Keyboard,

Mouse

Display,

Printer

Disk(where programs, data live whennot running)

Page 37: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

25

Overview of Physical Implementations

• Integrated Circuits (ICs)

� Combinational logic circuits, memory elements, analog interfaces.

• Printed Circuits (PC) boards

� substrate for ICs and interconnection, distribution of CLK, Vdd, and GND signals, heat dissipation.

• Power Supplies

� Converts line AC voltage to regulated DC low voltage levels.

• Chassis (rack, card case, ...)

� holds boards, power supply, provides physical interface to user or other systems.

• Connectors and Cables.

The hardware out of which we make systems.

Page 38: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

26

Integrated Circuits (2005 state-of-the-art)

• Primarily Crystalline Silicon

• 1mm - 25mm on a side

• 2005 - feature size ~ 90 nm = 90 x 10-9m

• 100 - 1000M transistors

• (25 - 100M “logic gates")

• 3 - 10 conductive layers

• “CMOS” (complementary metal oxide

semiconductor) - most common.

• Package provides:

� spreading of chip-level signal paths to board-

level

� heat dissipation.

• Ceramic or plastic with gold wires.

Chip in Package

Bare Die

Page 39: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

27

Printed Circuit Boards

• fiberglass or ceramic

•1-20 conductive layers

•1-20 in on a side

• IC packages are soldered down.

•Provides:

� Mechanical support

� Distribution of power and heat.

Page 40: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

28

Technology Trends:

Microprocessor Complexity

2X Transistors / ChipEvery 1.5 years

Called

“Moore’s Law”

Gordon Moore

Intel Cofounder

Year

# o

f tr

an

sis

tors

on

an

IC

Page 41: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

29

Technology Trends:

Memory Capacity (Single-Chip DRAM)size

Year

1000

10000

100000

1000000

10000000

100000000

1000000000

1970 1975 1980 1985 1990 1995 2000

year size (Mbit)

1980 0.0625

1983 0.25

1986 1

1989 4

1992 16

1996 64

1998 128

2000 256

2002 512

2004 1024 (1Gbit)• Now 1.4X/yr, or 2X every 2 years.

• 8000X since 1980!

Bit

s

Year

Page 42: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

30

1

10

100

1000

10000

1978 1980 1982 1984 1986 1988 1990 1992 1994 1996 1998 2000 2002 2004 2006

Perf

orm

ance (

vs. V

AX

-11/7

80)

25%/year

52%/year

20%/year

Technology Trends:

Uniprocessor Performance (SPECint)

• VAX : 1.25x/year 1978 to 1986

• RISC + x86: 1.52x/year 1986 to 2002

• RISC + x86: 1.20x/year 2002 to present

1.25x/year

1.52x/year

1.20x/year

Pe

rfo

rman

ce

(v

s. V

AX

-11

/780

)

Page 43: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

31

Computer Technology - Dramatic Change!

• Memory

� DRAM capacity: 2x / 2 years (since ‘96);

64x size improvement in last decade.

• Processor

� Speed 2x / 1.5 years (since ‘85); [slowing!]

100X performance in last decade.

• Disk

� Capacity: 2x / 1 year (since ‘97)

250X size in last decade.

Page 44: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

32

Computer Technology - Dramatic Change!

•State-of-the-art PC when you graduate: (at least…)

� Processor clock speed: 5000 MegaHertz (5.0 GigaHertz)

� Memory capacity: 8000 MegaBytes(8.0 GigaBytes)

� Disk capacity: 2000 GigaBytes(2.0 TeraBytes)

� New units! Mega ⇒ Giga, Giga ⇒ Tera

(Tera ⇒ Peta, Peta ⇒ Exa, Exa ⇒ ZettaZetta ⇒ Yotta = 1024)

We’ll see that Kilo, Mega, etc. are incorrect later!

Page 45: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

33

M230: So what's in it for me?

•Learn some of the big ideas in CS & engineering:

� Principle of abstraction, used to build systems as layers

� 5 Classic components of a Computer

� Data can be anything (integers, floating point, characters): a program determines what it is

� Stored program concept: instructions just data

� Principle of Locality, exploited via a memory hierarchy (cache)

� Greater performance by exploiting parallelism

� Compilation v. interpretation thru system layers

� Principles/Pitfalls of Performance Measurement

Page 46: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

34

Others Skills learned in 230

•Learning C

� If you know one, you should be able to learn another

programming language largely on your own

� Given that you know C++ or Java, should be easy to pick

up their ancestor, C

•Assembly Language Programming

� This is a skill you will pick up, as a side effect of

understanding the Big Ideas

•Hardware design

� We’ll learn just the basics of hardware design

Page 47: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

35

Course Lecture Outline• Number representations

• C-Language (basics + pointers)

• Storage management

• Assembly Programming• Floating Point

• make-ing an Executable (compilation, assembly)

• Logic Circuit Design

• CPU organization

• Pipelining

• Caches

• Virtual Memory

• Performance

• I/O Interrupts

• Disks, Networks

• Advanced Topics

Page 48: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

36

Page 49: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

37

Today’s Lab Work

• Log onto computer (swcstudent):

� username: pmath

� password: 7pmath

• Log onto Blackboard

� swccd.edu or swccd.blackboard.com• announcements

• grades

• Updating E-mail on Webadvisor

• sending e-mail

• Explore command-line environment

Page 50: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

38

Lab 0

• dir

• cd

• del

• pwd

• pushd/popd

• more

• path

• set

• redirection

• wildcards

Page 51: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

39

Binary Numbers

• Digits are 1 and 0

� 1 = true

� 0 = false

• MSB – most significant bit

• LSB – least significant bit

• Bit numbering: 015

1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0

MSB LSB

Page 52: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

40

Base-10 (decimal) arithmetic

• Uses the ten numbers from 0 to 9

• Each column represents a power of 10

Thousands (103) column

Hundreds (102) column

Tens (101) column

Ones (100) column

199910

= 1x103 + 9x102 + 9x101 + 9x100

Page 53: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

41

Base-2 (binary) arithmetic

• Uses the two numbers from 0 to 1

• Every column represents a power of 2

Page 54: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

41

Base-2 (binary) arithmetic

• Uses the two numbers from 0 to 1

• Every column represents a power of 2

10012

= 1x23 + 0x22 + 0x21 + 1x20

Eights (23) column

Fours (22) column

Twos (21) column

Ones (20) column

Page 55: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

42

Translating Binary to Decimal

Weighted positional notation shows how to calculate the decimal value of each binary bit:

dec = (Dn-1

×××× 2n-1) ++++ (Dn-2

×××× 2n-2) ++++ ... ++++ (D1

×××× 21) ++++(D

0×××× 20)

D = binary digit

binary 00001001 = decimal 9:

(1 × 23) + (1 × 20) = 9

Page 56: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

43

Converting from base-2 to base-10

32 16 8 4 2 1 1 0 0 1 = 1 0 1 1 = 1 0 1 0 1 = 1 1 1 1 1 1 =

Page 57: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

44

Converting from base-10 to base-2 (on the fly)

64 32 16 8 4 2 1 = 16 = 55 = 75 = 84

Page 58: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

45

Converting from base-10 to base-2 (using division)

• Repeatedly divide the decimal integer by 2. Each remainder is a binary digit in the translated value:

37 = 100101

Page 59: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

46

Addition

1 9 9 8 1 0 1 1 + 1 1 + 1 1

2 0 0 9 1 1 1 0

Base-10 Base-2

Page 60: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

47

Binary Addition

• Starting with the LSB, add each pair of digits, include the carry if present.

0 0 0 0 0 1 1 1

0 0 0 0 0 1 0 0

+

0 0 0 0 1 0 1 1

1

(4)

(7)

(11)

carry:

01234bit position: 567

Page 61: Intro to Math 230 Assembly Language Programmingdept.swccd.edu/bsmith/m230/lectures/01overview.pdf · Chip in Package Bare Die. 27 ... Processor clock speed: 5000 Mega Hertz (5.0 Giga

48

Practice binary arithmetic

1 0 1 1 1 1 1 + 1 1 + 1