1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 4: Memory and Memory-Mapped I/O September 16, 2010.

Slides:



Advertisements
Similar presentations
Development Environment C Toolchain C toolchain steps: Preprocessor Processes C code, handles include, pragma and macro expressions Compiler Transforms.
Advertisements

1 EECS 373 Design of Microprocessor-Based Systems Branden Ghena University of Michigan Lecture 3: Assembly, Tools, and ABI September 9, 2014 Slides developed.
Assembly Language.
1 ARM Movement Instructions u MOV Rd, ; updates N, Z, C Rd = u MVN Rd, ; Rd = 0xF..F EOR.
The 8051 Microcontroller and Embedded Systems
UEE072HM Linking HLL and ALP An example on ARM. Embedded and Real-Time Systems We will mainly look at embedded systems –Systems which have the computer.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 3: ISA, Assembly, and Toolchains September 13, 2011.
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.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
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)
PC hardware and x86 3/3/08 Frans Kaashoek MIT
UEE072HM Embedded Control Systems. Breaking down the compilation process Compilation is made up of a number of phases –Preprocessing –Compilation Can.
Slides developed in part by Mark Brehob
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Software Development and Software Loading in Embedded Systems.
Cortex-M3 Programming. Chapter 10 in the reference book.
Using the Clang Integrated Assembler to Compile the Linux Kernel Bryce Adelstein-Lelbach, Louisiana State University.
Lecture 5. AT91 - Memory Map, Timers, and AIC -
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 2: Architecture, Assembly, and ABI September 8, 2011 Slides.
6.828: PC hardware and x86 Frans Kaashoek
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 5: Memory and Peripheral Busses September 20, 2011.
CS-2710 Computer Organization Dr. Mark L. Hornick web: faculty-web.msoe.edu/hornick – CS-2710 info syllabus, homework, labs… –
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 2: Architecture, Assembly, and ABI Sept. 5, 2013 Slides developed.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Instruction Set Architecture Assembly Language Programming Software.
7/23 C Programming in Embedded Systems Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 2: Architecture, Assembly, and ABI September 9, 2010.
Recitation 6 – 2/26/01 Outline Linking Exam Review –Topics Covered –Your Questions Shaheen Gandhi Office Hours: Wednesday.
Topic 2d High-Level languages and Systems Software
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 2: Architecture, Assembly, and ABI September 4, 2014 Slides.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 3: Toolchain, ABI, Memory Mapped I/O January 14 th, 2016 Slides.
C Programming Chapters 11, . . .
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 4: Review, Simulation, ABI, and Memory-Mapped I/O September.
ARM Embedded Programming Lecture 4 Accessing Memory Mapped Registers.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
Operating Systems A Biswas, Dept. of Information Technology.
Intel Xscale® Assembly Language and C. The Intel Xscale® Programmer’s Model (1) (We will not be using the Thumb instruction set.) Memory Formats –We will.
List three things that distinguish embedded
Program Execution in Linux David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Lecture 3 Translation.
Writing Functions in Assembly
Instruction Set Architecture
Computer Science 210 Computer Organization
Development Environment Introduction
Chapter 1: A Tour of Computer Systems
Assembly Language programming
Slides developed in part by Mark Brehob & Prabal Dutta
COM S 326X Deep C Programming for the 21st Century Prof. Rozier
The University of Adelaide, School of Computer Science
The 8051 Microcontroller and Embedded Systems
Program Execution in Linux
Writing Functions in Assembly
Topic 2e High-Level languages and Systems Software
Computer Science 210 Computer Organization
Slides developed in part by Prof. Dutta
ARM Assembly Programming
Computer Organization & Compilation Process
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
More examples How many processes does this piece of code create?
Computer Organization and Design Assembly & Compilation
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Lecture 6: Multiprogramming and Context Switching
Slides developed in part by Mark Brehob
Program Execution in Linux
10/6: Lecture Topics C Brainteaser More on Procedure Call
Computer Organization & Compilation Process
An Introduction to the ARM CORTEX M0+ Instructions
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
Presentation transcript:

1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 4: Memory and Memory-Mapped I/O September 16, 2010

2 Announcements Prabal’s office hours this week –Thursday, 9/16 –1:00 PM to 2:30 PM –4773 CSE Homework 1 to be posted

3 Outline Minute quiz Announcements Review Embedded C/Assembly Memory Memory-mapped I/O

What happens after a power-on-reset (POR)? On the ARM Cortex-M3 SP and PC are loaded from the code (.text) segment Initial stack pointer –LOC: 0x –POR: SP  mem(0x ) Interrupt vector table –Initial base: 0x –Vector table is relocatable –Entries: 32-bit values –Each entry is an address –Entry #1: reset vector LOC: 0x POR: PC  mem(0x ) Execution begins 4.equSTACK_TOP, 0x text.syntaxunified.thumb.global_start.typestart, %function _start:.wordSTACK_TOP, start start: movs r0, #10...

5 How does an assembly language program get turned into a executable program image? Assembly files (.s) Object files (.o) as (assembler) ld (linker) Memory layout Memory layout Linker script (.ld) Executable image file Binary program file (.bin) Disassembled code (.lst) objcopy objdump

6 How does a mixed C/Assembly program get turned into a executable program image? Assembly files (.s) Object files (.o) as (assembler) gcc (compile + link) Memory layout Memory layout Linker script (.ld) Executable image file Binary program file (.bin) Disassembled Code (.lst) objcopy objdump ld (linker) Library object files (.o) C files (.c)

7 Outline Minute quiz Announcements Review Embedded C/Assembly Memory Memory-mapped I/O

8 #define SYSREG_SOFT_RST_CR 0xE uint32_t *reg = (uint32_t *)(SYSREG_SOFT_RST_CR); main () { *reg |= 0x ; // Reset GPIO hardware *reg &= ~(0x ); } Accessing memory locations from C Memory has an address and value Can equate a pointer to desired address Can set/get de-referenced value to change memory

9 Some useful C keywords const –Makes variable value or pointer parameter unmodifiable –const foo = 32; register –Tells compiler to locate variables in a CPU register if possible –register int x; static –Preserve variable value after its scope ends –Does not go on the stack –static int x; volatile –Opposite of const –Can be changed in the background –volatile int I;

10 Homework Write a library in assembly. Make it compatible with the EABI Link it with C

11 Outline Minute quiz Announcements Review Embedded C/Assembly Memory Memory-mapped I/O

System Memory Map

13 Outline Minute quiz Announcements Review Embedded C/Assembly Memory Memory-mapped I/O

14 Questions? Comments? Discussion?

15 int main() { int i; int n; unsigned int input = 40, output = 0; for (i = 0; i < 10; ++i) { n = factorial(i); printf("factorial(%d) = %d\n", i, n); } __asm("nop\n"); __asm("mov r0, %0\n" "mov r3, #5\n" "udiv r0, r0, r3\n" "mov %1, r0\n" :"=r" (output) : "r" (input) : "cc", "r3" ); __asm("nop\n"); printf("%d\n", output); } Cheap trick: use asm() or __asm() macros to sprinkle simple assembly in standard C code! $ arm-none-eabi-gcc \ -mcpu=cortex-m3 \ -mthumb main.c \ -T generic-hosted.ld \ -o factorial $ qemu-arm -cpu cortex-m3 \./factorial factorial(0) = 1 factorial(1) = 1 factorial(2) = 2 factorial(3) = 6 factorial(4) = 24 factorial(5) = 120 factorial(6) = 720 factorial(7) = 5040 factorial(8) = factorial(9) = Answer: 40/5 