Hail the all-powerful C pointer!
|
|
- Lizbeth Bennett
- 5 years ago
- Views:
Transcription
1 This week Assign1 due tomorrow Congrats on having proved your bare-metal mettle! Prelab for lab2 Read info on gcc/make and 7-segment display Bring your tools if you have them! "Gitting Started" Ashwin Wed 4:30pm in B21 Hail the all-powerful C pointer! Goals for today Relate C <-> asm Bare-metal build Pointers, pointers, and more pointers! ARM addressing modes
2 Matt Godbolt s Compiler Explorer Neat interactive tool to see translation from C to assembly. Let s try it now! Configure settings to ARM gcc 5.4.1(none), -Og to follow along
3 .equ DELAY, 0x3F0000 ldr r0, FSEL2 mov r1, #1 str r1, [r0] mov r1, #(1<<20) loop: ldr r0, SET0 str r1, [r0] mov r2, #DELAY wait1: subs r2, #1 bne wait1 ldr r0, CLR0 str r1, [r0] mov r2, #DELAY wait2: subs r2, #1 bne wait2 b loop C? blink.s cblink.c let s do it! FSEL2:.word 0x SET0:.word 0x C CLR0:.word 0x (Source code available in courseware repo at lectures/c1/code)
4 Know your tools Assembler as Transform assembly code (text) into object code (binary machine instructions) Mechanical rewrite, few surprises gcc Compiler Transform C code (text) into object code (likely staged C asm object) Complex translation, high artistry
5 When coding in assembly, the instructions you see are the instructions you get, no surprises! When coding in C, compiler transforms C source into assembly. Sometimes have to drop down to see what was generated to be sure of what you re getting What transformations are legal? What transformations are desirable?
6 cblink.c The little LED that wouldn t A cautionary tale (Source code available in courseware repo at lectures/c1/code)
7 Peripheral Registers These registers are mapped into the address space of the processor (memory-mapped IO). These registers may behave differently than memory. For example: Writing a 1 into a bit in a SET register causes 1 to be output; writing a 0 into a bit in SET register has no effect. Writing a 1 to the CLR register, sets the output to 0; writing a 0 to the CLR register has no effect. Neither SET or CLR can be read. To read the current value use the LEV (level) register. Q: What can happen if the C compiler makes assumptions reasonable for ordinary memory that don t hold for these oddball registers?
8 volatile For an ordinary variable, the compiler has complete knowledge of when it is read/written and can optimize those accesses as long as it maintains correct behavior. However, for a variable that can be read/written externally (by another process, by peripheral), these optimizations will not be valid. The volatile qualifier applied to a variable informs the compiler that it cannot remove, coalesce, cache, or reorder references. The generated assembly must faithfully execute each access to the variable as given in the C code.
9 Build process for bare-metal The default build process for C assumes a hosted environment. What does a hosted system have that we don t? - standard libraries - standard start-up sequence - OS services To build bare-metal, our makefile disables these defaults; we must supply our own replacements where needed
10 Build settings for bare-metal Compile freestanding CFLAGS = -ffreestanding Link without standard libs or start files LDFLAGS = -nostdlib Link with gcc if need division (b/c no ARM divide instruction) LDLIBS = -lgcc Write our own code for all libs and start files This puts us in an exclusive club
11 Memory Memory is a linear sequence of bytes, indexed by address GB Addresses start at 0, go to (32-bit architecture) MB
12 [8010] [800c] [8008] [8004] [8003] [8002] [8001] [8000] e e3 a e5 9f Memory = linear sequence of indexed bytes Note litte-endian byte ordering same bytes shown on left but instead grouped in 4-byte words [800c] [8008] [8004] [8000] e e3a01902 e59f0004
13 ARM load/store instructions ldr r0, [r1] str r0, [r1] Note: Store is a misfit among ARM instructions operands are in order of src, dst (reverse of all other instructions)
14 ASM and memory When loading a 4-byte word from memory, those bytes could represent: an address, an int, 4 characters an ARM instruction There is no indication of the data type. In fact, the ldr and str instructions are completely agnostic to type: assembly has no type system to guide or restrict what we do with the data being read/written.
15 Why pointers? Access specific memory by address, e.g. FSEL2 Access data by its offset relative to other nearby data (array elements, struct fields) Construct dynamic data structures at runtime Efficiently share/pass references without making copies of large data structures Coerce/manage type system when needed CULTURE FACT: IN CODE, IT S NOT CONSIDERED RUDE TO POINT.
16 Pointer vocabulary An address is a memory location, represented as an unsigned int (because this is a 32-bit architecture). A pointer is a variable that holds an address. The pointee is the data stored at that address. * is the dereference operator, & is address-of. C code address memory int val = 5; int *ptr = &val; 0x810c 0x8108 0x x c
17 C pointer types C has a type system: each variable has a declared type Operations required to respect the data type Can t multiply int* s, can t deference an int Distinguishes pointer variables by type of pointee Dereferencing an int* is an int Dereferencing a char* is a char Typecast can coerce different behavior from compiler
18 Pointer operations: & * int m, n, *p, *q; p = &n; *p = n; // same as prev line? q = p; *q = *p; // same as prev line? p = &m, q = &n; *p = *q; m = n; // same as prev line?
19 C arrays An array is a contiguous sequence of homogeneous elements. An array declaration specifies element type and count of elements. char letters[4]; letters[0] = 'a'; letters[1] = 'b'; 0x c 'a' 'b'?? int nums[2]; nums[0] = 0x107e; 0x ? 0x x e
20 Arrays and pointers You can assign an array to a pointer: int nums[2] = {5, 7}; int *ptr = nums; // ptr = &(nums[0]); An array and a pointer to the first element have a lot in common. Pointer arithmetic operates in element-sized chunks, i.e., scales by sizeof(type) ptr = ptr + 1; // now points to nums[1]
21 Pointer and arrays int n, arr[4], *p; p = arr; p = &arr[0]; // same as prev line? *p = 3; p[0] = 3; // same as prev line? n = *(arr + 1); n = arr[1]; // same as prev line?
22 C-strings No real string data type, just a pointer to a sequence of characters terminated by null char (zero byte)! oldschool char *s = "Stanford"; char arr[] = "University"; char oldschool[] = {'L','e','l','a','n','d','\0'}; char buf[20]; char *ptr; 0x63 0x64 0x00?? 0x4c 0x65 0x6c 0x61 ptr = s; // which assignments are valid? ptr = arr; ptr = buf; arr = ptr; buf = oldschool;
23 Fancy ARM addressing modes Preindex, non-updating ldr r0, [r1, #4] // constant displacement ldr r0, [r1, r2] // variable displacement ldr r0, [r1, r2, lsl #4] // scaled index Preindex, writeback (update dst before use) ldr r0, [r1, #4]! // r1 pre-updated += 4 ldr r0, [r1, r2]! // r1 pre-updated += r2 ldr r0, [r1, r2, lsl #4]! // r1 pre-updated += r2 << 4 Postindex (update dst after use) ldr r0, [r1], #4 // r1 post-updated += 4 ldr r0, [r1], r2 // r1 post-updated += r2 ldr r0, [r1], r2, lsl #4 // r1 post-updated += r2 << 4
24 Pointers: the fault in our *s Pointers are ubiquitous in C and safety is lax. It is on you to be vigilant! Q. For what reasons might a pointer be invalid? Q. What are the consequences of using an invalid pointer? "The fault, dear Brutus, is not in our stars, But in ourselves, that we are underlings." Julius Caesar (I, ii, )
button.c The little button that wouldn t
Goals for today The little button that wouldn't :( the volatile keyword Pointer operations => ARM addressing modes Implementation of C function calls Management of runtime stack, register use button.c
More informationCS 107e Lecture 4: From ASM to C Part 1 Friday, October 5, 2018
CS 107e Lecture 4: From ASM to C Part 1 Friday, October 5, 2018 Computer Systems from the Ground Up Fall 2018 Stanford University Computer Science Department Lecturer: Chris Gregg Logistics Assignment
More informationToday s lecture. Continue exploring C-strings. Pointer mechanics. C arrays. Under the hood: sequence of chars w/ terminating null
Today s lecture Continue exploring C-strings Under the hood: sequence of chars w/ terminating null Review implementation of strcpy, strncpy As abstraction: client of string.h functions Write pig latin
More informationCS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II
CS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II Example: Simple variables Handout written by Julie Zelenski and Nick Parlante A variable is a location in memory. When a variable
More informationToday s lecture. Pointers/arrays. Stack versus heap allocation CULTURE FACT: IN CODE, IT S NOT CONSIDERED RUDE TO POINT.
Pointers/arrays Mechanics, syntax Underlying memory model Array indexing == pointer arithmetic As parameters Stack versus heap allocation Stack declaration, scope, lifetime Heap allocation/deallocation
More informationLecture 4: Outline. Arrays. I. Pointers II. III. Pointer arithmetic IV. Strings
Lecture 4: Outline I. Pointers A. Accessing data objects using pointers B. Type casting with pointers C. Difference with Java references D. Pointer pitfalls E. Use case II. Arrays A. Representation in
More informationPointers. Memory. void foo() { }//return
Pointers Pointers Every location in memory has a unique number assigned to it called it s address A pointer is a variable that holds a memory address A pointer can be used to store an object or variable
More informationC++ ARRAYS POINTERS POINTER ARITHMETIC. Problem Solving with Computers-I
C++ ARRAYS POINTERS POINTER ARITHMETIC Problem Solving with Computers-I General model of memory Sequence of adjacent cells Each cell has 1-byte stored in it Each cell has an address (memory location) Memory
More informationARM. Assembly Language and Machine Code. Goal: Blink an LED
ARM Assembly Language and Machine Code Goal: Blink an LED Review Turning on an LED Connect LED to GPIO 20 3.3V 1k GND 1 -> 3.3V 0 -> 0.0V (GND) Two Steps 1. Configure GPIO20 to be an OUTPUT 2. "Set" GPIO20
More informationWilliam Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats
William Stallings Computer Organization and Architecture 8 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats Addressing Modes Immediate Direct Indirect Register Register Indirect Displacement
More informationAdvanced Operating Systems Embedded from Scratch: System boot and hardware access. Federico Terraneo
Embedded from Scratch: System boot and hardware access federico.terraneo@polimi.it Outline 2/28 Bare metal programming HW architecture overview Linker script Boot process High level programming languages
More informationWriting ARM Assembly. Steven R. Bagley
Writing ARM Assembly Steven R. Bagley Introduction Previously, looked at how the system is built out of simple logic gates Last week, started to look at the CPU Writing code in ARM assembly language Assembly
More informationEE251: Tuesday September 5
EE251: Tuesday September 5 Shift/Rotate Instructions Bitwise logic and Saturating Instructions A Few Math Programming Examples ARM Assembly Language and Assembler Assembly Process Assembly Structure Assembler
More informationARM. Assembly Language and Machine Code. Goal: Blink an LED
ARM Assembly Language and Machine Code Goal: Blink an LED Memory Map 100000000 16 4 GB Peripheral registers are mapped into address space Memory-Mapped IO (MMIO) MMIO space is above physical memory 020000000
More informationLecture 2: C Programm
0 3 E CS 1 Lecture 2: C Programm ing C Programming Procedural thought process No built in object abstractions data separate from methods/functions Low memory overhead compared to Java No overhead of classes
More informationHomework #3 CS2255 Fall 2012
Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation
More informationLecture 8: Pointer Arithmetic (review) Endianness Functions and pointers
CSE 30: Computer Organization and Systems Programming Lecture 8: Pointer Arithmetic (review) Endianness Functions and pointers Diba Mirza University of California, San Diego 1 Q: Which of the assignment
More informationIn Java we have the keyword null, which is the value of an uninitialized reference type
+ More on Pointers + Null pointers In Java we have the keyword null, which is the value of an uninitialized reference type In C we sometimes use NULL, but its just a macro for the integer 0 Pointers are
More informationUniversity of California, San Diego CSE 30 Computer Organization and Systems Programming Winter 2014 Midterm Dr. Diba Mirza
Name Student ID University of California, San Diego CSE 30 Computer Organization and Systems Programming Winter 2014 Midterm Dr. Diba Mirza Name of person to your left Name of person to your right Please
More informationAnnouncements. assign0 due tonight. Labs start this week. No late submissions. Very helpful for assign1
Announcements assign due tonight No late submissions Labs start this week Very helpful for assign1 Goals for Today Pointer operators Allocating memory in the heap malloc and free Arrays and pointer arithmetic
More informationLecture 4 (part 2): Data Transfer Instructions
Lecture 4 (part 2): Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Diba Mirza Dept. of Computer Science and Engineering University of California, San Diego Assembly Operands:
More informationCS 61c: Great Ideas in Computer Architecture
Arrays, Strings, and Some More Pointers June 24, 2014 Review of Last Lecture C Basics Variables, functioss, control flow, types, structs Only 0 and NULL evaluate to false Pointers hold addresses Address
More informationCS61C Machine Structures. Lecture 5 C Structs & Memory Mangement. 1/27/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/
CS61C Machine Structures Lecture 5 C Structs & Memory Mangement 1/27/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L05 C Structs (1) C String Standard Functions
More informationIntroduction to Scientific Computing and Problem Solving
Introduction to Scientific Computing and Problem Solving Lecture #22 Pointers CS4 - Introduction to Scientific Computing and Problem Solving 2010-22.0 Announcements HW8 due tomorrow at 2:30pm What s left:
More informationCS 31: Intro to Systems Arrays, Structs, Strings, and Pointers. Kevin Webb Swarthmore College March 1, 2016
CS 31: Intro to Systems Arrays, Structs, Strings, and Pointers Kevin Webb Swarthmore College March 1, 2016 Overview Accessing things via an offset Arrays, Structs, Unions How complex structures are stored
More informationCS C Primer. Tyler Szepesi. January 16, 2013
January 16, 2013 Topics 1 Why C? 2 Data Types 3 Memory 4 Files 5 Endianness 6 Resources Why C? C is exteremely flexible and gives control to the programmer Allows users to break rigid rules, which are
More informationARM Shift Operations. Shift Type 00 - logical left 01 - logical right 10 - arithmetic right 11 - rotate right. Shift Amount 0-31 bits
ARM Shift Operations A novel feature of ARM is that all data-processing instructions can include an optional shift, whereas most other architectures have separate shift instructions. This is actually very
More informationCS Programming In C
CS 24000 - Programming In C Week Two: Basic C Program Organization and Data Types Zhiyuan Li Department of Computer Science Purdue University, USA 2 int main() { } return 0; The Simplest C Program C programs
More informationCS61C Machine Structures. Lecture 4 C Structs & Memory Management. 9/5/2007 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/
CS61C Machine Structures Lecture 4 C Structs & Memory Management 9/5/2007 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Structs (1) C String Standard Functions
More informationECE 206, Fall 2001: Lab 3
ECE 206, : Lab 3 Data Movement Instructions Learning Objectives This lab will give you practice with a number of LC-2 programming constructs. In particular you will cover the following topics: - Load/store
More informationComputer Architecture and Organization. Instruction Sets: Addressing Modes and Formats
Computer Architecture and Organization Instruction Sets: Addressing Modes and Formats Addressing Modes Immediate Direct Indirect Register Register Indirect Displacement (Indexed) Stack Immediate Addressing
More informationREFERENCES, POINTERS AND STRUCTS
REFERENCES, POINTERS AND STRUCTS Problem Solving with Computers-I https://ucsb-cs16-sp17.github.io/ Pointer assignment 2 int *p1, *p2, x; p1 = &x; p2 = p1; Q: Which of the following pointer diagrams best
More informationOverview COMP Microprocessors and Embedded Systems. Lecture 11: Memory Access - I. August, 2003
Overview COMP 3221 Microprocessors and Embedded Systems Memory Access in Assembly Data Structures in Assembly Lecture 11: Memory Access - I http://www.cse.unsw.edu.au/~cs3221 August, 2003 Saeid@unsw.edu.au
More informationECE251: Tuesday Aug. 29
ECE251: Tuesday Aug. 29 ARM Cortex Architecture: Data Movement Loading memory data into registers Storing register data into memory Indexed Addressing Reading: Chapters 1 and 5 Labs: #1 due this week at
More informationCS2351 Data Structures. Lecture 7: A Brief Review of Pointers in C
CS2351 Data Structures Lecture 7: A Brief Review of Pointers in C 1 About this lecture Pointer is a useful object that allows us to access different places in our memory We will review the basic use of
More informationSpecial Topics for Embedded Programming
1 Special Topics for Embedded Programming ETH Zurich Fall 2018 Reference: The C Programming Language by Kernighan & Ritchie 1 2 Overview of Topics Microprocessor architecture Peripherals Registers Memory
More informationLecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?
Lecture 14 No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions? Friday, February 11 CS 215 Fundamentals of Programming II - Lecture 14 1 Outline Static
More informationPointers. 1 Background. 1.1 Variables and Memory. 1.2 Motivating Pointers Massachusetts Institute of Technology
Introduction to C++ Massachusetts Institute of Technology ocw.mit.edu 6.096 Pointers 1 Background 1.1 Variables and Memory When you declare a variable, the computer associates the variable name with a
More informationComparison InstruCtions
Status Flags Now it is time to discuss what status flags are available. These five status flags are kept in a special register called the Program Status Register (PSR). The PSR also contains other important
More informationClass Information ANNOUCEMENTS
Class Information ANNOUCEMENTS Third homework due TODAY at 11:59pm. Extension? First project has been posted, due Monday October 23, 11:59pm. Midterm exam: Friday, October 27, in class. Don t forget to
More informationData in Memory. variables have multiple attributes. variable
Data in Memory variables have multiple attributes variable symbolic name data type (perhaps with qualifier) allocated in data area, stack, or heap duration (lifetime or extent) storage class scope (visibility
More informationMidterm Sample Questions. a) What evaluates to FALSE in C? What evaluates to TRUE?
Midterm Syllabus: 1. Number systems a. Signed and unsigned representations b. Conversion between different representations c. Overflow condition 2. C Pointers 3. Dynamic Memory Allocation 4. C Data structures:
More informationJava and C I. CSE 351 Spring Instructor: Ruth Anderson
Java and C I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Homework 5 Due TONIGHT Wed
More informationJava and C CSE 351 Spring
Java and C CSE 351 Spring 2018 https://xkcd.com/801/ Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq
More informationENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design
ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2016 1 ISA is the HW/SW
More informationArrays and Pointers in C. Alan L. Cox
Arrays and Pointers in C Alan L. Cox alc@rice.edu Objectives Be able to use arrays, pointers, and strings in C programs Be able to explain the representation of these data types at the machine level, including
More informationLab5 2-Nov-18, due 16-Nov-18 (2 weeks duration) Lab6 16-Nov-19, due 30-Nov-18 (2 weeks duration)
CS1021 AFTER READING WEEK Mid-Semester Test NOW Thurs 8th Nov @ 9am in Goldsmith Hall (ALL students to attend at 9am) Final 2 Labs Lab5 2-Nov-18, due 16-Nov-18 (2 weeks duration) Lab6 16-Nov-19, due 30-Nov-18
More informationOperating System Labs. Yuanbin Wu
Operating System Labs Yuanbin Wu CS@ECNU Operating System Labs Project 2 Due 21:00, Oct. 24 Project 3 Group of 3 If you can not find a partner, drop us an email You now have 3 late days, but start early!
More informationARM Processor and Memory Architecture. Goal: Turn on an LED
ARM Processor and Memory Architecture Goal: Turn on an LED Babbage Difference Engine Analytical Engine Universal Computer http://www.theguardian.com/technology/2015/apr/12/thrilling-adventures-ada-lovelace-charles-babbage-sydney-padua
More informationReview: C Strings. A string in C is just an array of characters. Lecture #4 C Strings, Arrays, & Malloc
CS61C L4 C Pointers (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #4 C Strings, Arrays, & Malloc Albert Chae Instructor 2008-06-26 Review: C Strings A string in C is just an array
More informationHW1 due Monday by 9:30am Assignment online, submission details to come
inst.eecs.berkeley.edu/~cs61c CS61CL : Machine Structures Lecture #2 - C Pointers and Arrays Administrivia Buggy Start Lab schedule, lab machines, HW0 due tomorrow in lab 2009-06-24 HW1 due Monday by 9:30am
More information18-600: Recitation #3
18-600: Recitation #3 Bomb Lab & GDB Overview September 12th, 2017 1 Today X86-64 Overview Bomb Lab Introduction GDB Tutorial 2 3 x86-64: Register Conventions Arguments passed in registers: %rdi, %rsi,
More informationComputer Systems C S Cynthia Lee
Computer Systems C S 1 0 7 Cynthia Lee 2 Topics ARRAYS AND POINTERS IN C: This will solidify and deepen your understanding of C strings They re just pointers/arrays of char! Pointers to arrays, Pointers
More informationComputer Organization & Systems Exam I Example Questions
Computer Organization & Systems Exam I Example Questions 1. Pointer Question. Write a function char *circle(char *str) that receives a character pointer (which points to an array that is in standard C
More informationComp 11 Lectures. Mike Shah. June 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures June 26, / 57
Comp 11 Lectures Mike Shah Tufts University June 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures June 26, 2017 1 / 57 Please do not distribute or host these slides without prior permission. Mike
More informationARM Assembler Workbook. CS160 Computer Organization Version 1.1 October 27 th, 2002 Revised Fall 2005
ARM Assembler Workbook CS160 Computer Organization Version 1.1 October 27 th, 2002 Revised Fall 2005 ARM University Program Version 1.0 January 14th, 1997 Introduction Aim This workbook provides the student
More informationECE 598 Advanced Operating Systems Lecture 4
ECE 598 Advanced Operating Systems Lecture 4 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 28 January 2016 Announcements HW#1 was due HW#2 was posted, will be tricky Let me know
More informationCompilers and Interpreters
Compilers and Interpreters Pointers, the addresses we can see Programs that write other programs Managing the details A compiler is a program that, when fed itself as input, produces ITSELF! Then how was
More informationMalloc Lab & Midterm Solutions. Recitation 11: Tuesday: 11/08/2016
Malloc Lab & Midterm Solutions Recitation 11: Tuesday: 11/08/2016 Malloc 2 Important Notes about Malloc Lab Malloc lab has been updated from previous years Supports a full 64 bit address space rather than
More informationMemory and Addresses. Pointers in C. Memory is just a sequence of byte-sized storage devices.
Memory and Addresses Memory is just a sequence of byte-sized storage devices. 1 The bytes are assigned numeric addresses, starting with zero, just like the indexing of the cells of an array. It is the
More informationUW CSE 351, Winter 2013 Final Exam
Full Name: Student ID #: UW CSE 351, Winter 2013 Final Exam March 20, 2013 2:30pm - 4:20pm Instructions: Write your full name and UW student ID number on the front of the exam. When the exam begins, make
More informationRecitation #11 Malloc Lab. November 7th, 2017
18-600 Recitation #11 Malloc Lab November 7th, 2017 1 2 Important Notes about Malloc Lab Malloc lab has been updated from previous years Supports a full 64 bit address space rather than 32 bit Encourages
More informationMemory, Arrays & Pointers
1 Memory, Arrays & Pointers Memory int main() { char c; int i,j; double x; c i j x 2 Arrays Defines a block of consecutive cells int main() { int i; int a[3]; i a[0] a[1] a[2] Arrays - the [ ] operator
More informationEL2310 Scientific Programming
Lecture 11: Structures and Memory (yaseminb@kth.se) Overview Overview Lecture 11: Structures and Memory Structures Continued Memory Allocation Lecture 11: Structures and Memory Structures Continued Memory
More informationPointers in C/C++ 1 Memory Addresses 2
Pointers in C/C++ Contents 1 Memory Addresses 2 2 Pointers and Indirection 3 2.1 The & and * Operators.............................................. 4 2.2 A Comment on Types - Muy Importante!...................................
More informationx86 architecture et similia
x86 architecture et similia 1 FREELY INSPIRED FROM CLASS 6.828, MIT A full PC has: PC architecture 2 an x86 CPU with registers, execution unit, and memory management CPU chip pins include address and data
More informationCS 107 Lecture 5: Arrays. and Pointers in C. Monday, January 22, Stanford University. Computer Science Department
CS 107 Address Value Lecture 5: Arrays 8 and Pointers in C 0x128 3 0x120 Monday, January 22, 2018 9 0x118 Computer Systems Winter 2018-4 Stanford University 0x110 Computer Science Department 2 Reading:
More informationAgenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part II) Instructors: Randy H. Katz David A. Patterson http://inst.eecs.berkeley.edu/~cs61c/sp11 Spring 2011 -- Lecture
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 5 C Memory Management Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia CS 61C L04 C Structures, Memory Management (1) 2004-09-10 Barry
More informationProgramming in C - Part 2
Programming in C - Part 2 CPSC 457 Mohammad Reza Zakerinasab May 11, 2016 These slides are forked from slides created by Mike Clark Where to find these slides and related source code? http://goo.gl/k1qixb
More informationSTEVEN R. BAGLEY ARM: PROCESSING DATA
STEVEN R. BAGLEY ARM: PROCESSING DATA INTRODUCTION CPU gets instructions from the computer s memory Each instruction is encoded as a binary pattern (an opcode) Assembly language developed as a human readable
More informationECE 15B COMPUTER ORGANIZATION
ECE 15B COMPUTER ORGANIZATION Lecture 13 Strings, Lists & Stacks Announcements HW #3 Due next Friday, May 15 at 5:00 PM in HFH Project #2 Due May 29 at 5:00 PM Project #3 Assigned next Thursday, May 19
More informationPointers, Dynamic Data, and Reference Types
Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple
More informationSystems Architecture The ARM Processor
Systems Architecture The ARM Processor The ARM Processor p. 1/14 The ARM Processor ARM: Advanced RISC Machine First developed in 1983 by Acorn Computers ARM Ltd was formed in 1988 to continue development
More informationCourse organization. Course introduction ( Week 1)
Course organization Course introduction ( Week 1) Code editor: Emacs Part I: Introduction to C programming language (Week 2-9) Chapter 1: Overall Introduction (Week 1-3) Chapter 2: Types, operators and
More informationCS 61C: Great Ideas in Computer Architecture. C Arrays, Strings, More Pointers
CS 61C: Great Ideas in Computer Architecture C Arrays, Strings, More Pointers Instructor: Justin Hsia 6/20/2012 Summer 2012 Lecture #3 1 Review of Last Lecture C Basics Variables, Functions, Flow Control,
More informationHardware: Logical View
Hardware: Logical View CPU Memory Bus Disks Net USB Etc. 1 Hardware: Physical View USB I/O controller Storage connections CPU Memory 2 Hardware: 351 View (version 0) instructions? Memory CPU data CPU executes
More informationARM ASSEMBLY PROGRAMMING
ARM ASSEMBLY PROGRAMMING 1. part RAB Računalniška arhitektura 1 Intro lab : Addition in assembler Adding two variables : res := stev1 + stev2 Zbirni jezik Opis ukaza Strojni jezik ldr r1, stev1 R1 M[0x20]
More informationJava and C. CSE 351 Autumn 2018
Java and C CSE 351 Autumn 2018 Instructor: Teaching Assistants: Justin Hsia Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie Tian Teagan
More informationL14: Structs and Alignment. Structs and Alignment. CSE 351 Spring Instructor: Ruth Anderson
Structs and Alignment CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Lab 2 due TONIGHT
More informationCSE351: Memory, Data, & Addressing I
CSE351: Memory, Data, & Addressing I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis http://xkcd.com/138/
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 5 C Memory Management Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia CS61C L05 C Structures, Memory Management (1) 2005-01-28 The
More informationAssembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction
Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction E I P CPU isters Condition Codes Addresses Data Instructions Memory Object Code Program Data OS Data Topics Assembly Programmer
More informationProgramming in C. Lecture 9: Tooling. Dr Neel Krishnaswami. Michaelmas Term
Programming in C Lecture 9: Tooling Dr Neel Krishnaswami Michaelmas Term 2017-2018 1 / 24 Undefined and Unspecified Behaviour 2 / 24 Undefined and Unspecified Behaviour We have seen that C is an unsafe
More informationFORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):
FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): 1. If a function has default arguments, they can be located anywhere
More informationSystems Programming and Computer Architecture ( )
Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-0061-00) Timothy Roscoe Herbstsemester 2016 1 4: Pointers Computer Architecture and Systems Programming
More informationDo not start the test until instructed to do so!
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices
More informationMemory Allocation in C C Programming and Software Tools. N.C. State Department of Computer Science
Memory Allocation in C C Programming and Software Tools N.C. State Department of Computer Science The Easy Way Java (JVM) automatically allocates and reclaims memory for you, e.g... Removed object is implicitly
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #3 C Strings, Arrays, & Malloc 2007-06-27 Scott Beamer, Instructor Sun announces new supercomputer: Sun Constellation CS61C L3 C Pointers
More informationARM Memory Addressing and Function Calls
ARM Memory Addressing and Function Calls Tom Kelliher, CS 220 1 Administrivia Today s Objectives 1. Use indirect addressing to move data between registers and memory. 2. Manipulate numeric and character
More informationA sneak peek into SVE and VLA programming
A sneak peek into SVE and VLA programming Francesco Petrogalli September 2018 Page 1 of 19 Contents Contents 2 Introduction 2 1 SVE: an overview 3 New architectural registers...............................................
More informationNumber Review. Lecture #3 More C intro, C Strings, Arrays, & Malloc Variables. Clarification about counting down
CS61C L3 C Pointers (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #3 More C intro, C Strings, Arrays, & Malloc Albert Chae Instructor 2008-06-25 Number Review Sign and magnitude
More informationVirtual Memory 1. Virtual Memory
Virtual Memory 1 Virtual Memory key concepts virtual memory, physical memory, address translation, MMU, TLB, relocation, paging, segmentation, executable file, swapping, page fault, locality, page replacement
More informationCS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018
CS 31: Intro to Systems Pointers and Memory Kevin Webb Swarthmore College October 2, 2018 Overview How to reference the location of a variable in memory Where variables are placed in memory How to make
More informationVirtual Memory 1. Virtual Memory
Virtual Memory 1 Virtual Memory key concepts virtual memory, physical memory, address translation, MMU, TLB, relocation, paging, segmentation, executable file, swapping, page fault, locality, page replacement
More informationHacking in C. Pointers. Radboud University, Nijmegen, The Netherlands. Spring 2019
Hacking in C Pointers Radboud University, Nijmegen, The Netherlands Spring 2019 Allocation of multiple variables Consider the program main(){ char x; int i; short s; char y;... } What will the layout of
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #33 Pointer Arithmetic
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #33 Pointer Arithmetic In this video let me, so some cool stuff which is pointer arithmetic which helps you to
More informationCSE351 Spring 2018, Final Exam June 6, 2018
CSE351 Spring 2018, Final Exam June 6, 2018 Please do not turn the page until 2:30. Last Name: First Name: Student ID Number: Name of person to your left: Name of person to your right: Signature indicating:
More information[0569] p 0318 garbage
A Pointer is a variable which contains the address of another variable. Declaration syntax: Pointer_type *pointer_name; This declaration will create a pointer of the pointer_name which will point to the
More informationAnnouncements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls
Announcements HW1 is due on this Friday (Sept 12 th ) Appendix A is very helpful to HW1. Check out system calls on Page A-48. Ask TA (Liquan chen: liquan@ece.rutgers.edu) about homework related questions.
More information