DOC PREVIEW
CMU CS 15410 - Lecture

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 1215-410, F’04- 1 -#defineSep. 13, 2004Dave EckhardtDave EckhardtBruce MaggsBruce MaggsL06b_define15-410“Don't make me stop the car...”15-410, F’04- 1 -OutlineWhat's wrong with this picture?What's wrong with this picture?15-410, F’04- 1 -Example 1int scanbuf[64];int getchar(void){ ... if (++bufindex == 64) bufindex = 0; ...}15-410, F’04- 1 -Example 1 – Change RequirementFrom: Dave EckhardtSubject: keyboard buffer sizeKeyboard buffers must handle somebody placing a cat on the keyboard (the 101-key keyboard).15-410, F’04- 1 -Option 1int scanbuf[256];int getchar(void){ ... if (++bufindex == 64) bufindex = 0; ...}15-410, F’04- 1 -Option 2int scanbuf[64];int getchar(void){ ... if (++bufindex == 256) bufindex = 0; ...}15-410, F’04- 1 -Option 3 – Try This At Home!!!#define KSB_SIZE 256int scanbuf[KSB_SIZE];int getchar(void){ ... if (++bufindex == KSB_SIZE) bufindex = 0; ...}15-410, F’04- 1 -Example 2int scanbuf[64];int getchar(void){ ... if (bufindex == 63) bufindex = 0; ...}15-410, F’04- 1 -Example 2 – Truly PerniciousHow to fix How to fix halfhalf of the problem of the problem% grep 64 *.cWrong Wrong twotwo ways ways–Won't find 63–Will find random unrelated 64's15-410, F’04- 1 -Example 3#define CENTER_X 49#define CENTER_Y 12 ... set_cursor_pos(CENTER_Y, CENTER_X); ...15-410, F’04- 1 -Example 3 – Change RequirementFrom: Dave EckhardtSubject: new screen sizeWe have updated the VGA hardware initialization sequence. The new screen size will be:#define CONSOLE_WIDTH 120#define CONSOLE_HEIGHT 3015-410, F’04- 1 -Example 4...p->regsave[-18] |= 0x402;...Don't make me stop the car......Don't make me stop the


View Full Document

CMU CS 15410 - Lecture

Download Lecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?