Download presentation
Presentation is loading. Please wait.
Published byBudi Tedjo Modified over 6 years ago
1
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 ); }
2
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, # /* default first parameter */ fn_b: mov r1, # /* default second parameter */
3
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, # /* default first parameter */ fn_b: mov r1, # /* default second parameter */ fn: sum: add r0, r0, r /* add parameters and return sum */ bx lr
4
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; }
5
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.