C Programming Chapters 11, . . .

Slides:



Advertisements
Similar presentations
Introduction to C++ An object-oriented language Unit - 01.
Advertisements

1 Storage Duration and Scope –Local and global variables Storage classes –automatic, static, external, register Todays Material.
Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Subroutines – parameter passing passing data to/from a subroutine can be done through the parameters and through the return value of a function subroutine.
DSP Implementation Lecture 3. Anatomy of a DSP Project In VDSP Linker Description File (.LDF) Source Files (.asm,.c,.h,.cpp,.dat) Object Files (.doj)
. Pointers to functions Debugging. Logistics u Mid-term exam: 18/11  Closed books  List of topics – see web page Some you have to read by yourself!
Introduction to Kernel
Chapter 11-14, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3 Please return breadboards.
Overview C programming Environment C Global Variables C Local Variables Memory Map for a C Function C Activation Records Example Compilation.
C and Data Structures Baojian Hua
1-1 Embedded Software Development Tools and Processes Hardware & Software Hardware – Host development system Software – Compilers, simulators etc. Target.
Chapter 11-12, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3.
1. 2 FUNCTION INLINE FUNCTION DIFFERENCE BETWEEN FUNCTION AND INLINE FUNCTION CONCLUSION 3.
Memory Layout C and Data Structures Baojian Hua
Midterm Thursday Topics: First Midterm Instructions Set Architecture Machine Language Programming Assembly Language Programming Traps, Subroutines, & Interrupts.
1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
TCSS 372A Computer Architecture. Getting Started Get acquainted (take pictures) Purpose, scope, and expectations of the course Expectations & strategy.
Software Development and Software Loading in Embedded Systems.
Macro & Function. Function consumes more time When a function is called, the copy of the arguments are passed to the parameters in the function. After.
 Knowledge and use of tools and resources in a system: standard libraries, system calls, debuggers, the shell environment, system programs and scripting.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Runtime Environments Compiler Construction Chapter 7.
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
RNJ 05/05/091 6 Further System Fundamentals (HL) ‏ 6.3 Operating Systems and Utility Software Linkers, Loaders and Library Managers.
C Functions Three major differences between C and Java functions: –Functions are stand-alone entities, not part of objects they can be defined in a file.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
C++ Lecture 2 Friday 11 July Chapter 3, Functions l built-in functions l function prototype, function definition and use l storage class and scope.
+ Dynamic memory allocation. + Introduction We often face situations in programming where the data is dynamics in nature. Consider a list of customers.
CS415 C++ Programming Takamitsu Kawai x4212 G11 CERC building WV Virtual Environments Lab West Virginia University.
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
Chapter 14 Functions. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Declarations (aka prototype) int.
Department of Electronic & Electrical Engineering Functions Parameters Arguments Pointers/dereference & * Scope Global/Local Storage Static/Automatic.
Announcements There is a Quiz today. There were problems with grading assignment 2, but they should be worked out today The web page for correcting the.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
Beyond Application Profiling to System Aware Analysis Elena Laskavaia, QNX Bill Graham, QNX.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Embedded Real-Time Systems
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
WORKING OF SCHEDULER IN OS
Instructions for test_function
Introduction to Kernel
Process concept.
C++.
Protection of System Resources
Pointers and dynamic memory
Chapter 12 Variables and Operators
The Hardware Interface
CSC 253 Lecture 8.
Announcements Homework #7 due Monday at 3:00pm
Chapter 1: Intro (excerpt)
CSC 253 Lecture 8.
CS 2308 Exam I Review.
Stack Memory 2 (also called Call Stack)
More examples How many processes does this piece of code create?
System Structure and Process Model
Tools.
Pointers and dynamic memory
Observing how the machine acts
Tools.
Figure 14.1 The modern integrated computer environment
Program Execution in Linux
C Programming Pointers
Arrays An array is a grouping of elements of the same type that share a common base name Can have any number of elements in the array Individual elements.
How Memory Leaks Work with Memory Diagram
pointer-to-pointer (double pointer)
Run-time environments
Introduction to Pointers
Implementing Functions: Overview
Presentation transcript:

C Programming Chapters 11, . . . C – Compiler Compilation Tracing C programs C Functions C program Stack Structure

Memory map (Global Data pointer) I/O Devices

C Functions All C programs begin with the main Function: #include <stdio.h> ; include libraries for compiler #define Two = 2 ; “Two” will be replaced in code with 2 int x = 56; ; x is a global variable int main () ; main has an “int” type return value { int y = 47; ; y is a local variable return 0; ; return the value “0” }

C Functions #include <stdio.h> int sum (int r, int s, int t); int main() { z = sum (x,y,z) + 65; } int sum (int A, int B, int C) int total; ; total is a local variable total = A + B + C); return total; ; return the sum

C Program int Func1(int x) #include <stdio.h> { return Func2(x) + 1; } int Func2(int x) return Func3(x) + 1; int Func3(int x) return Func4(x) + 1; int Func4(int x) return x + 1; #include <stdio.h> int Func1(int x); int Func2(int x); int Func3(int x); int Func4(int x); int main() { int A = 3; int B = 5; int C; C = A + B; C = Func1(C); C = C + 1; return 2; }

C Program Compilation Compile the program Look at the files Load them into the LC-3 simulator Execute the program and observe its stack