简体   繁体   中英

How to return a value to a label in MIPS64?

If I had an immediate value like:

.data
sum:  .word  0

made some calculations in the code, and wanted to put the result back into "sum" in main memory, how would I do that? I've been going over the manual for the command, but I must not be understanding concepts as well as I should.

Any help for a newbie?

Use the Store Word instruction, sw . As usual, you have to use a register for the address, or let the assembler take care of that if it provides such support.

Suppose you want to write $t0 into sum :

la $t1, sum
sw $t0, ($t1)

or simply sw $t0, sum which your assembler will turn into equivalent code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM