; implementation of method:  int add(int a, int b)
; returns a+b

	MOV	R0, #7               ; x=7   want to call
	MOV	R1, #9               ; y=9   add(x, y)

	SUB	SP, SP, #8           ; get 2 cells (8 bytes) for params
	STR	R0, [SP, #8]         ; send x, put it in "first"/"a"  spot
	STR	R1, [SP, #4]         ; send y, put it in "second"/"b" spot

	BL	SUM_A_B              ; call the function

	LDR	R2, [SP, #4]         ; copy result from top of stack
	ADD	SP, SP, #12          ; release 3 cells (2 params + 1 result)

	END                          ; stop overall execution

SUM_A_B
	SUB	SP, SP, #4           ; get 1 cell (4 bytes) for result

	STMDA	SP!, {LR, FP, R0, R1, R2}     ; preserve 5 registers:
	     	                              ; - must use ! to change SP
	     	                              ; - careful with DA? vs DB? (Dec Before?, Dec After?)

	ADD	FP, SP, #32         ; skip 8 cells to get to beginning of frame (2 params + 1 result + 5 work regs)

	LDR	R0, [FP, #0]        ; copy a from params via FP
	LDR	R1, [FP, #-4]       ; copy b from params via FP
	ADD	R2, R0, R1          ; a+b
	STR	R2, [FP, #-8]       ; put result in its cell via FP

	LDMIB	SP!, {LR, FP, R0, R1, R2}    ; restore the registers
	     	                             ; - must use ! to change SP
	     	                             ; - DA become IB (opposite dir)

	MOV	PC, LR               ; leave by setting program counter to return address