2016-09-02 3 views
-1

Ich bin ein erstes Mal MIPS MARS Benutzer und halte diese Fehler:Fehlerspeicheradresse nicht auf Wortgrenze ausgerichtet

Error line 19: Runtime exception at 0x00400024: store address not aligned on word boundary 0x00000002

Dies ist der Code Ich verwende:

.data 
str: .ascii "abcdefgh" 
array: .space 20 
.text 
main: 
li $s0, 1 # a = 1 
li $s2, 1 # b = 1 
loop: 
la $t1, array 
slti $t0, $s0, 3 # t0<- 1 if a < 3 
beq $t0, $zero, exit 
sll $t0, $s0, 2 # t1<- 4*a 
add $t1, $t1, $t0 # new base addr 
add $t2, $s2, $s0 # t2<- a+b 
sw $t1, 0($t2) # D[a]=a+b 
addi $s0, $s0, 1 # a = a +1 
j loop # goes to loop: label 
exit: 
li $v0, 10 # v0<- (exit) 
syscall 

Kann jemand erklären, warum das so weitergeht?

-Code aktualisiert:

.data 
str: .ascii "abcdefgh" 
array: .space 20 
.text 
main: 
li $s0, 1 # a = 1 
li $s2, 1 # b = 1 
loop: 
la $t1, array 
slti $t0, $s0, 3 # t0<- 1 if a < 3 
beq $t0, $zero, exit 
sll $t0, $s0, 2 # t1<- 4*a 
add $t1, $t1, $t0 # new base addr 
add $t2, $s2, $s0 # t2<- a+b 
sw $t1, 2($t2) # D[a]=a+b 
addi $s0, $s0, 1 # a = a +1 
j loop # goes to loop: label 
exit: 
li $v0, 10 # v0<- (exit) 
syscall 

aber jetzt diesen Fehler Ich erhalte:

line 19: Runtime exception at 0x00400024: address out of range 0x00000004 

Wie kann ich dieses Problem beheben?

+0

Es wäre hilfreich zu wissen, auf welche Anweisung sich der Fehler bezieht. –

+0

Zeile 19: Laufzeitausnahme bei 0x00400024: Adresse außerhalb des Bereichs 0x00000004 –

+0

Das wurde bereits festgelegt; was ist Linie 19? –

Antwort

2

Wörter müssen an Adressen liegen, die Vielfache von 4 sind; Sie verwenden einen (0x00000002), der nicht ist.

Verwandte Themen