EECE.3170 Microprocessor Systems Design I

Slides:



Advertisements
Similar presentations
Calling sequence ESP.
Advertisements

The University of Adelaide, School of Computer Science
Computer Architecture CSCE 350
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Procedures II (1) Fall 2005 Lecture 07: Procedure Calls (Part 2)
Subroutines: Passing Arguments Using the Stack. Passing Arguments via the Stack Arguments to a subroutine are pushed onto the stack. The subroutine accesses.
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Accessing parameters from the stack and calling functions.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 15: Protected mode intro.
Microprocessor Systems Design I
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2013 Lecture 4: 80386DX memory, addressing.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2014 Lecture 4: x86 memory.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 7 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External 2. The type.
Stack Operations LIFO structure (last-in,first-out) –The last value put into the stack is the first value taken out Runtime stack –A memory array that.
Today’s topics Parameter passing on the system stack Parameter passing on the system stack Register indirect and base-indexed addressing modes Register.
Today’s topics Procedures Procedures Passing values to/from procedures Passing values to/from procedures Saving registers Saving registers Documenting.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
1 The Stack and Procedures Chapter 5. 2 A Process in Virtual Memory  This is how a process is placed into its virtual addressable space  The code is.
CSC 221 Computer Organization and Assembly Language Lecture 16: Procedures.
Calling Procedures C calling conventions. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
NASM ASSEMBLER & COMPILE WITH GCC 어셈러브 refered to ‘PC Assembly Language’ by Paul A. Carter
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
ICS51 Introductory Computer Organization Accessing parameters from the stack and calling functions.
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
Stack Operations Dr. Hadi AL Saadi.
Instructions for test_function
Assembly function call convention
Microprocessor Systems Design I
ECE Application Programming
Format of Assembly language
C function call conventions and the stack
Microprocessor Systems Design I
Microprocessor Systems Design I
Segment Definition The CPU has several segment registers:
Microprocessor Systems Design I
Microprocessor Systems Design I
Computer Architecture and Assembly Language
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
16.317: Microprocessor System Design I
Microprocessor and Assembly Language
Microprocessor Systems Design I
Microprocessor and Assembly Language
Introduction to Compilers Tim Teitelbaum
Procedures (Functions)
High-Level Language Interface
CS 301 Fall 2002 Control Structures
Programming 8086 – Part IV Stacks, Macros
Stack Memory 2 (also called Call Stack)
Stack Frames and Advanced Procedures
Procedures – Overview Lecture 19 Mon, Mar 28, 2005.
MIPS Procedure Calls CSE 378 – Section 3.
The University of Adelaide, School of Computer Science
Practical Session 4.
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Symbolic Instruction and Addressing
Multi-modules programming
Lecture 2 SCOPE – Local and Global variables
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
CSC 497/583 Advanced Topics in Computer Security
Computer Organization and Assembly Language
EECE.3170 Microprocessor Systems Design I
Computer Architecture and System Programming Laboratory
Presentation transcript:

EECE.3170 Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2016 Lecture 16 HLL  assembly

Microprocessors I: Lecture 16 Lecture outline Announcements/reminders HW 4 due 1:00 PM, Friday, 3/4 Review Subroutines Basics of stack usage Today’s lecture Translation from HLL  assembly 12/8/2018 Microprocessors I: Lecture 16

Microprocessors I: Lecture 16 Review: subroutines Subroutines: low-level functions When called, address of next instruction saved Return instruction ends routine; goes to that point May need to save state on stack x86 specifics CALL <proc>: call procedure <proc> can be label (16-/32-bit imm), reg, mem Saves address of next instruction to stack RET: return from procedure Saving state to stack: push instructions Store data “above” current TOS; decrement SP Basic PUSH stores word or double word Directly storing flags: PUSHF Storing all 16-/32-bit general purpose registers: PUSHA/PUSHAD Restoring state: POP/POPF/POPA/POPAD 12/8/2018 Microprocessors I: Lecture 16

Microprocessors I: Lecture 16 HLL  assembly Given some brief examples already; want to think about common HLL concepts and their assembly counterparts Compiling HLL to assembly Data accesses Stack usage with function calls Conditional statements (if-then-else) Loops 12/8/2018 Microprocessors I: Lecture 16

Microprocessors I: Lecture 16 Sample program int X[10], Y[10]; // integer arrays int i, j; // index variables for (i = 0; i < 10; i++) { // outer loop X[i] = i * 2; // set X[i] for (j = 0; j < 10; j++) { // inner loop if (j < 5) // set Y[j] Y[j] = X[i] + j; // based on else // value of j Y[j] = X[i] – j; } 12/8/2018 Microprocessors I: Lecture 16

Microprocessors I: Lecture 16 Data representations Program references four pieces of data Two integer arrays: X[10], Y[10] Two integer index variables: i, j Compilers must account for: Data size: is variable a double word, word, or byte? Characters (char) are always 8 bits  1 byte Other types system-dependent In x86, integers (int) are 32 bits  4 bytes  double word Short integers (short) are 16 bits  2 bytes  word Data location: where is data allocated? Depends on how it’s allocated … If writing assembly by hand, static data  directly allocated in memory If compiled code or function call, allocated on stack Variables declared inside functions, function arguments 12/8/2018 Microprocessors I: Lecture 16

Microprocessors I: Lecture 16 Static data accesses Global declarations in high-level program Stored in data segment Offset into data segment declared as symbol Example (from testfile2.asm) mov eax, DWORD PTR _c 12/8/2018 Microprocessors I: Lecture 16

Microprocessors I: Lecture 16 Stack accesses On function call SP or ESP: points to current top of stack Lowest address in current stack frame BP or EBP: used to reference data within frame Arguments Local variables 12/8/2018 Microprocessors I: Lecture 16

Microprocessors I: Lecture 16 Stack accesses (cont.) Arguments start at offset 8 from EBP Local variables start at offset -4 from EBP Starting offset of each variable can be defined as symbol Ex. (testfile1.asm) _j$ = -120; size = 4 _i$ = -108; size = 4 _Y$ = -96; size = 40 _X$ = -48; size = 40 mov DWORD PTR _i$[ebp], 0  sets i = 0 12/8/2018 Microprocessors I: Lecture 16

Microprocessors I: Lecture 16 Final notes Next time: More on HLL  assembly translation Reminders: HW 4 due 1:00 PM, Friday, 3/4 12/8/2018 Microprocessors I: Lecture 16