Download presentation
Presentation is loading. Please wait.
Published byKarson Wigton Modified over 10 years ago
1
Passing by-value vs. by-reference in ARM by value C code equivalent assembly code int a;.section ".bss" @.bss since a is not assigned an a:.skip 4 @ initial value; alloc 4 bytes.section ".text" int subr(int);.global main int main(void) main: { push {lr} a = 0; ldr r1, =a @ a = 0 a = subr( a ); mov r2, #0 return 0; str r2, [r1] @ } ldr r0, [r1] @ call subr( a ); pass “a” by value bl subr str r0, [r1] @ a = return value from subr in r0 mov r0, #0 @ return value 0 put in r0 pop {lr} bx lr @ 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, #1 @ 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 ".bss" @.bss since a is not assigned an a:.skip 4 @ initial value; alloc 4 bytes.section ".text" int subr(int *);.global main int main(void) main: { push {lr} a = 0; ldr r1, =a @ a = 0 a = subr( &a ); mov r2, #0 return 0; str r2, [r1] @ ldr r0, r1 @ call subr( a ); pass “a” by ref bl subr str r0, [r1] @ a = return value from subr in r0 mov r0, #0 @ return value 0 put in r0 pop {lr} bx lr @ 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, [r0] @deref parameter return(*x + 1); add r0, r1, #1 @return val in r0 } bx lr
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.