Mips Stack Examples Peter Rounce

10/13/2011 Mips Stack Examples Peter Rounce [email protected] 10/13/2011 09-GC03 Stacks 09-GC03 Stacks 1 1 10/13/2011 MIPS Stack Example ...
Author: Brian Jackson
144 downloads 1 Views 43KB Size
10/13/2011

Mips Stack Examples Peter Rounce [email protected]

10/13/2011

09-GC03 Stacks

09-GC03 Stacks

1

1

10/13/2011

MIPS Stack Example

Stack

The ‘bottom’ of the stack is anchored in one place – top moves. The ‘top’ of the stack is defined by the contents of a register, sp. accessing a data value within the stack

00EFFFFC 00EFFFF8 00EFFFF4 00EFFFF0 00EFFFEC 00EFFFE8 00EFFFE4 00EFFFE0 00EFFFDC

lw $7,8($sp) sp Register

top of stack 00EFFFD8

Where sp points is the top of the stack!

97 08 F3 FF 12 08 F3 FF 57 12

00EFFFD8 00EFFFD4 28 00EFFFD0 FF

B6 E2 7C FF 34 E2 7C FF

2A 31 00 FF 56 56 56 FF

A1 34

00 56

71 FF

55 FF

09-GC03 Stacks

09-GC03 Stacks

29 78 72 F8

4 locations (4 bytes)

Memory at address 0xefffe0 (0xefffd8 + 8) is accessed and 4 bytes read from this address and the following 3 addresses into register $7 10/13/2011

78 49 00 FF 78 56 56 FF

2

2

10/13/2011

A C Function (method):

int fun1(int p1, double p2, int p3 ) { int i , j, k, res; double r1; r1 = fun2( p1*p2+k, j, &i) ; …..

A call to the function:

return res ;

r1 = fun1(10, 11, 12) ;

}

MIPS assembler for the call (ignoring the parameters for now):jal

fun1

# $31