45
ECE291 ECE291 Lecture 0 Lecture 0 All about ECE291 All about ECE291

ECE291 Lecture 0 All about ECE291. ECE 291 Lecture 0Page 2 of 45 Staff info – Me! Josh Potts Office phone: 244-8032 Office address: 242 Everitt Email:

Embed Size (px)

Citation preview

ECE291ECE291

Lecture 0Lecture 0

All about ECE291All about ECE291

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 22 of 45 of 45

Staff info – Me!Staff info – Me!

Josh PottsJosh Potts

Office phone: 244-8032Office phone: 244-8032

Office address: 242 EverittOffice address: 242 Everitt

Email: Email: [email protected]@uiuc.edu

Office hours: whenever you see me and I Office hours: whenever you see me and I don’t blow you offdon’t blow you off

Sense of humor: present but very badSense of humor: present but very bad

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 33 of 45 of 45

Staff info – the TA’sStaff info – the TA’s

Michael Urman ([email protected])Michael Urman ([email protected])

Ajay Ladsaria ([email protected])Ajay Ladsaria ([email protected])

Ryan Chmiel ([email protected])Ryan Chmiel ([email protected])

Justin Quek ([email protected])Justin Quek ([email protected])

David Du ([email protected])David Du ([email protected])

George Lu ([email protected])George Lu ([email protected])

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 44 of 45 of 45

Lecture outlineLecture outline

Course overviewCourse overview

Lab etiquetteLab etiquette

Design flowDesign flow

Number systems reviewNumber systems review

AssignmentsAssignments

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 55 of 45 of 45

Course overviewCourse overview

What is ECE291?What is ECE291?

Computer Engineering IIComputer Engineering II

Assembly language programmingAssembly language programming

Emphasis on hardware and device programmingEmphasis on hardware and device programming

The glue between your logic design classes and The glue between your logic design classes and your high-level programming classesyour high-level programming classes

A A lotlot of work of work

The best class at UIUCThe best class at UIUC

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 66 of 45 of 45

Course goalsCourse goals

You will become proficient in assembly You will become proficient in assembly language programminglanguage programming

You will learn to organize large programsYou will learn to organize large programs

You will learn how to interface with You will learn how to interface with hardware devices in your computerhardware devices in your computer

You will develop excellent time You will develop excellent time management skills or you will diemanagement skills or you will die

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 77 of 45 of 45

Structure and evaluationStructure and evaluation

6 Home work sets6 Home work sets 125 points125 points

5 Machine problems5 Machine problems 300 points300 points

2 Exams2 Exams 400 points400 points

1 Final project1 Final project 175 points175 points

TotalTotal 1000 points1000 points

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 88 of 45 of 45

Structure and evaluation 2Structure and evaluation 2

Grading scaleGrading scale Minimum A = 95% x AVG(Top 10%)Minimum A = 95% x AVG(Top 10%) Minimum B = Minimum A – 100Minimum B = Minimum A – 100 Minimum C = Minimum B – 100Minimum C = Minimum B – 100 Etc.Etc.

If Minimum A as calculated above is > 900 If Minimum A as calculated above is > 900 then 900 is the minimum Athen 900 is the minimum A

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 99 of 45 of 45

Structure and evaluation 3Structure and evaluation 3

The top “few” people will get A+’s unless The top “few” people will get A+’s unless everyone in the class really suckedeveryone in the class really sucked

+ and - grades will be dolled out just below + and - grades will be dolled out just below letter grade break points.letter grade break points.

So if the minimum A is 900, 890 to 899 will So if the minimum A is 900, 890 to 899 will get an A-, 880 to 889 will get a B+.get an A-, 880 to 889 will get a B+.

I have no quotas on grades. I hope you all I have no quotas on grades. I hope you all get A’s!get A’s!

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1010 of 45 of 45

MiscellaneousMiscellaneous

The 291 website is your most important The 291 website is your most important source of informationsource of information

www.ece.uiuc.edu/ece291www.ece.uiuc.edu/ece291

Home works are completed online at the Home works are completed online at the websitewebsite

All lecture notes, schedule changes, All lecture notes, schedule changes, handouts, etc, are available on the handouts, etc, are available on the website.website.

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1111 of 45 of 45

Miscellaneous 2Miscellaneous 2

The lab notes may be purchased in the The lab notes may be purchased in the IEEE bookstore in the basement for IEEE bookstore in the basement for aproximately $11.aproximately $11.

