7

如何将整数读入 MIPS 中的局部变量?

问题要求我使用将整数变量分配为局部变量的概念。(我教科书中的一个问题。)

4

1 回答 1

23
li $v0, 5              # MARS/SPIM call number 5: read int
syscall                # return value in $v0
move $t0, $v0

The value is now in $t0. This will read the integer from the console.

"local variables" in asm can be registers or stack space.

MARS system-call documentation: http://courses.missouristate.edu/kenvollmar/mars/help/syscallhelp.html

于 2011-08-01T19:33:24.213 回答