00-Code-Generation-Examples

# 00-Code-Generation-Examples - CS107 Spring 2007 Handout 00...

This preview shows pages 1–2. Sign up to view the full content.

CS107 Handout 00 Spring 2007 May 7, 2007 Additional Code Generation Examples Problem 1: Project Runway: One Of You Will Be cout Consider the following struct definitions: typedef struct { int uli; short laura[8]; char *jeffrey; double **robert; } designer; static designer *aufwiedersehen(designer *kayne, int bonnie); static char *nopatternbooksallowed(int *michael, designer malan) { malan.laura[michael[2]] = (malan.jeffrey + 2)[2]; *(short **)(((designer *)&malan.robert)->laura) += 10; return aufwiedersehen(&malan - 10, malan.uli)->jeffrey; } Generate code for the entire nopatternbooksallowed function. Be clear about what assembly code corresponds to what line. Problem 2: San Francisco Fine Dining Consider the following struct definitions: typedef struct { int **garydanko; int aqua[3]; char *quince; } appetizer; dessert *dinnerisserved(short *boulevard, appetizer *jardiniere); int *bonappetit(dessert azie, char **indigo) { appetizer oola; dessert *catch; azie.bacar[azie.ame[2]] += catch->farallon.aqua[4]; ((appetizer *)(((dessert *)(&oola.quince))->farallon.garydanko))->quince = 0; return (*dinnerisserved((short *) &indigo, &oola)).farallon.aqua; } Generate code for the entire bonappetit function. Be clear about what assembly code corresponds to what

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/14/2010 for the course CS 107 taught by Professor Cain,g during the Spring '08 term at Stanford.

### Page1 / 4

00-Code-Generation-Examples - CS107 Spring 2007 Handout 00...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online