Accessing Data in Memory
|
|
- Sharlene Allen
- 6 years ago
- Views:
Transcription
1 Accessing Data in Memory You will implement a simple C function that parses a tangled list of binary records in memory, processing them nonsequentially, and produces a simple text report. The function must conform to the following interface specification: / Untangle() parses a chain of records stored in the memory region pointed to by pbuffer and writes a report to the supplied file stream. Formatting details are provided in the specification for the assignment. Pre: pbuffer points to a region of memory formatted as specified. Log points to an opened text file. Post: The target of pbuffer has been parsed and a report written as specified. Returns: the number of tokens in the supplied quotation. / uint8_t Untangle(const uint8_t pbuffer, FILE Log); The first two bytes of the memory region contain the offset at which you will begin processing records; the offset is stored as a uint16_t value. This offset is followed by a collection of word records, each consisting of an integer value, a sequence of characters, and another integer value: Length of word Characters in word Offset of next word uint8_t chars uint16_t The first value in each record specifies the number of characters in the sequence for that record. Since words are never very long, this value will be stored as a uint8_t, which has a range of This is followed by a sequence of ASCII codes for the characters that make up the word. (The term "word" is used a bit loosely here.) The last character is followed immediately (no string terminator!) by a uint16_t value specifying the offset of the next word record in the list. Note that the length of the record depends upon the number of characters in the word, and so these records are variable-length. While traversing the memory region, your program will write to a text file reporting the results of the traversal. Aside from a header, each line of the file will specify the hexadecimal offset at which a word record was found, and then the word from that record. Memory Layout: Your program will deal with a single chunk of memory, in the format described above. Here is a hex dump of a sample memory region: A 0B 0C 0D 0E 0F F _..species5..vir B 3A 00 0A 6D 6F F tue;:..moderatio E E E 7A 00 nu..vice.d..inz F is@..of#..but D 2D F 6D a...--I..Thomas E C 00 0A R..Paine...isl D 6F F 6E 2B C 77 Moderation+..alw E D ays...in...tempe C 5A 00 0A E C 65 2C 30 r,z..principle, C 00..a A 0B 0C 0D 0E 0F 1
2 Since I'm using x86 hardware, integer values are stored in memory in little-endian order; that is, the low-order byte is stored first (at the smallest address) and the high-order byte is stored last (at the largest address). So the bytes of a multibyte integer value appear to be reversed. As a programmer, you usually do not need to take the byte-ordering into account since the compiler will generate machine language compatible with your hardware, and that will make use of the bytes in the appropriate manner. But, when you're reading memory displays, you must take the byte-ordering into account. So, looking at the first two bytes of the memory block, we see that the word record we will process first occurs at relative offset 0x005F from the beginning of the memory block. The first word record is: 0A 4D 6F F 6E 2B 00 The length of the word is 0x0A or 10 in base-10. The ASCII codes are 4D 6F F 6E. The next record is at a relative offset of 0x002B. Here is the log file, named "Log.txt", corresponding to the given input files: 005F: Moderation 002B: in 007A: temper, 005A: is 006C: always 0091: a 000C: virtue; 003A: but 0016: moderation 0075: in 0084: principle, 0030: is 0040: a 0002: species 0035: of 0023: vice. 0044: : Thomas 0052: Paine Number of words reported: 19 To aid in your testing, a simple driver (driver.c) will be posted on the website. This driver will read a binary file and build a suitable in-memory data region, and then call your implementation of Untangle(). Some sample binary files will also be posted to use with this driver. In addition, a binary file generator (tangle) will be posted as a 32-bit Linux executable. You may use this program to generate additional binary test files for the aforementioned simple driver. Type tangle --help for more information. Submitting Your Program: You will submit this assignment to the Curator System (read the Student Guide), and it will be graded automatically. Instructions for submitting, and a description of how the grading is done, are contained in the Student Guide. For this project you should develop your implementation, using separate compilation, and then submit a single.c file containing your function implementation and any necessary include directives. You may write helper functions that are called by your code; if so, be sure to put any necessary declarations for those in your.c file, not in a header file. Your solution should not write to standard output. Submit your source file to the Curator system under the heading HW10. 2
3 You will be allowed multiple submissions for this assignment. Use them wisely. Test your program thoroughly before submitting it. If you do not get a perfect score, analyze the problem carefully and test your fix before submitting again. The highest score you achieve will be counted. The Student Guide and link to the submission client can be found at: Evaluation: Your submitted code will be compiled with a driver program, which will allocate and initialize a memory region in the format described above, open a FILE pointer on an empty log file, and call your implementation of the function Untangle(). An appropriate header file will be provided, containing a declaration for your function implementation and any include directives needed for the prototype. The supplied header file will be named Untangle.h, so if you need to include that header into your.c file, make sure you use that name for it. Your submitted program will be assigned a score based upon the runtime testing performed by the Curator System. After that, your program may be given a brief evaluation by a TA, who will consider whether you have followed the requirements in the specification above, and how well you have documented your implementation. See the Programming Standards page on the course website for specific requirements that should be observed in this course. This evaluation will produce a deduction (ideally zero, of course) that will be applied to your runtime testing score to produce your final score for the project. Pledge: Each of your program submissions must be pledged to conform to the Honor Code requirements for this course. Specifically, you must include the pledge statement provided with the earlier project specifications in the header comment for your source code file. 3
4 Brief tutorial on using pointer arithmetic and pointer typecasts in C: This assignment does not require any esoteric portions of the C language, but it does require an understanding of pointer manipulations. First of all, you must understand the effect and uses of a pointer typecast. Consider the following snippet: uint16_t x = malloc(sizeof(short int)); // 1 x = 684; // 2 Statement 1 causes the allocation of a two-byte region of memory, whose address is stored in the pointer x. Statement 2 stores the value 684 (0x2AC or in binary) into that two-byte region. So the current situation in memory would be: x the Stack???? low byte (at low address) high byte (at next address) the Heap (The bytes are stored in little-endian order, just as they would be on any Intel-compatible system.) If you dereference the pointer x, you'll obtain the contents of the two bytes beginning at the address stored in x. That's because x was declared as a pointer to something of type uint16_t, and sizeof(uint16_t) is 2 (bytes). Now consider: uint8_t y = NULL; // 3 y = (uint8_t) x; // 4 uint8_t z = y; // 5 uint16_t w = x; // 6 The effect of statement 4 is that y takes on the same value as x; pointer variables are 32 bits wide, regardless of the type of target they may take, and so the value of x will fit neatly into y. So, why the typecast? Simply that C is somewhat picky about assigning a pointer of one type to a pointer of another type, and the typecast formalizes the logic so that the compiler will accept it. If you dereference y, you'll obtain the contents of the single byte at the address stored in y, since sizeof(uint8_t) is 1. Hence, statement 5 will assign the value 0xAC or 172 to z, but statement 6 will assign the two-byte value 0x02AC or 684 to the variable w. Here's a brief summary: 4
5 Note how we can use the type of a pointer to determine how many bytes of memory we obtain when we dereference that pointer, as well as how those bytes are interpreted. This can be really useful. The second thing to understand is how pointer arithmetic works. Here is a simple summary: T p, q; // Take T to represent a generic type.... // Assume p gets assigned a target in here. q = p + K; // Let K be an expression that evaluates to an integer. Then the value of q will be: p + K sizeof(t). Note well: this is very dangerous unless you understand how to make use of it. In some respects, this is really quite simple; maybe too simple. The essential thing you must always remember is that if you want to move a pointer by a specific number of bytes, it's simplest if the pointer is a char or uint8_t, since the arithmetic will then provide you with byte-level control of the pointer's logical position in memory. The following loop would walk the pointer y through the bytes of the target of x (the uint16_t seen earlier): uint8_t y = (uint8_t) x; uint32_t bytesread = 0; while ( bytesread < sizeof(uint16_t) ) { printf("%"prix8"\n", y); // print value of current byte in hex; // 'x' causes output in hex; // 'X' capitalizes the hex } ++y; ++bytesread; // step to next byte of target of x You might want to experiment with this a bit Now for copying values from memory into your variables (which are also in memory also, of course)... The simplest approach is use appropriate variable types and pointer typecasts. Suppose that the uint8_t pointer p points to some location in memory and you want to obtain the next four bytes and interpret them as an int32_t value; then you could try these: int32_t N = p; // NO. This takes only 1 byte! int32_t q = (int32_t) p; // Slap an int32_t onto the location; int32_t N = q; // so this takes 4 bytes as desired. int32_t N = ((int32_t) p); // Or do it all in one fell swoop. The last form is the most idiomatic in the C language; it creates a temporary, nameless int32_t from p and then dereferences it to obtain the desired value. Note that this doesn't move p. So, if you wanted to copy the next few bytes you'd need to apply pointer arithmetic to move p past the bytes you just copied: p = p + sizeof(int32_t); // Since p is a uint8_t, this will move p forward // by exactly the size of an int32_t. One final C tip may be of use. The C Standard Library includes a function that will copy a specified number of bytes from one region of memory into another region of memory: memcpy(). You can find a description of how to use the function in any decent C language reference, including the C tutorial linked from the Resources page of the course website. 5
6 The C Standard, section says: When an expression that has integer type is added to or subtracted from a pointer, the result has the type of the pointer operand. If the pointer operand points to an element of an array object, and the array is large enough, the result points to an element offset from the original element such that the difference of the subscripts of the resulting and original array elements equals the integer expression. In other words, if the expression P points to the i-th element of an array object, the expressions (P)+N (equivalently, N+(P)) and (P)-N (where N has the value n) point to, respectively, the i+n-th and i n-th elements of the array object, provided they exist. Moreover, if the expression P points to the last element of an array object, the expression (P)+1 points one past the last element of the array object, and if the expression Q points one past the last element of an array object, the expression (Q)-1 points to the last element of the array object. If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined. If the result points one past the last element of the array object, it shall not be used as the operand of a unary operator that is evaluated. A useful Linux utility: This assignment requires processing in-memory data. The supplied test driver makes use of an input file that stores the exact contents of a sample memory block of the type that your function must process. Because the file contains exactly the same bytes as would be stored in memory, there is no point in trying to view the contents of the file in a typical editor, or in cat'ing it to the console window. However, there is a handy Linux utility: hexdump. The example below uses the "canonical" switch to display the contents of a binary file as formatted text. The left side shows the offset of the beginning of each "line". The middle portion shows the bytes contained in the file, formatted in hexadecimal and chopped into 16-byte chunks. The right side shows the corresponding ASCII characters (for bytes whose values are valid ASCII codes). MSI-Ubuntu HW > hexdump -C Data01.bin c f 75 3c the...you<..D e f 6f c 1c ay...choose,...d c b f f ay,...yourg..cho e 0e e 64 4d f ac ice...andm..do e is...way...wh e at...integritya f c your,..characte a f e 6b 2c r...youy..think, f d d 2d 9a your b e f a y...yourt..herac a0 6c d0 litus...is`..is b ea f 75 be what...you...b c f 6d 65 2e c f0 00 ecome...light d f b8 00 0c e 79 2e 2e.who...destiny e0 2e e f it...is...you f f that...guides f d f.yourF..The...co e e f ntent...of%..wha ts
Pointer Casts and Data Accesses
C Programming Pointer Casts and Data Accesses For this assignment, you will implement a C function similar to printf(). While implementing the function you will encounter pointers, strings, and bit-wise
More informationHere is a C function that will print a selected block of bytes from such a memory block, using an array-based view of the necessary logic:
Pointer Manipulations Pointer Casts and Data Accesses Viewing Memory The contents of a block of memory may be viewed as a collection of hex nybbles indicating the contents of the byte in the memory region;
More informationPointer Accesses to Memory and Bitwise Manipulation
C Programming Pointer Accesses to Memory and Bitwise Manipulation This assignment consists of two parts, the second extending the solution to the first. Q1 [80%] Accessing Data in Memory Here is a hexdump
More informationPointer Accesses to Memory and Bitwise Manipulation
C Programming Pointer Accesses to Memory and Bitwise Manipulation This assignment consists of two parts, the second extending the solution to the first. Q1 [80%] Accessing Data in Memory Here is a hexdump
More informationPointer Accesses to Memory and Bitwise Manipulation
C Programming Pointer Accesses to Memory and Bitwise Manipulation This assignment consists of implementing a function that can be executed in two modes, controlled by a switch specified by a parameter
More informationHere is a C function that will print a selected block of bytes from such a memory block, using an array-based view of the necessary logic:
Pointer Manipulations Pointer Casts and Data Accesses Viewing Memory The contents of a block of memory may be viewed as a collection of hex nybbles indicating the contents of the byte in the memory region;
More informationgcc o driver std=c99 -Wall driver.c bigmesa.c
C Programming Simple Array Processing This assignment consists of two parts. The first part focuses on array read accesses and computational logic. The second part focuses on array read/write access and
More informationgcc o driver std=c99 -Wall driver.c everynth.c
C Programming The Basics This assignment consists of two parts. The first part focuses on implementing logical decisions and integer computations in C, using a C function, and also introduces some examples
More informationCS 2604 Minor Project 1 Summer 2000
RPN Calculator For this project, you will design and implement a simple integer calculator, which interprets reverse Polish notation (RPN) expressions. There is no graphical interface. Calculator input
More informationCS 1044 Program 6 Summer I dimension ??????
Managing a simple array: Validating Array Indices Most interesting programs deal with considerable amounts of data, and must store much, or all, of that data on one time. The simplest effective means for
More informationCS 2604 Minor Project 1 DRAFT Fall 2000
RPN Calculator For this project, you will design and implement a simple integer calculator, which interprets reverse Polish notation (RPN) expressions. There is no graphical interface. Calculator input
More informationDynamic Allocation in C
Dynamic Allocation in C C Pointers and Arrays 1 The previous examples involved only targets that were declared as local variables. For serious development, we must also be able to create variables dynamically,
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 informationCS 2505 Computer Organization I Test 2. Do not start the test until instructed to do so! printed
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page fact sheet. Your fact sheet may contain definitions and examples,
More informationDynamic Allocation in C
Dynamic Allocation in C 1 The previous examples involved only targets that were declared as local variables. For serious development, we must also be able to create variables dynamically, as the program
More informationstruct _Rational { int64_t Top; // numerator int64_t Bottom; // denominator }; typedef struct _Rational Rational;
Creating a Data Type in C Rational Numbers For this assignment, you will use the struct mechanism in C to implement a data type that represents rational numbers. A set can be modeled using the C struct:
More informationCreating a String Data Type in C
C Programming Creating a String Data Type in C For this assignment, you will use the struct mechanism in C to implement a data type that models a character string: struct _String { char data; dynamically-allocated
More informationBoth parts center on the concept of a "mesa", and make use of the following data type:
C Programming Simple Array Processing This assignment consists of two parts. The first part focuses on array read accesses and computational logic. The second part requires solving the same problem using
More informationIntroduction to Computer Science Midterm 3 Fall, Points
Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do
More informationYou will provide an implementation for a test driver and for a C function that satisfies the conditions stated in the header comment:
Decision-making in C (Possibly) Intersecting Rectangles Background A rectangle in the xy-plane, whose sides are parallel to the coordinate axes can be fully specified by giving the coordinates of one corner
More information1. A student is testing an implementation of a C function; when compiled with gcc, the following x86-32 assembly code is produced:
This assignment refers to concepts discussed in the course notes on gdb and the book The Art of Debugging by Matloff & Salzman. The questions are definitely "hands-on" and will require some reading beyond
More informationThe assignment requires solving a matrix access problem using only pointers to access the array elements, and introduces the use of struct data types.
C Programming Simple Array Processing The assignment requires solving a matrix access problem using only pointers to access the array elements, and introduces the use of struct data types. Both parts center
More informationCS 2505 Computer Organization I Test 2. Do not start the test until instructed to do so! printed
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 informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
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 informationNumber Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers
Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We
More informationint32_t Buffer[BUFFSZ] = {-1, -1, -1, 1, -1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, -1, -1, -1, -1, -1}; int32_t* A = &Buffer[5];
This assignment refers to concepts discussed in the course notes on gdb and the book The Art of Debugging by Matloff & Salzman. The questions are definitely "hands-on" and will require some reading beyond
More information// Initially NULL, points to the dynamically allocated array of bytes. uint8_t *data;
Creating a Data Type in C Bytes For this assignment, you will use the struct mechanism in C to implement a data type that represents an array of bytes. This data structure could be used kind of like a
More informationGiven that much information about two such rectangles, it is possible to determine whether they intersect.
Decision-making in C (Possibly) Intersecting Rectangles Background A rectangle in the xy-plane, whose sides are parallel to the coordinate axes can be fully specified by giving the coordinates of one corner
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 informationCPS 104 Computer Organization and Programming
CPS 104 Computer Organization and Programming Lecture-3 : Memory, Bit Operations. Sep. 3, 1999 Dietolf (Dee) Ramm http://www.cs.duke.edu/~dr/cps104.html CPS104 Lec3.1 GK&DR Fall 1999 Administrivia Homework
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 informationA rectangle in the xy-plane, whose sides are parallel to the coordinate axes can be fully specified by giving the coordinates of two opposite corners:
Decision-making in C (Possibly) Intersecting Rectangles Background A rectangle in the xy-plane, whose sides are parallel to the coordinate axes can be fully specified by giving the coordinates of two opposite
More informationDecision Logic: if, if else, switch, Boolean conditions and variables
CS 1044 roject 4 Summer I 2007 Decision Logic: if, if else, switch, Boolean conditions and variables This programming assignment uses many of the ideas presented in sections 3 through 5 of the course notes,
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 informationData Structure Series
Data Structure Series This series is actually something I started back when I was part of the Sweet.Oblivion staff, but then some things happened and I was no longer able to complete it. So now, after
More informationC Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:
C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should
More informationRepresentation of Information
Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept
More informationSimple C Dynamic Data Structure
C Programming Simple C Dynamic Data Structure For this assignment, you will implement a program that manipulates a simple queue of integer values. Your program will include the following features: IntegerDT
More informationA Capacity: 10 Usage: 4 Data:
Creating a Data Type in C Integer Set For this assignment, you will use the struct mechanism in C to implement a data type that represents sets of integers. A set can be modeled using the C struct: struct
More informationcalling a function - function-name(argument list); y = square ( z ); include parentheses even if parameter list is empty!
Chapter 6 - Functions return type void or a valid data type ( int, double, char, etc) name parameter list void or a list of parameters separated by commas body return keyword required if function returns
More informationMemory, Data, & Addressing II
Memory, Data, & Addressing II CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson
More informationEach line will contain a string ("even" or "odd"), followed by one or more spaces, followed by a nonnegative integer.
Decision-making in C Squeezing Digits out of an Integer Assignment For part of this assignment, you will use very basic C techniques to implement a C function to remove from a given nonnegative integer
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationEE355 Lab 5 - The Files Are *In* the Computer
1 Introduction In this lab you will modify a working word scramble game that selects a word from a predefined word bank to support a user-defined word bank that is read in from a file. This is a peer evaluated
More informationMemory, Data, & Addressing II CSE 351 Spring
Memory, Data, & Addressing II CSE 351 Spring 2018 http://xkcd.com/138/ Review Questions 1) If the word size of a machine is 64-bits, which of the following is usually true? (pick all that apply) a) 64
More informationCS 3114 Data Structures and Algorithms DRAFT Project 2: BST Generic
Binary Search Tree This assignment involves implementing a standard binary search tree as a Java generic. The primary purpose of the assignment is to ensure that you have experience with some of the issues
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 informationMemory, Data, & Addressing I
Memory, Data, & Addressing I CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan http://xkcd.com/953/
More informationDeclaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples:
1 Programming in C Pointer Variable A variable that stores a memory address Allows C programs to simulate call-by-reference Allows a programmer to create and manipulate dynamic data structures Must be
More informationCS 1044 Project 1 Fall 2011
Simple Arithmetic Calculations, Using Standard Functions One of the first things you will learn about C++ is how to perform numerical computations. In this project, you are given an incomplete program
More informationPractical Malware Analysis
Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the
More informationLab 03 - x86-64: atoi
CSCI0330 Intro Computer Systems Doeppner Lab 03 - x86-64: atoi Due: October 1, 2017 at 4pm 1 Introduction 1 2 Assignment 1 2.1 Algorithm 2 3 Assembling and Testing 3 3.1 A Text Editor, Makefile, and gdb
More informationA short session with gdb verifies a few facts; the student has made notes of some observations:
This assignment refers to concepts discussed in the course notes on gdb and the book The Art of Debugging by Matloff & Salzman. The questions are definitely "hands-on" and will require some reading beyond
More informationINITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS
INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS Pages 792 to 800 Anna Rakitianskaia, University of Pretoria INITIALISING POINTER VARIABLES Pointer variables are declared by putting
More informationStack Overflow. Faculty Workshop on Cyber Security May 23, 2012
Stack Overflow Faculty Workshop on Cyber Security May 23, 2012 Goals Learn to hack into computer systems using buffer overflow Steal sensitive data Crash computer programs Lay waste to systems throughout
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 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 informationCS 2505 Computer Organization I
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 computing devices may
More informationLearning Objectives. A Meta Comment. Exercise 1. Contents. From CS61Wiki
From CS61Wiki Contents 1 Learning Objectives 2 A Meta Comment 3 Exercise 1 3.1 Questions 3.2 Running code and using GDB 3.3 Compiler Optimizations 3.4 hexdump: a handy function 3.4.1 Questions 3.5 Checkpoint
More informationSo on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees.
So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees. According to the 161 schedule, heaps were last week, hashing
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 informationCS 1044 Program 2 Spring 2002
Simple Algebraic Calculations One of the first things you will learn about C++ is how to perform numerical computations. In this project, you are given an incomplete program (see the end of this specification),
More informationSurvey. Motivation 29.5 / 40 class is required
Survey Motivation 29.5 / 40 class is required Concerns 6 / 40 not good at examination That s why we have 3 examinations 6 / 40 this class sounds difficult 8 / 40 understand the instructor Want class to
More informationreply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000
Declaring Variables in Assembly Language As in Java, variables must be declared before they can be used Unlike Java, we do not specify a variable type in the declaration in assembly language Instead we
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 information17. Instruction Sets: Characteristics and Functions
17. Instruction Sets: Characteristics and Functions Chapter 12 Spring 2016 CS430 - Computer Architecture 1 Introduction Section 12.1, 12.2, and 12.3 pp. 406-418 Computer Designer: Machine instruction set
More information1. A student is testing an implementation of a C function; when compiled with gcc, the following x86-64 assembly code is produced:
This assignment refers to concepts discussed in sections 2.1.1 2.1.3, 2.1.8, 2.2.1 2.2.6, 3.2, 3.4, and 3.7.1of csapp; see that material for discussions of x86 assembly language and its relationship to
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationLecture Notes on Memory Layout
Lecture Notes on Memory Layout 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 11 1 Introduction In order to understand how programs work, we can consider the functions,
More informationSYSC 2006 C Winter 2012
SYSC 2006 C Winter 2012 Pointers and Arrays Copyright D. Bailey, Systems and Computer Engineering, Carleton University updated Sept. 21, 2011, Oct.18, 2011,Oct. 28, 2011, Feb. 25, 2011 Memory Organization
More informationWe do not teach programming
We do not teach programming We do not teach C Take a course Read a book The C Programming Language, Kernighan, Richie Georgios Georgiadis Negin F.Nejad This is a brief tutorial on C s traps and pitfalls
More informationFundamental Concepts: array of structures, string objects, searching and sorting. Static Inventory Maintenance Program
Fundamental Concepts: array of structures, string objects, searching and sorting The point of this assignment is to validate your understanding of the basic concepts presented in CS 1044. If you have much
More informationCS 2604 Minor Project 3 Movie Recommender System Fall Braveheart Braveheart. The Patriot
Description If you have ever visited an e-commerce website such as Amazon.com, you have probably seen a message of the form people who bought this book, also bought these books along with a list of books
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationLab 5 - Linked Lists Git Tag: Lab5Submission
UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE-13/L: COMPUTER SYSTEMS AND C PROGRAMMING WINTER 2016 Lab 5 - Linked Lists Git Tag: Lab5Submission Introduction This lab
More informationCS 2605 Lab 10 Spring 2008
Text Parsing and Indexing: A Minimal db Goal In this lab, you will explore basic text parsing in C++. Learning Objectives understanding how to use getline() to break down input data understanding the logical
More informationCS 2604 Minor Project 3 DRAFT Summer 2000
Simple Hash Table For this project you will implement a simple hash table using closed addressing and a probe function. The hash table will be used here to store structured records, and it should be implemented
More informationComputer Architecture and System Software Lecture 06: Assembly Language Programming
Computer Architecture and System Software Lecture 06: Assembly Language Programming Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Assignment 3 due thursday Midterm
More informationThe following notes illustrate debugging a linked list implementation with gdb.
Payload Type The following notes illustrate debugging a linked list implementation with. The example makes use of the following payload type: struct _WordRecord { char* Word; // zero-terminated C-string
More informationORG ; TWO. Assembly Language Programming
Dec 2 Hex 2 Bin 00000010 ORG ; TWO Assembly Language Programming OBJECTIVES this chapter enables the student to: Explain the difference between Assembly language instructions and pseudo-instructions. Identify
More informationReference operator (&)
Pointers Each cell can be easily located in the memory because it has a unique address and all the memory cells follow a successive pattern. For example, if we are looking for cell 1776 we know that it
More informationCS Programming In C
CS 24000 - Programming In C Week 16: Review Zhiyuan Li Department of Computer Science Purdue University, USA This has been quite a journey Congratulation to all students who have worked hard in honest
More informationVirtual Machine Tutorial
Virtual Machine Tutorial CSA2201 Compiler Techniques Gordon Mangion Virtual Machine A software implementation of a computing environment in which an operating system or program can be installed and run.
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More informationProgramming Assignment IV Due Thursday, June 1, 2017 at 11:59pm
Programming Assignment IV Due Thursday, June 1, 2017 at 11:59pm 1 Introduction In this assignment, you will implement a code generator for Cool. When successfully completed, you will have a fully functional
More informationThe Program Specification:
Reading to Input Failure, Decisions, Functions This programming assignment uses many of the ideas presented in sections 3 through 8 of the course notes, so you are advised to read those notes carefully
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 informationFor this assignment, you will implement a collection of C functions to support a classic data encoding scheme.
C Programming SEC-DED Data Encoding For this assignment, you will implement a collection of C functions to support a classic data encoding scheme. Data transmission and data storage both raise the risk
More informationC++ Programming Chapter 7 Pointers
C++ Programming Chapter 7 Pointers Yih-Peng Chiou Room 617, BL Building (02) 3366-3603 ypchiou@cc.ee.ntu.edu.tw Photonic Modeling and Design Lab. Graduate Institute of Photonics and Optoelectronics & Department
More informationProgramming in C++ 5. Integral data types
Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long
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 informationDECLARAING AND INITIALIZING POINTERS
DECLARAING AND INITIALIZING POINTERS Passing arguments Call by Address Introduction to Pointers Within the computer s memory, every stored data item occupies one or more contiguous memory cells (i.e.,
More informationLecture 03 Bits, Bytes and Data Types
Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics
More informationContents of Lecture 3
Contents of Lecture 3 Repetition of matrices double a[3][4]; double* b; double** c; Terminology Linkage Types Conversions Jonas Skeppstedt (js@cs.lth.se) Lecture 3 2014 1 / 33 A global matrix: double a[3][4]
More informationComputer Architecture I Midterm I
Computer Architecture I Midterm I April 11 2017 Computer Architecture I Midterm I Chinese Name: Pinyin Name: E-Mail... @shanghaitech.edu.cn: Question Points Score 1 1 2 12 3 16 4 14 5 18 6 17 7 22 Total:
More informationHomework 2 - KW26 - using 40 hexadecimal digits
Homework 2 - KW26 - using 40 hexadecimal digits Michael McAlpin Instructor - COP3502 - CS-1 Fall 2017 CECS-UCF michael.mcalpin@ucf.edu October 13, 2017 Assignment due date: November 5, 2017 Abstract In
More informationFor storage efficiency, longitude and latitude values are often represented in DMS format. For McBryde Hall:
Parsing Input and Formatted Output in C Dealing with Geographic Coordinates You will provide an implementation for a complete C program that reads geographic coordinates from an input file, does some simple
More informationCS 1044 Project 5 Fall 2009
User-defined Functions and Arrays This programming assignment uses many of the ideas presented in topics 3 through 18 of the course notes, so you are advised to read those carefully. Read and follow the
More information