Prog Execution Diagram
Prog Execution Diagram
...... |
...... |
...... |
...... |
...... |
...... |
105d4: fa1ff0ef jal ra,10574 <add_5> |
105d8: 87aa mv a5,a0 #RA1 |
...... |
...... |
...... |
...... |
...... |
...... |
105f8: 8082 ret <---------Main ends here --------
//Note Main function start at 0x105b4 (Hex) and ends at 105f8 (Hex)
// Total main function is about (0x105f8-0x105b4) = (0x44+4) = 0x48 (hex) bytes
// Total of 0x48 bytes = 72 bytes
// If there is no JAL or any Jump, the PC starts at 0x105b4 continuosly
// increment to either 4 or 2 (depending 4-byte or 2byte instruction) and end
// at 0x105f8
We will start discussion from main function 1st instruction i.e 0x105b4
------------------
| |
------------------
| |
------------------
| |
------------------
| |
------------------
After First jal of main function at 0x105d4 (store RA1=0x105d8 after that stack has
one entry)
------------------
| |
------------------
| |
------------------
| |
------------------
| RA1=0x105d8 |
------------------
After Second jal in add_5 function at 0x10596 (store RA2=0x1059a after that stack
has two entries)
------------------
| |
------------------
| |
------------------
| RA2=0x1059a |
------------------
| RA1=0x105d8 |
------------------
After third jal in add_4 function at 0x10556 (store RA2=0x1055a after that stack
has two entries)
------------------
| |
------------------
| RA3=0x1055a |
------------------
| RA2=0x1059a |
------------------
| RA1=0x105d8 |
------------------
------------------
| |
------------------
| |
------------------
| RA2=0x1059a |
------------------
| RA1=0x105d8 |
------------------
PC continues from 0x1055a in add_4 till ret instruction in add_4 at 10572: 8082
ret
(Retrive RA2 = 0x1059a after that stack has one entry)
Now PC moves 0x1059a which is in add_5 function
------------------
| |
------------------
| |
------------------
| |
------------------
| RA1=0x105d8 |
------------------
PC continues from 0x1059a in add_5 till ret instruction in add_5 at 105b2: 8082
ret
(Retrive RA1 = 0x105d8 after that stack has zero entry)
Now PC moves 0x105d8 which is in main function
------------------
| |
------------------
| |
------------------
| |
------------------
| |
------------------
Now PC continues from 0x105d8 in main function till ret instruction at main
function
105f8: 8082 ret
We will stop our discussion at this point of time as we start 1st instruction of
main function