2016-09-29 4 views

答えて

1

コードライン・バイ・ラインを理解することができます:

.data   # static variables are defined in .data block 
A: .word 0:100 # array 100 of integers each initialized to 0 

    .text   # MIPS code block 
li $t1, 4  # loading a 16 bit constant value 4 into register $t1 

lw $t0, A($t1) # going to the memory at the address of A (address 
        # of first element of array) + $t1 (which contains 
        # value 4) and fetch it into register $t0 

左:

.data   # static variables are defined in .data block 
A: .word 0:100 # array 100 of integers each initialized to 0 

    .text   # MIPS code block 
la $t1, A  # load the address of first element of array 
        # into register $t1 

lw $t0, 4($t1) # going to the memory at the address of $t1 + 4 
        # and fetch it into register $t0 

注: MIPSのアドレスはバイトで、整数(.word)は4バイトです。したがって、配列のベースアドレス(配列のベースアドレス)を4増加させると、配列の2番目の要素のアドレスになります。

したがって: 2つのコードは同じです。最後に、配列の2番目の要素(index = 1)の内容がレジスタ$t0にロードされます。

関連する問題