【问题标题】:MIPS and Assembly finding the sections of a parameter blockMIPS 和 Assembly 查找参数块的部分
【发布时间】:2016-02-29 17:46:45
【问题描述】:

在函数中,给定的参数包含一个参数块。在该参数块中,前两个部分包含单独的字符串,第三部分将存储组合字符串。如何确定参数块各段的地址位置?

【问题讨论】:

  • 你能举个例子吗?标签是一个地址,你想要的东西的地址只是放一个唯一的标签。
  • Yes.Register a0 是一个参数块的地址。对于该地址,它包含单词。 1. 字符串的地址。 2.字符串的地址。 3. 另一个字符串的地址 4. 字符串的长度。如何访问这些值?

标签: debugging assembly mips


【解决方案1】:

执行索引或间接寻址。

这是一个例子:

.data
.align  2

problem1:
    .word   str_a1      # First number
    .word   str_a2      # Second number
    .word   buf_a       # Place to store the result
    .word   1           # Length of both numbers and result buf
    .word   out_a       # Where to start printing the answer


.text
...

la    $a0,problem    # Address of parameters for
jal   print_label    #   problem 1, and do it.


print_label:
...
move    $s0, $a0        # copy the loc of the parm block to s0

li  $v0, 4              # print 1st number  
lw  $a0, 0($s0)
syscall

li  $v0, 4              # print 2nd number  
lw  $a0, 4($s0)         # Indexing!
syscall


li  $v0, 4              # print newline at end  
la  $a0, result3
syscall

标签表示是不相关的。本质上,$a0 的内容被复制到 $s0 并通过索引访问。如果你要增加它的“指针”,那将是间接位移。

执行任何操作,它们可以保存在参数块 $a0 中的一个移位位置,然后读出,如标签问题1所示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-27
    • 1970-01-01
    • 2021-04-07
    • 1970-01-01
    相关资源
    最近更新 更多