; void swap (int*, int*); ; void main (void) ; { ; int x = 2, y = 3; ; swap (&x, &y); /* swap x and y */ ; } ; void swap (int *a, int *b) ; { ; int temp; ; temp = *a; ; *a = *b; ; *b = temp; ; } AREA SwapVal, CODE, READONLY ENTRY MOV sp, #0x00000000 B main swap SUB sp, sp, #4 LDR r1, [sp, #8] ; get address of parameter a LDR r2, [r1] ; get value of parameter a STR r2, [sp] ; store parameter a in temp in stack frame LDR r0, [sp, #4] ; get address of parameter b LDR r3, [r0] ; get value of parameter b STR r3, [r1] ; store parameter b in parameter a LDR r3, [sp] ; get temp from stack frame STR r3, [r0] ; store temp in b ADD sp, sp, #4 MOV pc, lr main SUB sp, sp, #8 ADR r6, x ; store x on the STR r6, [sp, #4] ; store &x on the stack ADR r6, y STR r6, [sp] ; store &y on the stack BL swap ADD sp, sp, #8 Stop B Stop x DCD 2 y DCD 3 END