/* ----------------------------------------------
sumSquares(a,b): returns (a*a + b*b)
---------------------------------------------- */
int sumSquares( int a, int b )
{
return (a*a + b*b);
}
void main( )
{
int x, y, z;
z = sumSquares(x, y);
}
|
|
/* -------------------------------------------------
Pass parameter x by copying its value in reg r0
------------------------------------------------- */
movw r0, #:lower16:x
movt r0, #:upper16:x
ldr r0, [r0]
/* -------------------------------------------------
Pass parameter y by copying its value in reg r1
------------------------------------------------- */
movw r1, #:lower16:y
movt r1, #:upper16:y
ldr r1, [r1]
/* ----------------------------------------------------------------
call z = sumSquares(x,y):
agreed inputs: r0 = x, r1 = y
|
/* ----------------------------------------------------------------
Function sumSquares(a,b):
agreed inputs: r0 = a, r1 = b
agreed return: r0 = return value
---------------------------------------------------------------- */
sumSquares:
// When sumSquares begin, we will have: r0 = a, r1 = b
|
How to run the program:
|