They have been extensively revised and They have been extensively revised and updated over the summer and should be updated over the summer and should be very useful. very useful.

You may obtain PDF or HTML versions You may obtain PDF or HTML versions from the 291 Web Site.from the 291 Web Site.

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1212 of 45 of 45

Miscellaneous 3Miscellaneous 3

The 291 newsgroup is used heavily throughout The 291 newsgroup is used heavily throughout the semester to answer questionsthe semester to answer questions

uiuc.classes.ece291uiuc.classes.ece291Don’t post code to the newsgroupDon’t post code to the newsgroupPost questions and answers to questions, but Post questions and answers to questions, but don’t tell people how to code their MP’s.don’t tell people how to code their MP’s.Be civil. No flaming. Flaming will be punished.Be civil. No flaming. Flaming will be punished.We also have an announcements newsgroup We also have an announcements newsgroup that only TA’s and myself can post tothat only TA’s and myself can post to

uiuc.classes.ece291.announceuiuc.classes.ece291.announce

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1313 of 45 of 45

Miscellaneous 4Miscellaneous 4

Review the following documents available Review the following documents available on the 291 websiteon the 291 website SyllabusSyllabus Class outline and lecture scheduleClass outline and lecture schedule Lab staffing scheduleLab staffing schedule Homework 0Homework 0 Machine problem 0Machine problem 0

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1414 of 45 of 45

Lab etiquetteLab etiquette

The 291 lab is in 238 Everitt LabThe 291 lab is in 238 Everitt Lab

The lab is open 24-7The lab is open 24-7

Get your keycards activated in 153 ELGet your keycards activated in 153 EL

No food or drink allowed in the labNo food or drink allowed in the lab

Don’t prop the door openDon’t prop the door open

Don’t let people in the lab who aren’t Don’t let people in the lab who aren’t enrolled in the classenrolled in the class

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1515 of 45 of 45

Lab etiquette 2Lab etiquette 2

The lab has recently been completely The lab has recently been completely renovated.renovated. New paint jobNew paint job New tables and chairsNew tables and chairs Increased number of computers from 30 to 37Increased number of computers from 30 to 37 New computers (1GHz, 256MB ram, 17” flat New computers (1GHz, 256MB ram, 17” flat

panel monitors)panel monitors) About $85,000 worth of improvements in allAbout $85,000 worth of improvements in all

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1616 of 45 of 45

Lab etiquette 3Lab etiquette 3

Clean up after yourselvesClean up after yourselves Push your chair back under the table when Push your chair back under the table when

you leaveyou leave Don’t leave candy wrappers or pop cansDon’t leave candy wrappers or pop cans Don’t leave papers laying aboutDon’t leave papers laying about Don’t lock screens – log off when you leaveDon’t lock screens – log off when you leave Don’t poke monitors!!!Don’t poke monitors!!!

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1717 of 45 of 45

Lab etiquette 4Lab etiquette 4

Computer accounts – reset password atComputer accounts – reset password at

http://accounts.ad.uiuc.edu http://accounts.ad.uiuc.edu

Home directories – store your work on the Home directories – store your work on the w: drive. The w: drive is your own private w: drive. The w: drive is your own private work area. It is stored on a server and work area. It is stored on a server and follows you from computer to computerfollows you from computer to computer

DO NOT STORE ANYTHING ON THE C: DO NOT STORE ANYTHING ON THE C: DRIVES OF THE LAB COMPUTERSDRIVES OF THE LAB COMPUTERS

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1818 of 45 of 45

Lab etiquette 5Lab etiquette 5

FTP access to home directoriesFTP access to home directories

ftp to elalpha.ece.uiuc.eduftp to elalpha.ece.uiuc.edu

The 291 lab printer is for printing 291 lab The 291 lab printer is for printing 291 lab materials.materials. Don’t abuse itDon’t abuse it 100 page per month quota100 page per month quota $0.07 charge per page over quota$0.07 charge per page over quota

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 1919 of 45 of 45

Lab etiquette 6Lab etiquette 6

The lab computers don’t belong to you!The lab computers don’t belong to you! Don’t destroy themDon’t destroy them Don’t install Don’t install anythinganything on them (this includes on them (this includes

ICQ, Netscape, Real Player, MIRC, etc.)ICQ, Netscape, Real Player, MIRC, etc.) Don’t attempt to move the computers, Don’t attempt to move the computers,

