CS-401 Computer Architecture & Assembly Language Programming

Slides:



Advertisements
Similar presentations
Calling sequence ESP.
Advertisements

University of Washington Procedures and Stacks II The Hardware/Software Interface CSE351 Winter 2013.
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 5 MIXING C AND ASSEMBLY.
C Programming and Assembly Language Janakiraman V – NITK Surathkal 2 nd August 2014.
University of Washington Last Time For loops  for loop → while loop → do-while loop → goto version  for loop → while loop → goto “jump to middle” version.
Context Switch Animation Another one by Anastasia.
Machine-Level Programming III: Procedures Apr. 17, 2006 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables CS213.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Cse322, Programming Languages and Compilers 1 6/18/2015 Lecture #16, May 24, 2007 Runtime.c Running the code debugging assembler division strings for println.
Accessing parameters from the stack and calling functions.
– 1 – , F’02 ICS05 Instructor: Peter A. Dinda TA: Bin Lin Recitation 4.
Machine-Level Programming III: Procedures Jan 30, 2003
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2014 Lecture 4: x86 memory.
Stack Activation Records Topics IA32 stack discipline Register saving conventions Creating pointers to local variables February 6, 2003 CSCE 212H Computer.
CS2422 Assembly Language and System Programming High-Level Language Interface Department of Computer Science National Tsing Hua University.
High-Level Language Interface Chapter 17 S. Dandamudi.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
6.828: PC hardware and x86 Frans Kaashoek
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 7 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Ithaca College Machine-Level Programming IV: IA32 Procedures Comp 21000: Introduction to Computer Systems & Assembly Lang Spring 2013 * Modified slides.
University of Washington Today More on procedures, stack etc. Lab 2 due today!  We hope it was fun! What is a stack?  And how about a stack frame? 1.
Code Generation Gülfem Savrun Yeniçeri CS 142 (b) 02/26/2013.
Fabián E. Bustamante, Spring 2007 Machine-Level Programming III - Procedures Today IA32 stack discipline Register saving conventions Creating pointers.
IA32 (Pentium) Processor Architecture. Processor modes: 1.Protected (mode we will study) – 32-bit mode – 32-bit (4GB) address space 2.Virtual 8086 modes.
Low Level Programming Lecturer: Duncan Smeed The Interface Between High-Level and Low-Level Languages.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Compiler Construction Code Generation Activation Records
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
Introduction to Assembly II Abed Asi Extended System Programming Laboratory (ESPL) CS BGU Fall 2014/2015.
1 Assembly Language: Function Calls Jennifer Rexford.
CSC 221 Computer Organization and Assembly Language Lecture 16: Procedures.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Improvements to the Compiler Lecture 27 Mon, Apr 26, 2004.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
Microprocessor, Programming & Interfacing Tutorial 2- Module 3.
NASM ASSEMBLER & COMPILE WITH GCC 어셈러브 refered to ‘PC Assembly Language’ by Paul A. Carter
Assembly Language Addressing Modes. Introduction CISC processors usually supports more addressing modes than RISC processors. –RISC processors use the.
ICS51 Introductory Computer Organization Accessing parameters from the stack and calling functions.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Assembly function call convention
Reading Condition Codes (Cont.)
Computer Architecture and Assembly Language
Assembly language.
C function call conventions and the stack
Operating Systems Engineering
Computer Architecture and Assembly Language
Anton Burtsev February, 2017
Exploiting & Defense Day 2 Recap
Aaron Miller David Cohen Spring 2011
Introduction to Compilers Tim Teitelbaum
Assembly IA-32.
Computer Architecture and Assembly Language
Discussion Section – 11/3/2012
Machine-Level Programming 4 Procedures
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
Assembly Language Programming II: C Compiler Calling Sequences
Machine-Level Programming III: Procedures Sept 18, 2001
Multi-modules programming
Computer Architecture CST 250
CS-401 Assembly Language Programming
X86 Assembly Review.
Low-Level Thread Dispatching on the x86
CSC 497/583 Advanced Topics in Computer Security
ICS51 Introductory Computer Organization
Computer Architecture and System Programming Laboratory
Computer Architecture and System Programming Laboratory
Computer Architecture and System Programming Laboratory
Presentation transcript:

CS-401 Computer Architecture & Assembly Language Programming Lecture-44 Interfacing with High Level Languages

Lets Revise the Last Lecture

Calling Conventions

Calling Conventions Naming conventions Parameter passing Registers that must be preserved Registers used as scratch Registers which hold the return value Responsibility of clearing the parameters

C Vs PASCAL Naming Conventions C PASCAL An underscore is Case sensitive Prep ended all uppercase name Case sensitive

C Vs PASCAL Naming Conventions Parameter Passing C PASCAL Pushed in reverse Pushed in proper Order order

C Vs PASCAL Naming Conventions Registers that must be preserved C PASCAL EBX, EDI, EBP, ESP, DS, ES and SS

C Vs PASCAL Naming Conventions Registers used as scratch C PASCAL EAX, ECX, EDX, FS, GS, EFLAGS and all others

C Vs PASCAL Naming Conventions Registers which hold the return value C PASCAL EAX (32 – bit value) EDX:EAX (64 – bit value)

C Vs PASCAL Naming Conventions Responsibility of clearing parameters C PASCAL Caller Callee

Calling C from Assembly Responsibility of clearing parameters int divide(int dividend, int divisor); push dword [mydivisor] Push dword [mydividend] Call_divide Add esp,8 ;EAX holds the answer

Swap in C void swap (int *p1, int *p2) { int temp = *p1; *p1 = *p2; *p2 = temp; }

Calling Swap from Assembly [section .text] extern_swap x:dd 4 y:dd 7 push dword y push dword x call_swap ; will only retain the ; specified registers add esp,8

Swap in Assembly [segment .text] global _swap _swap: mov ecx,[esp+4] ;copy parameter p1 mov edx,[esp+8] ;copy parameter p2 mov eax,[ecx] ;copy *p1 into eax xchg eax,[edx] ;copy eax into *p2 mov [ecx],eax ;copy ecx into *p1 ret

OBJ file in win32

Swap In Assembly Language