Lecture 26-28a - C Data Structures Basic data types: int,...

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

View Full Document Right Arrow Icon
C Data Structures Basic data types: int, char, float, double Arrays Of “things” (basic data types, structures, arrays) Structures Composite data types struct flightType { char flightNum[7]; /* max 6 chars */ int altitude; /* in meters */ int longitude; /* in tenths of degrees */ int latitude; /* in tenths of degrees */ int heading; /* in tenths of degrees */ double airSpeed; /* in kmh */ }; Pointers Addresses of “things” CS310 Fall 2010 - Boral Aside An instance of a “char” data type only requires one byte So, we could pack two chars into a single LC-3 word But because LC-3 does not directly support shifting it can be difficult (and costly) to “unpack” two chars stored in one word For our purposes we will assume each char is stored in its own LC-3 word CS310 Fall 2010 - Boral
Background image of page 1

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

View Full DocumentRight Arrow Icon
Example 1: Passing Parameters By Reference void swap(int *firstVal, int *secondVal); int main () { int val1 = 3; int val2 = 4; swap(&val1, &val2); } int swap(int *firstVal, int *secondVal) { int temp; temp = *firstVal; *firstVal = *secondVal; *secondVal = temp; } CS310 Fall 2010 - Boral ; int tempVal = *firstVal; LDR R0, R5, #4 ; R0=xEFFA LDR R1, R0, #0 ; R1=M[xEFFA]=3
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Lecture 26-28a - C Data Structures Basic data types: int,...

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

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