Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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 value; alloc 4 bytes.section ".text" int subr(int);.global main int main(void) main: { push {lr} a = 0; ldr r1, a = 0 a = subr( a ); mov r2, #0 return 0; str r2, } ldr r0, call subr( a ); pass “a” by value bl subr str r0, a = return value from subr in r0 mov r0, return value 0 put in r0 pop {lr} bx put lr in pc

2 Passing by-value vs. by-reference in ARM by value C code equivalent assembly code int sub( int x ) subr: add r0, r0, return value = x + 1 { bx lr return( x + 1 ); }

3 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 value; alloc 4 bytes.section ".text" int subr(int *);.global main int main(void) main: { push {lr} a = 0; ldr r1, a = 0 a = subr( &a ); mov r2, #0 return 0; str r2, ldr r0, call subr( a ); pass “a” by ref bl subr str r0, a = return value from subr in r0 mov r0, return value 0 put in r0 pop {lr} bx put lr in pc

4 Passing by-value vs. by-reference in ARM by value C code equivalent assembly code int sub( int *x ) subr: { ldr r1, parameter return(*x + 1); add r0, r1, val in r0 } bx lr


Download ppt "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."

Similar presentations


Ads by Google