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