【发布时间】:2012-03-05 13:27:51
【问题描述】:
知道为什么我会遇到对齐错误吗?执行la $t0, mainF 时会发生错误,即使类似的行la $t0, mainB 执行得很好。这是我第一次在 MIPS 中编码,所以我做了一些研究并对地址对齐的含义有一个模糊的概念,但是编译器甚至没有到达我添加 4 的部分,然后才抛出这个运行时异常。
.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)
...
【问题讨论】:
-
握住你的马,我没有意识到它没有显示行号。我指出来了。更好的?即使解释为什么它可能会让我犯这个错误也会有所帮助。 (这就是我犹豫使用帮助论坛的原因。没有人愿意提供帮助。)
-
好的,我重写了你的问题,以演示如何编写它以使其易于回答。
标签: assembly alignment mips runtime-error