Chapter 6 - Memory How to allocate variables and constants in RAM and FLASH memory.

Slides:



Advertisements
Similar presentations
CS Spring 2014 Prelim 2 Review
Advertisements

The University of Adelaide, School of Computer Science
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
1 C and the 8051 EGRE Introduction The Silicon Labs ISE uses the Keil C51 compiler. The code size is limiter to 2K C has replaced PL/M (the original.
Chapter 4 - NUMB3RS Learning to chose the right “types” Exploring The PIC32 - Lucio Di Jasio.
Exploring Security Vulnerabilities by Exploiting Buffer Overflow using the MIPS ISA Andrew T. Phillips Jack S. E. Tan Department of Computer Science University.
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
SPIM and MIPS programming
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Computer Architecture CSCE 350
MIPS Function Continued
1 Nested Procedures Procedures that don't call others are called leaf procedures, procedures that call others are called nested procedures. Problems may.
Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
Recitation Material of Engineering an Assembler June 11, 2013.
The University of Adelaide, School of Computer Science
ITEC 352 Lecture 27 Memory(4). Review Questions? Cache control –L1/L2  Main memory example –Formulas for hits.
 Procedures (subroutines) allow the programmer to structure programs making them : › easier to understand and debug and › allowing code to be reused.
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)
Chapter 6 Under the Hood. Di Jasio – Programming 16-bit Microcontrollers in C (Second Edition) Checklist The following tools will be used in this lesson:
Embedded Systems Lecture 7: Configuration & memory Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site:
Homework 2 Review Cornell CS Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return.
Chapter 10.
L5 – Addressing Modes 1 Comp 411 – Spring /29/08 Operands and Addressing Modes Where is the data? Addresses as data Names and Values Indirection.
Main Index Contents 11 Main Index Contents Pointer Illustration Pointer Illustration Vertical / Horizontal View. Vertical / Horizontal View. Data Addresses.
RISC Concepts, MIPS ISA and the Mini–MIPS project
Main Index Contents 11 Main Index Contents Pointer Illustration Pointer Illustration Vertical / Horizontal View. Vertical / Horizontal View. Data Addresses.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
ARM C Language & Assembler. Using C instead of Java (or Python, or your other favorite language)? C is the de facto standard for embedded systems because.
Software Development and Software Loading in Embedded Systems.
Lecture 7: MIPS Instruction Set Today’s topic –Procedure call/return –Large constants Reminders –Homework #2 posted, due 9/17/
Chapter 1 The First Flight Creating the first project and saying “Hello to the World”
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
© 2003 Xilinx, Inc. All Rights Reserved Address Management.
VxWorks & Memory Management
Memory Addressing in Linux  Logical Address machine language instruction location  Linear address (virtual address) a single 32 but unsigned integer.
Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop More challenging than HW3 because HW3 is stateless, the.
Lecture 4. Miscellaneous Addressing Mode, Memory Map, Pointer, and ASCII Prof. Taeweon Suh Computer Science Education Korea University ECM534 Advanced.
Topic 2d High-Level languages and Systems Software
MAL 3 - Procedures Lecture 13. MAL procedure call The use of procedures facilitates modular programming. Four steps to transfer to and return from a procedure:
EEE527 Embedded Systems Lecture 5: Chapter 6 and7 Configuration & memory Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring
This material exempt per Department of Commerce license exception TSU Address Management.
C Programming – Part 3 Arrays and Strings.  Collection of variables of the same type  Individual array elements are identified by an integer index 
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
Computer Organization and Design Addressing Modes Montek Singh Sep 30, 2015 Lecture 7.
Chapter 5 - Interrupts.
4. Kernel and VGA ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  None.
Pointers in C++. Topics Covered  Introduction to Pointers  Pointers and arrays  Character Pointers, Arrays and Strings  Examples.
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
The Assembly Process Computer Organization and Assembly Language: Module 10.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Function Calls in Assembly MIPS R3000 Language (extensive use of stack) Updated 7/11/2013.
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
L7 – Assembler Directives
Topic 2e High-Level languages and Systems Software
CSCI206 - Computer Organization & Programming
Windows Programming Lecture 02.
Solutions Chapter 2.
These are slides from Comp411
Operands and Addressing Modes
Lecture 3: Main Memory.
Computer Organization and Design Assembly & Compilation
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Program and memory layout
Writing an Embedded Controller
Program Assembly.
Operands and Addressing Modes
Variables and Constants
Introduction to Pointers
Presentation transcript:

Chapter 6 - Memory How to allocate variables and constants in RAM and FLASH memory

Di Jasio - Programming 32-bit Microcontrollers in C Strings.c Example /* ** Strings */ #include // 1. variable declarations const char a[] = "Exploring the PIC32"; char b[100] = "Initialized"; // 2. main program main() { strcpy( b, "MPLAB C32");// assign new content to b } // main

Di Jasio - Programming 32-bit Microcontrollers in C Using the Watch Window

Di Jasio - Programming 32-bit Microcontrollers in C Setting the Watch Properties

Di Jasio - Programming 32-bit Microcontrollers in C String “b” after C0 initialization

