assembly - How to preserve the global variables in the stack in MIPS when calling a function? -


i'm developing compiler language mixes c++ , javascript mips assembly

what's best approach preserve global variables in stack when calling 1 or more functions, including recursion?

at main function, global , local variables @ stack, starting $fp, , part works well. however, when calling function, methodology i'm using saves return address $ra , sets new $fp , $sp. means have no more access old $fp addresses global variables saved. how proceed?

the image below describes process i'm using. image obtained prof. sen lectures, berkley prof. koushik sen - berkley

i put globals @ .data segment

here how access , modify content

data    globalvariable:  .word  10  .text     #access    lw $a0, globalvariable      #modify    la $a0, globalvariable #get address    li $a1, 11 #new value    sw $a1 0($a0) #save new value     lw $a2, globalvariable  #get new value 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -