



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CMSC 212 – F05 (lect 26) 1
CMSC 212 – F05 (lect 26)^2
CMSC 212 – F05 (lect 26)^3
CMSC 212 – F05 (lect 26) 4
CMSC 212 – F05 (lect 26)^5
CMSC 212 – F05 (lect 26)^6
Adapted from: www.cs.tau.ac.il/~dcor/Software1/Makefile. ppt
CMSC 212 – F05 (lect 26) 7
CMSC 212 – F05 (lect 26)^8
Purpose Opcode Register 1 Register 2 Register 3 Memory
Size (bits) 4 4 4 4 16
CMSC 212 – F05 (lect 26)^9
int foo(int *a) { *a = 3; }
int x; foo(&x);
CMSC 212 – F05 (lect 26) 10
typdef struct { int a; char b; } Simple;
Simple x; Simple y[20], z;
CMSC 212 – F05 (lect 26)^11
int foo:13; unsigned int foo:4; typedef struct { /* from project #1 */ unsigned int opCode:4; unsigned int r1:4; unsigned int r2:4; unsigned int r3:4; unsigned int address:16; } instruction;
CMSC 212 – F05 (lect 26)^12
CMSC 212 – F05 (lect 26) 19
CMSC 212 – F05 (lect 26)^20
CMSC 212 – F05 (lect 26)^21
89
p q
a
CMSC 212 – F05 (lect 26) 22
CMSC 212 – F05 (lect 26)^23
CMSC 212 – F05 (lect 26)^24
typedef struct ARC { struct NODE *nodePtr; struct ARC *next; } Arc; typedef struct NODE { Arc *outArcs; int value; } Node;
CMSC 212 – F05 (lect 26) 25
CMSC 212 – F05 (lect 26)^26
CMSC 212 – F05 (lect 26)^27
typedef int (*compareFunc)(item *a, item * b);
int searchTree(Node *root, Item target, compareFunc cmp) { if (!root) return -1; ret = (cmp)(target, root->data); if (ret == 0) { / found it */ return 1; } else if (ret < 0) { return searchTree(root->left, target, cmp); } else { return searchTree(root->right, target, cmp); } }
CMSC 212 – F05 (lect 26) 28
CMSC 212 – F05 (lect 26)^29
8/0 16/1 24/0 8/1 24/1 0/
CMSC 212 – F05 (lect 26)^30