Di Jasio - Programming 32-bit Microcontrollers in C Disassembly Listing 14: // 2. main program 15: main() 16: { 9D BDFFE8 addiu sp,sp,-24 9D00001C AFBF0014 sw ra,20(sp) 9D AFBE0010 sw s8,16(sp) 9D A0F021 addu s8,sp,zero 17: strcpy( b, "MPLAB C32");// assign new content to b 9D C02A000 lui v0,0xa000 9D00002C addiu a0,v0,0 9D C029D00 lui v0,0x9d00 9D C addiu a1,v0,1868 9D F jal 0x9d D00003C nop 18: } // main 9D C0E821 addu sp,s8,zero 9D FBF0014 lw ra,20(sp) 9D FBE0010 lw s8,16(sp) 9D00004C 27BD0018 addiu sp,sp,24 9D E00008 jr ra 9D nop

Di Jasio - Programming 32-bit Microcontrollers in C Looking at the “Map” C:/Program Files/Microchip/../pic32mx/lib\libc.a(strcpy.o) Strings.o (strcpy) C:/Program Files/Microchip/../pic32mx/lib\libc.a(strcpy.o) Strings.o (strcpy) Memory Configuration Name Origin Length Attributes kseg0_program_mem 0x9d x xr kseg0_boot_mem 0x9fc x exception_mem 0x9fc x kseg1_boot_mem 0xbfc x debug_exec_mem 0xbfc x00000ff0 config3 0xbfc02ff0 0x config2 0xbfc02ff4 0x config1 0xbfc02ff8 0x config0 0xbfc02ffc 0x kseg1_data_mem 0xa x w !x sfrs 0xbf x *default* 0x xffffffff Memory Configuration Name Origin Length Attributes kseg0_program_mem 0x9d x xr kseg0_boot_mem 0x9fc x exception_mem 0x9fc x kseg1_boot_mem 0xbfc x debug_exec_mem 0xbfc x00000ff0 config3 0xbfc02ff0 0x config2 0xbfc02ff4 0x config1 0xbfc02ff8 0x config0 0xbfc02ffc 0x kseg1_data_mem 0xa x w !x sfrs 0xbf x *default* 0x xffffffff

Di Jasio - Programming 32-bit Microcontrollers in C Memory Map Sections .reset section, containing the code that will be placed by the linker at the reset vector. This is normally filled with a default handler (_reset())..reset 0xbfc x10 C:/.../pic32mx/lib/crt0.o 0xbfc00000 _reset .vector_x sections, there are 64 of them each associated to the corresponding interrupt handler. They will be empty unless your program is using the specific interrupt handler..vector_0 0x9fc x0 .startup section, where the C0 initialization code is placed..startup 0x9fc x1e0 C:/.../lib/crt0.o .text sections, you will find many of them, where all the code generated by the MPLAB C32 compiler from your source files is placed. Here is the specific part produced by our main() function:.text 0x9d x40 Strings.o 0x9d main .rodata section, where read only (constant) data is placed in program memory space. Here we can find space for our constant string “a” for example:.rodata 0x9d x20 Strings.o 0x9d a .data section, where RAM memory is allocated for global variables..data 0xa x64 Strings.o 0xa b .data1 section, where the initialization value, ready for the C0 code to load into the “b” variable is placed, once more, in program memory space. *(.data1) 0x9d00076c _data_image_begin=LOADADDR(data)

Di Jasio - Programming 32-bit Microcontrollers in C The Memory Window Address C ASCII 1D00_0760 9D0003AC 9D0004F4 9D E x...Init 1D00_ C A ialized

Di Jasio - Programming 32-bit Microcontrollers in C Pointers int *pi; // define a pointer to an integer int i; // index/counter int a[10]; // the array of integers // 1. sequential access using array indexing for( i=0; i<10; i++) a[ i] = i; // 2. sequential access using a pointer pi = a; for( i=0; i<10; i++) { *pi = i; pi++; }

Advanced Material Fixed Translation Map User and Kernel Virtual Memory Maps

Di Jasio - Programming 32-bit Microcontrollers in C The PIC32 Fixed Translation Map

Di Jasio - Programming 32-bit Microcontrollers in C Phisical Addressing Space RAM FLASH SFRSFR SFRSFR 0x x1D x1F BOOTBOOT BOOTBOOT 0x1FC000000xFFFFFFFF

Di Jasio - Programming 32-bit Microcontrollers in C RAM Partitioning Kernel RAM (Data) Kernel RAM (Data) 0x BMXDUDBA0xBF BMXDUDBA User RAM (Data) User RAM (Data) 0xFFFFFFFF User RAM (Prog) Kernel RAM (Prog) Kernel RAM (Prog) BMXDKDBA0xBF BMXDUPBA

Di Jasio - Programming 32-bit Microcontrollers in C User Mode Virtual Memory Map 0x7F BMXDUDBA User RAM (Data) User RAM (Data) 0x7F BMXDUPBA User RAM (Prog) User RAM (Prog) 0x User SpaceKernel Space User FLASH Generate an immediate exception if access is attempted! 0xFFFFFFFF 0x x7D000000

Di Jasio - Programming 32-bit Microcontrollers in C Kernel Mode Virtual Memory Map 0x BMXDKPBA User Space Kernel Space FLASH Cached (Kseg0) FLASH Cached (Kseg0) 0xFFFFFFFF0x x9D RAM (Data) RAM (Data) RAM (Prog) RAM (Prog) FLASH Un- Cached (Kseg1) FLASH Un- Cached (Kseg1) 0xBD x SFRSFR SFRSFR 0xBF BOOTBOOT BOOTBOOT 0xBFC00000