rearrange the monitors and speakers, etc.rearrange the monitors and speakers, etc. ALWAYS log off when you are doneALWAYS log off when you are done

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2020 of 45 of 45

Machine problemsMachine problems

MP0 – Introduction to assembly languageMP0 – Introduction to assembly language General design flowGeneral design flow Debugging processDebugging process Introduction to the software toolsIntroduction to the software tools

MP1 – Basic input and outputMP1 – Basic input and output ProceduresProcedures Basic instructionsBasic instructions Library routinesLibrary routines

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2121 of 45 of 45

Machine problemsMachine problems

MP2 – Interrupts and I/OMP2 – Interrupts and I/O Advanced keyboard inputAdvanced keyboard input Serial port communication (probably between Serial port communication (probably between

two computers in a client-server paradigm)two computers in a client-server paradigm) Keyboard interruptsKeyboard interrupts

MP3 – Text mode video, timingMP3 – Text mode video, timing

MP4 – Protected mode, hi-res graphics, MP4 – Protected mode, hi-res graphics, image processing, basic-shape drawingimage processing, basic-shape drawing

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2222 of 45 of 45

Final projectFinal project

All of the above topics plus sound and All of the above topics plus sound and networking if you want to try them.networking if you want to try them.

Groups of 2 to 5 people (we prefer 3 or 4)Groups of 2 to 5 people (we prefer 3 or 4)

Should be the equivalent of a later MP’s Should be the equivalent of a later MP’s work per personwork per person

You propose projects to us, we approve You propose projects to us, we approve them or make suggestionsthem or make suggestions

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2323 of 45 of 45

Why am I doing this?Why am I doing this?

Program speedProgram speed

Compact executableCompact executable

Common in DSP and embedded systemsCommon in DSP and embedded systems

Games, games, games!!!Games, games, games!!!

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2424 of 45 of 45

Design flowDesign flow

CodingCoding We will provide you with “skeleton” files for We will provide you with “skeleton” files for

each MP. Copy this skeleton file to your w: each MP. Copy this skeleton file to your w: drive and work on it from there. For MP0, the drive and work on it from there. For MP0, the file is mp0.asm.file is mp0.asm.

Write your assembly code in mp0.asm using Write your assembly code in mp0.asm using your favorite text editor (we suggest vim)your favorite text editor (we suggest vim)

Run the make command. This invokes Run the make command. This invokes NASM, the Netwide ASseMbler.NASM, the Netwide ASseMbler.

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2525 of 45 of 45

Design flow 2Design flow 2

Making your executableMaking your executable Running make from the command line Running make from the command line

assembles your code using NASM, links it assembles your code using NASM, links it with any library functions we provide and with any library functions we provide and generates an executable like mp0.exegenerates an executable like mp0.exe

If there are syntax errors in your code, Nasm If there are syntax errors in your code, Nasm will tell you about itwill tell you about it

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2626 of 45 of 45

Design flow 3Design flow 3

DebuggingDebugging Use feedback from Nasm to eliminate all Use feedback from Nasm to eliminate all

syntax errors.syntax errors. Use Turbo Debugger (td) to track down run-Use Turbo Debugger (td) to track down run-

time and logic errors.time and logic errors.

MP0 takes you through the above processMP0 takes you through the above process

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2727 of 45 of 45

Number systems reviewNumber systems review

Base 10 representation (decimal) (0..9): Base 10 representation (decimal) (0..9): ddnn1010nn + d + dn-1n-11010n-1n-1 + ... + d + ... + d22101022 + d + d11101011 + d + d00101000 Example: 3045Example: 3045

= 3*10= 3*1033 + 4*10 + 4*1011 + 5*10 + 5*1000

= 3000 + 40 + 5= 3000 + 40 + 5

= 3045 = 3045

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2828 of 45 of 45

Number systems review 2Number systems review 2

Base 2 representation (binary) (0..1): Base 2 representation (binary) (0..1): ddnn22nn + d + dn-1n-122n-1n-1 + ... + d + ... + d22

22 + d + d112211 + d + d002200 Eg: 101101Eg: 101101

= 1*2= 1*255 + 1*2 + 1*233 + 1*2 + 1*222 + 1*2 + 1*200

= 32 + 8 + 4 + 1= 32 + 8 + 4 + 1

= 45 = 45

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 2929 of 45 of 45

Number systems review 3Number systems review 3

