The Stack.

Slides:



Advertisements
Similar presentations
Wat gaan we doen? harhaling data types
Advertisements

Run-time Environment for a Program different logical parts of a program during execution stack – automatically allocated variables (local variables, subdivided.
Procedure Calls Prof. Sirer CS 316 Cornell University.
1 Nested Procedures Procedures that don't call others are called leaf procedures, procedures that call others are called nested procedures. Problems may.
Ch. 8 Functions.
Procedure call frame: Hold values passed to a procedure as arguments
Multiple data transfer instructions ARM also supports multiple loads and stores: ldm/ldmia/ldmfd: load multiple registers starting from [base register],
S. Barua – CPSC 240 CHAPTER 10 THE STACK Stack - A LIFO (last-in first-out) storage structure. The.
Intro to Computer Architecture
Chapters 9 & 10 Midterm next Wednesday (11/19) Trap Routines & RET Subroutines (or Functions) & JSR & JSRR & RET The Stack SSP & USP Interrupts RTI.
©2000 Addison Wesley IEEE 754 single precision floating-point number format.
© 2010 Kettering University, All rights reserved..
Chapter 10 And, Finally... The Stack. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Stacks A LIFO.
Chapter 10 The Stack Stack: An Abstract Data Type An important abstraction that you will encounter in many applications. We will describe two uses:
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE Lecture 15 & 16 Stacks, Endianness Addressing Modes Course Instructor: Engr. Aisha Danish.
CS41B MACHINE David Kauchak CS 52 – Fall Admin  Midterm Thursday  Review question sessions tonight and Wednesday  Assignment 3?  Assignment.
Procedure (Method) Calls Ellen Spertus MCS 111 September 25, 2003.
More on Assembly 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
The x86 Instruction Set Lecture 16 Mon, Mar 14, 2005.
F28PL1 Programming Languages Lecture 4: Assembly Language 3.
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
Arrays and Strings in Assembly
More on Assembly 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 10 The Stack Stack data structure Interrupt I/O (again!) Arithmetic using a stack.
CPU performs the bulk of data processing operations CPU performs the bulk of data processing operations The CPU is made up of three parts. They are Control.
Lecture 8: Loading and Storing to Memory CS 2011 Fall 2014, Dr. Rozier.
Function Calling. Mips Assembly Call and Return Steps for procedure calling –Save the return address –Jump to the procedure (function) –Execute the procedure.
The Stack. ARMSim memory space: 0x Unused 0x x11400 Stack 0x x09400 Heap 0x?????-0x01400 Data 0x x????? Text 0x x01000.
Instruction Set Architectures. Our Progress Done with levels 0 and 1 Seen multiple examples of level 2 Ready for ISA general principles.
The LC-3 – Chapter 5 COMP 2620 Dr. James Money COMP
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.
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.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
1 Topic 6: Activation Records COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer.
Chapter 14 Functions.
Storage Classes There are three places in memory where data may be placed: In Data section declared with .data in assembly language in C - Static) On the.
C function call conventions and the stack
The Stack.
Introduction to the ARM Instruction Set
Functions and the Stack
Assembly Language Assembly Language
The Cortex-M3/m4 Embedded Systems: Cortex-M3/M4 Instruction Sets
The Stack.
Chapter 10 And, Finally... The Stack
CS41B recursion David Kauchak CS 52 – Fall 2015.
In this lecture Global variables Local variables System stack
Chapter 10 The Stack.
Arithmetic using a stack
Instruction Set Architectures
Computer Programming Machine and Assembly.
ARM Memory.
Subroutines and the Stack
The University of Adelaide, School of Computer Science
ARM Load/Store Instructions
Компьютерийн зохион байгуулалт, ассемблер CS201
Von Neumann model - Memory
Chapter 10 And, Finally... The Stack
Data structures.
EE6502/MPMC/UNIT II/STACK AND SUBROUTINE/T.THARANKUMAR
Program and memory layout
Program to find equivalence classes
ARM Memory.
Program and memory layout
Program and memory layout
Program and memory layout
Copyright © 2013 Elsevier Inc. All rights reserved.
(The Stack and Procedures)
Implementing Functions: Overview
Presentation transcript:

The Stack

The Stack ARMSim memory space: 0x11400 + Unused 0x09400-0x11400 Stack Heap 0x?????-0x01400 Data 0x01000-0x????? Text 0x00000-0x01000 Reserved

Stack possibilites How to use the space in stack? Grow up Keep track of top item in stack (Full Ascending) Keep track of first empty slot (Empty Ascending)

Stack possibilites How to use the space in stack? Grow down Keep track of top item in stack (Full Descending) Keep track of first empty slot (Empty Descending)

Stack possibilites ARM Convention : Full Descending r13 Points to "top" item (lowest address) in stack Stack view of memory flipped

Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC ????????? sp 0x11400

Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC ????????? sp 0x113FC

Push Recipe Subtract 4 from sp STR data … 81818181 0x113F4 0x113F8 0x113FC AA 0x11400 ????????? sp 0x113FC

Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC AA ????????? sp 0x113F8

Push Recipe Subtract 4 from sp STR data … 81818181 0x113F4 0x113F8 BB 0x113FC AA 0x11400 ????????? sp 0x113F8

Pop Recipe LDR data … 81818181 0x113F4 0x113F8 BB 0x113FC AA 0x11400 ????????? sp 0x113F8

Pop Recipe LDR data Add 4 to sp … 81818181 0x113F4 0x113F8 BB 0x113FC ????????? sp 0x113FC

Pop Recipe LDR data … 81818181 0x113F4 0x113F8 BB 0x113FC AA 0x11400 ????????? sp 0x113FC

Pop Recipe LDR data Add 4 to sp … 81818181 0x113F4 0x113F8 BB 0x113FC ????????? sp 0x11400

Push / Pop Always tear down stack in reverse order Push A Push B Pop B Time

Machine Push/Pop Fun Fact Common need : machine instructions Store Multiple to Full Descending use sp and update it (!) store r1 and r2

Machine Push/Pop Fun Fact Common need : machine instructions Load Multiple from Full Descending use sp and update it (!) load r2 then r1 (reverse order)

Pseudo Instructions Easier pseudinstructions: PUSH {register list} POP {register list}