Lecture 8: Loading and Storing to Memory CS 2011 Fall 2014, Dr. Rozier.

Slides:



Advertisements
Similar presentations
Appendix D The ARM Processor
Advertisements

Wat gaan we doen? harhaling data types
1 ARM Movement Instructions u MOV Rd, ; updates N, Z, C Rd = u MVN Rd, ; Rd = 0xF..F EOR.
Optimizing ARM Assembly Computer Organization and Assembly Languages Yung-Yu Chuang with slides by Peng-Sheng Chen.
Run-time Environment for a Program different logical parts of a program during execution stack – automatically allocated variables (local variables, subdivided.
Embedded System Design Center Sai Kumar Devulapalli ARM7TDMI Microprocessor Load and store instruction.
COMP3221 lec-12-mem-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 12: Memory Access - II
ARM Microprocessor “MIPS for the Masses”.
Multiple data transfer instructions ARM also supports multiple loads and stores: ldm/ldmia/ldmfd: load multiple registers starting from [base register],
Elec2041 lec-11-mem-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 4: Memory Access March,
Elec2041 lec-11-mem-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 11: Memory Access - I
COMP3221 lec18-function-III.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 17 : Functions in C/ Assembly - III
Topics covered: ARM Instruction Set Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
ARM Core Architecture. Common ARM Cortex Core In the case of ARM-based microcontrollers a company named ARM Holdings designs the core and licenses it.
ARM Instructions I Prof. Taeweon Suh Computer Science Education Korea University.
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
Advanced RISC Machines
Subroutines and Stacks 1. Subroutines Separate, independent module of program, performs a specific task shortens code, provide reusable “tools” High-level.
ARM Assembly Programming Computer Organization and Assembly Languages Yung-Yu Chuang 2007/11/19 with slides by Peng-Sheng Chen.
Lecture 4: Advanced Instructions, Control, and Branching cont. EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer.
Topic 10: Instruction Representation CSE 30: Computer Organization and Systems Programming Winter 2011 Prof. Ryan Kastner Dept. of Computer Science and.
COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE Lecture 15 & 16 Stacks, Endianness Addressing Modes Course Instructor: Engr. Aisha Danish.
Lecture 2: Basic Instructions CS 2011 Fall 2014, Dr. Rozier.
1 ARM University Program Copyright © ARM Ltd 2013 Cortex-M4 CPU Core.
Lecture 4. ARM Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University ECM586 Special Topics in Embedded Systems.
Chapter 3-1 ARM ISA ARM Instruction Set Architecture ARM Instruction Set Architecture Next Lecture Next Lecture  ARM program examples.
Lecture 4. ARM Instructions Prof. Taeweon Suh Computer Science & Engineering Korea University COMP427 Embedded Systems.
Lecture 3. ARM Instructions Prof. Taeweon Suh Computer Science Education Korea University ECM583 Special Topics in Computer Systems.
Lecture 8: Control, Procedures, and the Stack CS 2011 Fall 2014, Dr. Rozier.
1 ARM University Program Copyright © ARM Ltd 2013 Cortex-M0+ CPU Core.
More on Assembly 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
ECS642U Embedded Systems ARM CPU and Assembly Code William Marsh.
嵌入式處理器架構與程式設計 王建民 中央研究院 資訊所 2008 年 7 月. 2 Contents Introduction Computer Architecture ARM Architecture Development Tools  GNU Development Tools ARM Instruction.
1 Chapter 4 ARM Assembly Language Smruti Ranjan Sarangi Computer Organisation and Architecture PowerPoint Slides PROPRIETARY MATERIAL. © 2014 The McGraw-Hill.
More on Assembly 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
Lecture 6: Branching CS 2011 Fall 2014, Dr. Rozier.
The Stack. ARMSim memory space: 0x Unused 0x x11400 Stack 0x x09400 Heap 0x?????-0x01400 Data 0x x????? Text 0x x01000.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
Instruction Set Architectures Early trend was to add more and more instructions to new CPUs to do elaborate operations –VAX architecture had an instruction.
Arrays In high-level languages, we have several technigues available for constucting data stuctures: −One-dimensional arrays −Multi-dimensional arrays.
Lecture 10: Load/Store cont. and Integer Arithmetic CS 2011 Fall 2014, Dr. Rozier.
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.
ARM Instruction Set Computer Organization and Assembly Languages Yung-Yu Chuang with slides by Peng-Sheng Chen.
Lecture 6: Decision and Control CS 2011 Spring 2016, Dr. Rozier.
Multiple data transfer instructions ARM also supports multiple loads and stores: When the data to be copied to the stack is known to be a multiple of 4.
ARM Programming CMPE 450/490 ©2010 Elliott, Durdle, Minderman
Chapter 15: Higher Level Constructs
Main features of the ARM Instruction Set
ARM Assembly Language Programming
Chapter 4 Copying Data.
Chapter 15: Higher Level Constructs
ECE 3430 – Intro to Microcomputer Systems
Introduction to the ARM Instruction Set
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
ECE 3430 – Intro to Microcomputer Systems
The Cortex-M3/m4 Embedded Systems: Cortex-M3/M4 Instruction Sets
EE 319K Introduction to Embedded Systems
The Stack.
Chapter 4 Addressing modes
Overview Introduction General Register Organization Stack Organization
The Stack.
ECM586 Special Topics in Embedded Systems Lecture 4. ARM Instructions
ARM Load/Store Instructions
Computer Organization and Assembly Languages Yung-Yu Chuang 2008/11/17
Overheads for Computers as Components 2nd ed.
ARM Memory.
Computer Architecture
Introduction to Assembly Chapter 2
ARM Load/Store Instructions
An Introduction to the ARM CORTEX M0+ Instructions
Presentation transcript:

Lecture 8: Loading and Storing to Memory CS 2011 Fall 2014, Dr. Rozier

MEMORY BASICS

The Memory Hierarchy

RISC Load/Store Architecture Processor Registers Add Cmp Load Etc Store Memory

Single Register Data Transfer LDR/STR – load or store – {cond}{size} Rd, Size is an option suffix – LDR, No suffix? Transfer a word – LDRB, Transfer an unsigned byte – LDRSB, Transfer a signed byte – LDRH, Transfer an unsigned half word – LDRSH, Transfer a signed half word

Addressing Address can be… – An expression – A pre-indexed address [Rn, ]{!} [Rn, {-}Rm]{!} [Rn, {-}Rm count]{!} – A post-indexed address [Rn], [Rn], {-}Rm [Rn], {-}Rm count

Addressing Pre-indexing – Modify Rn to a new index, and use it. – If the “!” postfix is included, write back the pre- index to Rn. Post-indexing – Use Rn as the index. – Write back the result of the post-indexing to Rn.

Addressing Pseudo-instruction – ldr r0, =myvalue The compiler substitutes a PC relative load to an appropriate literal pool. – ldr r0, [pc, #8]

Memory Puzzle mov sp, #135, lsl #3 mov r0, #0 mov r1, #1 mov r2, #2 mov r3, #3 mov r4, #4 mov r5, #5 str r0, [sp], #4 str r1, [sp, #4] str r1, [sp], #4 str r2, [sp!, #4] str r3, [sp, #4] ldr r2, [sp], -r4

ADVANCED MEMORY OPS

Multiple Register Data Transfer LDM, STM – load/store multiple – {cond} Rn{!}, Modes control how Rn is changed – IA – increment after – IB – increment before – DA – decrement after – DB – decrement before The ! suffix to Rn tells the operation to write the results back when done.

Importance of Modes?

What does this instruction mean? LDMIA r0, {r3, r7}

What does this instruction mean? LDMIA r0, {r3-r7}

What does this instruction mean? STMDB r1!, {r6-r8}

Memory Puzzle mov sp, #135, lsl #3 mov r0, #0 mov r1, #1 mov r2, #2 mov r3, #3 mov r4, #4 mov r5, #5 stmia r13, {r0-r5} stmib r13, {r1-r4} ldmia r13, {r0-r5} Checkpoint1: stmia r13!, {r1-r3} ldmda r13!, {r1-r3} Checkpoint2:

RISC Load/Store Architecture Processor Registers Add Cmp Load Etc Store Memory

THE STACK

The Stack There is nothing special about the stack – It’s a conceptual abstraction we use to implement higher features. – ARM has no new instructions to implement the stack.

The Stack ARM assembler does provide “pseudo- instructions” – Pseudo-instructions are nicknames for existing instructions that make our job easier FD – full descending ED – empty descending FA – full ascending EA – empty ascending

Work out how FD,ED,FA,EA map to our real instructions.

The Stack While we could use any method (so long as we are consistent), it is rare to see anything but a full descending stack. The pseudo-instructions PUSH and POP assume a full descending stack

PUSH and POP PUSH{cond} POP{cond} PUSH and POP assume use of the stack pointer.

Memory Puzzle mov sp, #135, lsl #3 mov r0, #0 mov r1, #1 mov r2, #2 mov r3, #3 mov r4, #4 mov r5, #5 push {r0, r4-r5} pop {r1} push {r1-r3} pop {r2-r5}

For next time Read Chapter 3 Sections 3.1 – 3.5