Base 16 representation (hex) (0..9,A..F): Base 16 representation (hex) (0..9,A..F): ddnn1616nn + d + dn-1n-11616n-1n-1 + ... + d + ... + d22161622 + d + d11161611 + d + d00161600 3AF3AF

= 3*16= 3*1622 + 10*16 + 10*1611 + 15*16 + 15*1600

= 3*256 + 10*16 + 15= 3*256 + 10*16 + 15

= 943 = 943

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3030 of 45 of 45

Base conversionBase conversion

Division/remainder method - Long division Division/remainder method - Long division by largest power of base.by largest power of base. Example: Convert 45 decimal to binaryExample: Convert 45 decimal to binary

45 divides by 32 (245 divides by 32 (255) once, leaves 13) once, leaves 13

13 divides by 8 (213 divides by 8 (233) once, leaves 5) once, leaves 5

5 divides by 4 (25 divides by 4 (222) once, leaves 1) once, leaves 1

1 divides by 1 (21 divides by 1 (200) once, leaves nothing [done]) once, leaves nothing [done]

Thus: 45 (base 10) == 101101 (base 2)Thus: 45 (base 10) == 101101 (base 2)

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3131 of 45 of 45

Number representationNumber representation

In computers, the size of a number In computers, the size of a number becomes important. An 8-bit number for becomes important. An 8-bit number for example always has 8 binary digits.example always has 8 binary digits. Example: 0001 1010Example: 0001 1010

Hexadecimal is a convenient shorthand for Hexadecimal is a convenient shorthand for binary numbers:binary numbers: Example: 1AhExample: 1Ah

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3232 of 45 of 45

Number representationNumber representation

In an 8-bit system, the largest number we In an 8-bit system, the largest number we can represent is 1111 1111, or FFh, or can represent is 1111 1111, or FFh, or 255d255d

If we need to represent bigger numbers, If we need to represent bigger numbers, we need more bytes.we need more bytes.

16-bit numbers go up to 65,535d or FFFFh 16-bit numbers go up to 65,535d or FFFFh or 1111 1111 1111 1111.or 1111 1111 1111 1111.

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3333 of 45 of 45

Signed numbersSigned numbers

Need a way to represent negative Need a way to represent negative numbersnumbers

Let’s try using the first bit or most Let’s try using the first bit or most significant bit as a sign bit!significant bit as a sign bit! Sign bit = 0: positiveSign bit = 0: positive Sign bit = 1: negative Sign bit = 1: negative

Example: Example: 11000 0010 = -2 decimal000 0010 = -2 decimal

00000 0010 = +2 decimal000 0010 = +2 decimal

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3434 of 45 of 45

Signed numbers 2Signed numbers 2

Trouble/Confusion/ProblemTrouble/Confusion/Problem How is 0000 0000 different from 1000 0000?How is 0000 0000 different from 1000 0000? One is -0 and one is +0. No different at all!One is -0 and one is +0. No different at all! We should intuitively dislike having to different We should intuitively dislike having to different

representations for the same thing.representations for the same thing.

More problemsMore problems It becomes difficult to process positive and It becomes difficult to process positive and

negative numbers. Special cases for each.negative numbers. Special cases for each.

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3535 of 45 of 45

Two’s complementTwo’s complement

The solution is to use Two’s ComplementThe solution is to use Two’s Complement Numeric Formula: Numeric Formula:

-d-dnn22nn + d + dn-1n-122n-1n-1 + ... + d + ... + d222222 + d + d11*2*211 + d + d00*2*200

Notice the negative sign in front of dNotice the negative sign in front of dnn

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3636 of 45 of 45

Two’s complement 2Two’s complement 2

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3737 of 45 of 45

Two’s complement 3Two’s complement 3

We are taking advantage of the circular We are taking advantage of the circular nature of fixed-length binary numbersnature of fixed-length binary numbersTo subtract A-B, perform A+(-B).To subtract A-B, perform A+(-B).Now the addition operator works for Now the addition operator works for negative numbersnegative numbers Notice: First bit Notice: First bit still representsstill represents the sign of the sign of the number. the number. s=0: positive (+) s=0: positive (+) s=1: negative (-) s=1: negative (-)

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3838 of 45 of 45

Two’s complement 4Two’s complement 4

Three methods to compute a negative Three methods to compute a negative number (n) (choose one method) number (n) (choose one method) Invert bits of Invert bits of nn then add 1 then add 1 Take largest number (all ones), subtract Take largest number (all ones), subtract nn, ,

add 1 add 1 Scan Scan nn from right to left. Copy zeros, copy first from right to left. Copy zeros, copy first

one, invert remaining numbers one, invert remaining numbers

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 3939 of 45 of 45

Two’s complement 5Two’s complement 5

Examples (8-bit): Examples (8-bit): -1 -1 = = 1111 1111 1111 1111 -2 -2 = = 1111 1110 1111 1110 -128 -128 = = 1000 0000 1000 0000 +1 +1 = = 0000 0001 0000 0001 +127 +127 = = 0111 1111 0111 1111 +128 +128 = = Invalid Invalid

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 4040 of 45 of 45

Two’s complement 6Two’s complement 6

Examples: (16-bit) Examples: (16-bit) -1 = 1111 1111 1111 1111 -1 = 1111 1111 1111 1111 -2 = 1111 1111 1111 1110 -2 = 1111 1111 1111 1110 -32,768 = 1000 0000 0000 0000 -32,768 = 1000 0000 0000 0000

Observations Observations When you move to a larger register (increase When you move to a larger register (increase

the number of bits), just extend the sign bit to the number of bits), just extend the sign bit to the left. the left.

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 4141 of 45 of 45

Sign and Zero ExtensionSign and Zero Extension

Consider the value 64 Consider the value 64 the 8-bit representation isthe 8-bit representation is 40h40h 0100 00000100 0000 the 16-bit equivalent isthe 16-bit equivalent is 0040h0040h 0000 0000 0100 0000 0000 0100

00000000

Consider the value -64 Consider the value -64 the 8-bit two’s complement is the 8-bit two’s complement is C0hC0h 1100 00001100 0000 the 16-bit equivalent isthe 16-bit equivalent is FFC0hFFC0h 1111 1111 1100 1111 1111 1100

00000000

The rule: to sign extend a value from some number of The rule: to sign extend a value from some number of bits to a greater number of bits - bits to a greater number of bits - copy the sign bit into all copy the sign bit into all the additional bits in the new formatthe additional bits in the new formatRememberRemember - - you must not sign extend unsigned valuesyou must not sign extend unsigned values

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 4242 of 45 of 45

Sign ContractionSign Contraction

Given an n-bit number, you cannot always convert it into Given an n-bit number, you cannot always convert it into an m-bit number if m < nan m-bit number if m < nConsider the value -448Consider the value -448

the 16-bit representation is FE40hthe 16-bit representation is FE40h 1111 1110 0100 1111 1110 0100 00000000

the magnitude of this number is too great to fit into an 8-bit valuethe magnitude of this number is too great to fit into an 8-bit value this is an example of an overflow condition that occurs upon this is an example of an overflow condition that occurs upon

conversionconversion

To properly sign contract one value to another the bits To properly sign contract one value to another the bits that you wish to remove must all contain either 0 or 1that you wish to remove must all contain either 0 or 1

FF80h FF80h can be signed contracted to can be signed contracted to 80h80h 0100h cannot be sign contracted to 8-bit representation0100h cannot be sign contracted to 8-bit representation

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 4343 of 45 of 45

Real numbers in binaryReal numbers in binary

RecallRecall ddnn*2*2nn + d + dn-1n-1*2*2n-1n-1 + ... + d + ... + d22*2*222 + d + d11*2*211 + d + d00*2*200

Notice the exponents begin from n and Notice the exponents begin from n and decrease to zero.decrease to zero.

For fractional parts, just keep goingFor fractional parts, just keep going dd-1-1*2*2-1-1 + d + d-2-2*2*2-2-2 + d + d-3-3*2*2-3-3 + … + …

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 4444 of 45 of 45

Real numbers in binaryReal numbers in binary

Example: Convert 11010.101 to decimalExample: Convert 11010.101 to decimal 2244 + 2 + 233 + 2 + 211 + 2 + 2-1-1 + 2 + 2-3-3

16 + 8 + 2 + .5 + .12516 + 8 + 2 + .5 + .125 26.62526.625

For negative numbers, we just stick a sign For negative numbers, we just stick a sign bit in the front and forget about it.bit in the front and forget about it.

ECE 291 Lecture 0ECE 291 Lecture 0

Page Page 4545 of 45 of 45

AssignmentsAssignments

Get started on MP0.Get started on MP0.

Start HW0. Due WednesdayStart HW0. Due Wednesday

Reset your computer account passwordReset your computer account password

Get your keycard activatedGet your keycard activated

Go buy the Lab ManualGo buy the Lab Manual