任何想法爲什麼我收到對齊錯誤?執行la $t0, mainF
時發生錯誤,即使類似的行la $t0, mainB
執行得很好。這是我第一次在MIPS中編寫代碼,所以我做了一些研究,並且對地址對齊意味着什麼有一個模糊的概念,但編譯器甚至沒有在我將這個運行時異常拋出之前加入4的部分。讀取地址未在字邊界上對齊(MIPS)
.data
mainF:
.byte 1
mainB:
.byte 1
mainN:
(has '.word's, generic tests for the program itself)
newline:
.asciiz "\n"
textFw:
.asciiz "The integers in order:\n"
textBw:
.asciiz "The integers in backwards order:\n"
.text
main:
# Function prologue
addiu $sp, $sp, -24 # allocate stack space -- default of 24 here
sw $fp, 0($sp) # save caller's frame pointer
sw $ra, 4($sp) # save return address
addiu $fp, $sp, 20 # setup main's frame pointer
# Put mainF into $s0
la $t0, mainF
lw $s0, 0($t0)
# Put mainB into $s1
la $t0, mainB
lw $s1, 0($t0)
...
抱着你的馬,我沒有意識到它沒有顯示行號。我指出了。更好?甚至解釋爲什麼它可能會拋出我的錯誤會有所幫助。 (這就是我爲什麼猶豫使用幫助論壇的原因,沒有人願意幫忙。) – Alyssa 2012-02-14 06:11:21
好的,我重寫了你的問題,以演示如何寫它來使它很容易回答。 – Gabe 2012-02-14 06:23:40