Multiple Entry Points Multiple entry points allow different function names, different parameter lists, default parameters, etc. Example int fn( int a =

Slides:



Advertisements
Similar presentations
1 Storage Duration and Scope –Local and global variables Storage classes –automatic, static, external, register Todays Material.
Advertisements

EiS – Education iT Services Our passion in EiS is to make a real difference in education and ultimately childrens lives by providing innovative solutions.
For(int i = 1; i
Hello World!. PC / MS-DOS code segment para assume cs:code,ds:code org 0100h start: mov dx,offset message ;point to message mov ah,09h ;func# to printstring.
Passing by-value vs. by-reference in ARM by value C code equivalent assembly code int a;.section since a is not assigned an a:.skip initial.
Functions Prototypes, parameter passing, return values, activation frams.
1 ARM Movement Instructions u MOV Rd, ; updates N, Z, C Rd = u MVN Rd, ; Rd = 0xF..F EOR.
Run-time Environment for a Program different logical parts of a program during execution stack – automatically allocated variables (local variables, subdivided.
Test practice Multiplication. Multiplication 9x2.
LCS Non-Dynamic Version int function lcs (x, y, i, j) begin if (i = 0) or (j = 0) return 0; else if (x[i] = y[j]) return lcs(x, y, i-1, j-1)+1; else return.
Ch. 8 Functions.
C Programming and Assembly Language Janakiraman V – NITK Surathkal 2 nd August 2014.
Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, All rights reserved. You may modify and.
More on Functions Programming. COMP104 Lecture 19 / Slide 2 Passing Parameters by Reference l To have a function with multiple outputs, we have to use.
Memory Image of Running Programs Executable file on disk, running program in memory, activation record, C-style and Pascal-style parameter passing.
COMP3221: Microprocessors and Embedded Systems Lecture 13: Functions II Lecturer: Hui Wu Session 2, 2005.
Program.-(4)* Write a program for input two integer number with message and display their sum. Algorithm steps Algorithm steps 1.Display message for input.
Separate Assembly allows a program to be built from modules rather than a single source file.
FUNCTION – Microprocessor Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
MicroComputer Engineering IntroLab1 page 1 Introduction Lab1  A crash course in assembler programming  Learn how a processor works!  Decode a coded.
V 1.01 Arrays and Pointers in C A pointer variable is a variable that contains the address of another variable. An array is a collection of like elements,
1 The System Dependence Graph and its use in Program Slicing.
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
WEEK 6 Class Activities Lecturer’s slides.
Overview of Assembly Language Chapter 4 S. Dandamudi.
Arrays and Strings in Assembly
$100 $200 $300 $400 $100 $200 $300 $400 $300 $200 $100 Adding multiples of 10 Add 1 to 2 digit numbers with regrouping Add 3 two digit numbers Ways.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Improvements to the Compiler Lecture 27 Mon, Apr 26, 2004.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
ICS51 Introductory Computer Organization Accessing parameters from the stack and calling functions.
Looping Examples I.
Assembly Language Lab 9.
CS-401 Computer Architecture & Assembly Language Programming
Computer Architecture and Assembly Language
CSCI206 - Computer Organization & Programming
Functions Examples CSCI 230
Computer Architecture and Assembly Language
Separate Assembly allows a program to be built from modules rather than a single source file assembler linker source file.
(The Stack and Procedures)
ARM Assembly Programming
CSCI206 - Computer Organization & Programming
Functions Examples CSCI N305
Passing by-value vs. by-reference in ARM
Int add3 (int a, int b, int c) { return a + b + c; } int sum = 0; main () sum += add3 (1, 2, 3); sum += 10; sum += add3 (10, 20, 30);
Stack Frame Linkage.
Assembly Language Programming II: C Compiler Calling Sequences
Lec 6.
The University of Adelaide, School of Computer Science
(The Stack and Procedures)
Java Lesson 36 Mr. Kalmes.
Summary.
Stack Frames and Functions
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Компьютерийн зохион байгуулалт, ассемблер CS201
Objective - To add and subtract decimals.
Debugging with printf you can call printf from an ARM assembly language program some of the details will be explained later, but for now use this skeleton.
Function In this lesson, you will learn about Introduction to Function
CS-401 Computer Architecture & Assembly Language Programming
Where is all the knowledge we lost with information? T. S. Eliot
(The Stack and Procedures)
The multiples of Delete this text and write about what you notice:
ICS51 Introductory Computer Organization
Computer Architecture and System Programming Laboratory
MIPS function continued
Computer Architecture and System Programming Laboratory
Methods Scope How are names handled?
Procedures & Macros Introduction Syntax Difference.
Presentation transcript:

Multiple Entry Points Multiple entry points allow different function names, different parameter lists, default parameters, etc. Example int fn( int a = 1, int b = 2 ) { return( a + b ); }

Multiple Entry Points Multiple entry points allow different function names, different parameter lists, default parameters, etc. Example int fn( int a = 1, int b = 2 ) { return( a + b ); } can be written in assembly as .global %function fn_ab, fn_b, fn, sum push {lr} fn_ab: mov r0, #1 /* default first parameter */ fn_b: mov r1, #2 /* default second parameter */

Multiple Entry Points The previous example can be written in assembly as .text .global fn_ab, fn_b, fn, sum .type fn_ab, %function .type fn_b, %function .type fn, %function .type sum, %function fn_ab: mov r0, #1 /* default first parameter */ fn_b: mov r1, #2 /* default second parameter */ fn: sum: add r0, r0, r1 /* add parameters and return sum */ bx lr

Multiple Entry Points with fn() becoming call fn_ab fn(3) becoming call fn_b after the caller places 3 in r0 fn(4,6) becoming call fn (or call sum) after the caller places 4 in r0 and 6 in r1 so that a driver like this #include<stdio.h> int fn_ab(); int fn_b(int); int fn(int, int); int sum(int, int); int main() { printf("fn_ab() returns %d\n",fn_ab()); printf("fn_b(3) returns %d\n",fn_b(3)); printf("fn(4,6) returns %d\n",fn(4,6)); printf("sum(5,7) returns %d\n",sum(5,7)); return 0; }

Multiple Entry Points will print fn_ab() returns 3 fn_b(3) returns 5 fn(4,6) returns 10 sum(5,7) returns 12 Of course, multiple exit paths are also possible.