1

配列を作成し、必要に応じて特定のセルの値を更新しようとしています。私の知る限り、Stack Frame を使用するのが最善の方法ですが、うまくいきません。誰でも私を正しい方向に向けることができますか?

ありがとう!

4

1 に答える 1

2

You should already have a good understanding of how array manipulation works in a language like C.

If you want to put an array in the current stack frame, and manipulate it there (and understand the benefits and issues of doing so), then you should do the following:

  1. First, take note of the current value of the stack pointer register ($sp). You will use this as the pointer to the start of the array. Store it in another register.
  2. First increment the stack pointer register ($sp) by however many bytes the array is. This will give you enough space to work.
  3. When you want to update the array, compute the address of the start of the array plus the array index. For example, to write or read element 5, add 5 to the start of the array, times the word size. On a 32-bit machine, multiply it by 4.
  4. Use the sw instruction to store a word in the array at that address, and use lw to load a word.
于 2011-02-11T05:49:33.233 に答える