lec21 - Lecture 21 Pointers and WLPP CS 241 Foundations of...

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

View Full Document Right Arrow Icon
Lecture 21 Pointers and WLPP CS 241: Foundations of Sequential Programs Fall 2009 Troy Vasiga et al University of Waterloo 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
WL and MIPS I Compiling WL to MIPS means that MIPS can do everything that a WL program can do I The reverse is not true: mips.array I WL cannot be used to solve A2P3 or A2P4 2
Background image of page 2
WLPP I Allows arrays to be declared, initialized, allocated and destroyed I Uses C++ syntax 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Arrays Nothing more than a pointer: starting address in $1. Size is stored in $2. Picture 4
Background image of page 4
A first WLPP Program int wain(int *a, int n) { return *a; } I signature I declaration of the array I dereferencing I syntax: C++-like (in fact, see the C++ embedding) I semantics of the above program 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
@cpu04.student[124]% java cs241.wlppc < ex1.wlpp > ex1.mips @cpu04.student[125]% java mips.array ex1.mips Enter length of array: 3 Enter array element 0: 10 Enter array element 1: 14 Enter array element 2: 19 Allocates memory on the heap , then calls wain with the address and the size as parameters. 6
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/23/2011 for the course CS 241 taught by Professor Troyvasiga during the Fall '09 term at Waterloo.

Page1 / 20

lec21 - Lecture 21 Pointers and WLPP CS 241 Foundations of...

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

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