CIS 240 - Exam 1 - Cheat Sheet

CIS 240 - Exam 1 - Cheat Sheet - LC4 Data Memory Layout for...

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

View Full Document Right Arrow Icon
LC4 Data Memory Layout for C x0000-x3FFF: global variables x4000-x6FFF: dynamic storage—heap x7000-x7FFF: local variables—stack x8000-xFFFF: reserved for OS - calling convention : standard way program passes/returns parameters to/from functions - debugger : program that shepherds execution of another program and gives you hooks for examining the internals of that program -breakpoint: instructions/statements -watchpoint: data elements -in C, integers are 32 or 64 bit; C compiled to LC4 needs 16-bit integers - typedef : define your own synonyms for types typedef short lc3int; typedef unsigned short lc3uint; - C preprocessor -macros (#define FMAC(a,b) text here) – replaces macro name in the rest of the program with text -modules (#include “mx-stdlib.h”; #include <stdio.h>;) -conditional compilation (#ifdef HW3 “code” #endif /* HW3 */) Pointers : data values that are memory addresses -created by &, dereferenced by * -use: reference parameters (callee can change callers’ variables) -passing parameters via registers much faster -NULL: macro for an invalid pointer value -signify end of linked list, end of string -* declaration operator binds to variables, not types (int *x, y – x is pointer, y is int) -printf: print format compiler optimizations -common sub-expression elimination: avoid load if value already in some register -register allocation: assign variable to register for its entire lifetime Arrays -group of closely related variables of same type #define NUM_ELEMENTS 4 int nums[NUM_ELEMENTS]; int i, sum = 0; for (i = 0; i < NUM_ELEMENTS; i++) sum += nums[i]; -arrays are pointers to the first element! nums = &nums = &nums[0] nums[0] = *(&nums[0]) = *(nums) nums[i] = &nums[0] + i = nums[0] + i -scalar types and data sizes – sizeof() LC4: memory 16-bit addressable C: memory is 8-bit addressable, char (1byte), short (2), long/float (4), double/int (8)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2009 for the course CIS 240 taught by Professor Roth during the Spring '09 term at UPenn.

Page1 / 2

CIS 240 - Exam 1 - Cheat Sheet - LC4 Data Memory Layout for...

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

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