L03 - CS61C Machine Structures Lecture 3 C Pointers and...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 61C L04 C Pointers (1) Wawrzynek Fall 2007 © UCB 8/31/2007 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS61C – Machine Structures Lecture 3 – C Pointers and Arrays CS 61C L04 C Pointers (2) Wawrzynek Fall 2007 © UCB All About Me: John Wawrzynek ° EECS faculty member since 1988 ° Taught CS61c 3 times previously: along with other instructors, help create the current course content. ° Many times teaching CS150, and other undergrad and grad courses in computer architecture ° Research in computer systems design: current project focuses on using reconfigurable logic to help design future parallel computing systems. ° More on www.cs.berkeley.edu/~johnw ° Office hours: MF after class or by appointment ° Email for short answers, otherwise come to office hours
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 61C L04 C Pointers (3) Wawrzynek Fall 2007 © UCB 61C: All the way from programs through hardware High Level Language Program (e.g., C) Assembly Language Program (e.g.,MIPS) Machine Language Program (MIPS) Hardware Architecture Description (e.g., block diagrams) Compiler Assembler Machine Interpretation temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; lw $t0, 0($2) lw $t1, 4($2) sw $t1, 0($2) sw $t0, 4($2) 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 Logic Circuit Description (Circuit Schematic Diagrams) Architecture Implementation Register File ALU CS 61C L04 C Pointers (4) Wawrzynek Fall 2007 © UCB CS61c Course content has survived 3 decades of Moore’s Law! From 2,000 transistors to 200,000,000!
Background image of page 2
CS 61C L04 C Pointers (5) Wawrzynek Fall 2007 © UCB Review from Wednesday All data is in memory. Each memory location has an address to use to refer to it and a value stored in it. ° A pointer is a C version of the address. * “follows” a pointer to its value ( *p gives the value of x ) address of x in p ) 23 42 ... ... 101 102 103 104 105 . .. x y Location (address) name p 104 CS 61C L04 C Pointers (6) Wawrzynek Fall 2007 © UCB Common C Error ° There is a difference between assignment and equality a = b is assignment a == b is an equality test ° This is one of the most common errors for beginning C programmers!
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS 61C L04 C Pointers (7) Wawrzynek Fall 2007 © UCB ° After declaring a pointer: int *ptr; ptr doesn’t actually point to anything yet (well actually points somewhere - but don’t know where!). We can either: make it point to something that already exists, or allocate room in memory for something new that it will point to… (next time) CS 61C L04 C Pointers (8)
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/09/2008 for the course CS 61A taught by Professor Harvey during the Spring '08 term at Berkeley.

Page1 / 14

L03 - CS61C Machine Structures Lecture 3 C Pointers and...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online